Code Monkey home page Code Monkey logo

wecount.inclusivedesign.ca's Introduction

We Count

License GitHub Release GitHub Workflow Status Netlify Status

The source code for the We Count website.

The front end of the website is built with Eleventy.

The website uses Decap CMS to manage the following content:

The website also uses one backend API:

  • Airtable API that serves user comments for events.
    • The production table: WeCount
    • The development table: WeCount_DEV

Getting Started

To contribute, please be sure to review our development processes as documented in the contributing guide.

To work on the project, you need to install NodeJS and NPM for your operating system.

Then, clone the project from GitHub. Create a fork with your GitHub account, then enter the following in your command line (make sure to replace your-username with your username):

git clone https://github.com/your-username/wecount.inclusivedesign.ca.git

From the root of the cloned project, enter the following in your command line to install dependencies:

npm ci

Content Management System (CMS)

Decap CMS is a client-side React application which manages files in a git repository, creating pull requests when new content is drafted and merging them when it is published. Access to this website's CMS is managed via Netlify Identity. If you need access to the CMS, a team administrator must invite you to create a Netlify Identity account.

CMS Configuration

The CMS is configured via a config.yml file according to Decap CMS' specifications. As an example, here is the configuration for the events collection, stored in src/collections/events:

- name: events
  label: Events
  label_singular: Event
  folder: src/collections/events
  sortable_fields: [eventDate, title]
  slug: "{{title}}"
  preview_path: "events/{{slug}}"
  create: true
  fields:
    - label: Event Title
      name: title
      widget: string
    - label: Event ID
      name: id
      widget: uuid
      hint: The ID is used to associate comments with this event and cannot be edited.
    - label: Permanent Link
      name: permalink
      widget: string
      required: false
      hint: |-
        If you do not specify a permanent link, one will be automatically generated from the event title.
        Permalinks must have the format /events/event-title/ (the trailing slash is required).
    - label: Event Date
      name: eventDate
      widget: datetime
      time_format: false
      required: false
    - label: Cover Image
      name: coverImageUrl
      widget: image
      required: false
    - label: Cover Image Alt Text
      name: coverImageAltText
      widget: string
      required: false
    - label: Event Body
      name: body
      widget: markdown
    - label: Short Description
      name: shortDescription
      widget: markdown
      hint: The short description is shown on the Events page.
    - label: Preview Image
      name: previewImageUrl
      widget: image
      required: false
      hint: The preview image is shown on the Events page.
    - label: Preview Image Alt Text
      name: previewImageAltText
      widget: string
      required: false

For information on individual widgets and their configuration, see Decap CMS' widget documentation.

Previews

Decap CMS supports preview templates for CMS content, which must be a React component registered with the following code (the following examples are for events):

CMS.registerPreviewTemplate("events", Event);

The Event React component is created in src/admin/cms.js based on a technique demonstrated in Andy Bell's Hylia Eleventy starter kit:

  1. The site's Nunjucks templates are precompiled and copied to the admin directory of the built site (Eleventy handles this here).
  2. A generic Preview React component accepts a data object and a Nunjucks template path, renders the Nunjucks template with the supplied data using Nunjucks Slim, and outputs the resulting HTML.
  3. The specific Event React component passes the Preview component the entry object (from Decap CMS), the Nunjucks template path (relative to src/_includes), and a function which maps the entry object's data to what's needed in the Nunjucks template expects.

This approach allows the templates which Eleventy uses to render the production site to be consumed by Decap CMS and used to generate live previews as content editors are updating content in the CMS interface.

Testing the CMS

The CMS may be tested locally without authentication if the site is being run in development mode as documented below. Any changes made will be immediately reflected in the file system. This is a good way of making sure that CMS functionality behaves as expected, but content should not be edited this way under normal circumstances. Rather, content editors should log in under their Netlify Identity accounts at https://wecount.inclusivedesign.ca/admin/ and create content through the CMS interface.

How to Run

The website uses Netlify Functions to provide a server side endpoint that supports the save of user comments for initiatives on the "Initiatives" page. To run the website in local development mode that supports a live reload at file changes, there are two ways to test the website with and without Netlify Functions. The latter is easier than the former:

Test the website with Netlify Functions

  1. Follow Netlify instructions to install tools for testing and deploying Netlify functions locally;
  2. Once the tool is set up, using Netlify Dev as an example, run following commands:
# Due to security concerns, these environment variables are only available to WeCount team members
export AIRTABLE_API_KEY=AIRTABLE_API_KEY_VALUE
export EMAIL_FROM=EMAIL_TO_VALUE
export EMAIL_FROM_PWD=EMAIL_FROM_PWD_VALUE
export EMAIL_TO_PRODUCTION=PRODUCTION_SITE_MODERATOR_EMAIL
export EMAIL_TO_DEV=DEV_SITE_MODERATOR_EMAIL
export AIRTABLE_BASE_PRODUCTION=AIRTABLE_BASE_VALUE_FOR_PRODUCTION
export AIRTABLE_BASE_DEV=AIRTABLE_BASE_VALUE_FOR_DEV

netlify dev

Look for this box in your console output:

   ┌──────────────────────────────────────────────────┐
   │                                                  │
   │   * Server now ready on http://localhost:64939   │
   │                                                  │
   └──────────────────────────────────────────────────┘

The website will be available at http://localhost:64939.

Alternatively, a .env file can be created within the local project directory and environment variables can be added directly to it as follows:

AIRTABLE_API_KEY=AIRTABLE_API_KEY_VALUE
EMAIL_FROM=EMAIL_TO_VALUE
EMAIL_FROM_PWD=EMAIL_FROM_PWD_VALUE
EMAIL_TO_PRODUCTION=PRODUCTION_SITE_MODERATOR_EMAIL
EMAIL_TO_DEV=DEV_SITE_MODERATOR_EMAIL
AIRTABLE_BASE_PRODUCTION=AIRTABLE_BASE_VALUE_FOR_PRODUCTION
AIRTABLE_BASE_DEV=AIRTABLE_BASE_VALUE_FOR_DEV

(Note: .env is in the project's .gitignore file to prevent sensitive information from being accidentally committed to git.)

If a .env file is used, the local development server can be started with the following command:

netlify dev

Test the website without Netlify Functions

Note that the website launched via this testing method cannot save user comments to Airtable due to the absence of the server side save function.

# Due to security concerns, these environment variables are only available to WeCount team members
export AIRTABLE_API_KEY=WECOUNT_API_KEY
export AIRTABLE_BASE_PRODUCTION=AIRTABLE_BASE_VALUE_FOR_PRODUCTION
export AIRTABLE_BASE_DEV=AIRTABLE_BASE_VALUE_FOR_DEV
npm run start

The website will be available at http://localhost:3000.

Alternatively, a .env file can be created within the local project directory and environment variables can be added directly to it as follows:

AIRTABLE_API_KEY=AIRTABLE_API_KEY_VALUE
AIRTABLE_BASE_PRODUCTION=AIRTABLE_BASE_VALUE_FOR_PRODUCTION
AIRTABLE_BASE_DEV=AIRTABLE_BASE_VALUE_FOR_DEV

(Note: .env is in the project's .gitignore file to prevent sensitive information from being accidentally committed to git.)

If a .env file is used, the local development server can be started with the following command:

npm run start

How to Lint

To lint JavaScript, CSS and Markdown files in the project (including JavaScript and CSS in Vue components), enter the following in the command line:

npm run lint

We use the following lint configurations:

How to Build

Note that the website launched via this build method cannot save user comments to Airtable due to the absence of the server side save function.

To build and serve a static version of the website, enter the following in your command line:

# Due to security concerns, these environment variables are only available to WeCount team members
export AIRTABLE_API_KEY=AIRTABLE_API_KEY_VALUE
export AIRTABLE_BASE_PRODUCTION=AIRTABLE_BASE_VALUE_FOR_PRODUCTION
npm run build
npm run serve

The website will be available at http://localhost:5000.

Alternatively, a .env file can be created within the local project directory and environment variables can be added directly to it as follows:

AIRTABLE_API_KEY=AIRTABLE_API_KEY_VALUE
AIRTABLE_BASE_PRODUCTION=AIRTABLE_BASE_VALUE_FOR_PRODUCTION

(Note: .env is in the project's .gitignore file to prevent sensitive information from being accidentally committed to git.)

If a .env file is used, the site can be built and served with the following commands:

npm run build
npm run serve

How to Deploy

This repository is connected to Netlify, and commits will be automatically deployed as follows:

License

Creative Commons Licence

This work is licensed under a Creative Commons Attribution 4.0 International License.

wecount.inclusivedesign.ca's People

Contributors

amb26 avatar blueslug avatar carenwatkins avatar chaitanyassr avatar chosww avatar cindyli avatar dependabot[bot] avatar fluid-bot avatar github-actions[bot] avatar greatislander avatar gtirloni avatar idrc-cms-bot avatar jobara avatar teddtech avatar uttaraghodke avatar vr619536 avatar waharnum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wecount.inclusivedesign.ca's Issues

Fix: BootstrapVue import warning

Describe the bug

Running in dev mode:

wecount.inclusivedesign.ca/plugins/bootstrap-vue.js
  2:8  warning  Using exported name 'BootstrapVue' as identifier for default export  import/no-named-as-default

To Reproduce

Examine terminal output.

Expected behavior

No warnings.

Additional context

cc: @TeddTech

Set up typography styles

Is your feature request related to a problem? Please describe.

Create styles for headings level 1-3 and paragraphs from Figma specifications.

Describe the solution you'd like

Put these styles in the appropriate Sass partial.

Describe alternatives you've considered

Not applicable.

Additional context

Not applicable.

CI Task not flagging Nuxt generating error

Describe the bug

The CI jobs are all passing; however, the Nuxt Generation step is reporting an error if you look at the logs.

To Reproduce

Steps to reproduce the behavior:

  1. https://github.com/inclusive-design/wecount.inclusivedesign.ca/runs/428626425
  2. Expand the "npm install, build, and test" job
  3. Scroll to the bottom of the logs
  4. Notice the error [error] Error generating /we-count

Expected behavior

Errors should cause the CI job to fail. It might also be a good idea to separate the install, linting, build, and test steps into separate jobs. This would make it easier to see at a glance which step failed when something goes wrong.

Fix: component property order

Describe the bug

Running in dev mode:

wecount.inclusivedesign.ca/components/Search.vue
  36:2  warning  The "fetch" property should be above the "methods" property on line 24  vue/order-in-components

✖ 1 problem (0 errors, 1 warning)

To Reproduce

  1. npm run dev
  2. Look at terminal output.
  3. See error.

Expected behavior

No warnings about this issue.

Additional context

cc: @TeddTech

Query Images

Describe the bug

The images that appear on post and page links do not display properly.
They either display the image partly (if too big) or repeat in a tile pattern (if too small).

To Reproduce

Go to News page or query "" in the search bar of We Count webpage.

Expected behavior

Ful imaged diplayed

Screenshots

image

Page Layout: News

The News page, with a grid of NewsItem components and paged navigation.

Add Fira Sans webfont

Is your feature request related to a problem? Please describe.

The designs use Fira Sans and Fira Sans Bold. The webfonts for these typefaces need to be added to the project.

Describe the solution you'd like

Find an efficient way to load these webfonts into Nuxt.

Describe alternatives you've considered

Not applicable.

Additional context

Not applicable.

API: split routes for News and Views

Is your feature request related to a problem? Please describe.

The News page will contain short excerpts linking to external articles/videos/etc. The Views page will contain full length articles written by members of the We Count project. This will necessitate creating separate pages at /news and /views and populating the content from category feeds from the WordPress API.

Describe the solution you'd like

Instead of the existing /news-and-views page, we need to create separate pages at /news and /views, populating the content from category feeds from the WordPress API:

Describe alternatives you've considered

Not applicable.

Additional context

Not applicable.

API: create tag archives statically

Is your feature request related to a problem? Please describe.

Right now tags are loaded into the VueX Store and can be queried by visiting /tags?s=<tagname>. This means all the tag matching has to happen client side.

Describe the solution you'd like

We should build archives for each tag during the generate step. So, for example, a list of posts tagged with AI could be retrieved from https://wecount.inclusivedesign.ca/wp-json/wp/v2/posts?tags=3, and the archives would be built at /tags/ai/.

Describe alternatives you've considered

Not applicable.

Additional context

Tag archives will need to be paginated.

Fix: appThemeColor and appBgColor

Describe the bug

In assets/config.js, remove extra character in appThemeColor and appBgColor strings.

Additional context

Both values are # followed by seven characters, which are not valid hex color values. The appThemeColor value should have the last f removed and the appBgColor value should have the trailing space removed.

Structure: set up base components

Restructure project as follows.

Components:

  • Header
    • Brand (logo and site title)
    • NavBar
    • SearchForm
  • Main
    • Aside (sidebar, used on some pages as shown in wireframes)
    • Article (content of a single page or post)
    • PostGrid (grid of posts, used on News page or search results)
      • PostPreview (single post preview in grid)
  • Footer
    • ContactInfo
    • SocialMedia
    • Funders

Layouts:

  • Default
  • Error

Pages:

Reorganize these as requested in #39. All of them include the same content structure, except for the News page, the Tag pages and the Search page:

<div id="container">
	<h1 id="title">{{ Title }}</h1>
	<div id="api-content" v-html="Content" />
</div>

So you should import this from the Article component.

For News, Tag, and Search, you should import the PostGrid component.

Please let me know if you have any questions about this and we can talk through it.

API: generate page routes dynamically

Is your feature request related to a problem? Please describe.

Right now, each named page from the WordPress backend has a corresponding route (about.vue, tools.vue, inclusion-challenges.vue etc). This involves lots of duplication as all of these Vue files are identical.

Describe the solution you'd like

All pages except for the Home page (index.vue) should share a single template, under /_page/index.vue, and the routes should be generated from the WordPress API response for the pages endpoint: https://wecount.inclusivedesign.ca/wp-json/wp/v2/pages

Describe alternatives you've considered

Not applicable.

Additional context

Not applicable.

Avoid mixing tabs and spaces for indentation

Describe the bug

Indentation should either use tabs or spaces, but not both. The .eslintrc.js and .editroconfig files both define indentation as 2 tabs. However, there are files where there are spaces used for indentation, files that have some lines with spaces and others with tabs, and files that have both tabs and spaces used on the same line.

To Reproduce

Steps to reproduce the behavior:

  1. Open .eslintrc.js
  2. Notice the inconsistent indentations

On GitHub you'll notice this as the indentation being larger for some lines than others. In an editor you can set the invisible characters to be shown.

Expected behavior

The indentations should all use a consistent format; character and size.
Note: you may want to have some file types use tabs and others spaces. That is acceptable but should be consistent. And this should be defined in the editorconfig and/or lint files.

Only Import Necessary Bulma folders

Is your feature request related to a problem? Please describe.

Importing the full Bulma framework would include some unwanted functionality (e.g. set class stylings).

After the We Count check-in on 03/10/20, it is decided to only make use of the layout and grid functionality of Bulma. Additional functionality will be added as/if needed.

Describe the solution you'd like

changed main.scss from:

@import "~bulma"

to

@import "bulma/sass/utilities/_all.sass";
@import "bulma/sass/grid/_all.sass";
@import "bulma/sass/layout/_all.sass";

starting at line 9

Describe alternatives you've considered

not applicable.

Additional context

http://versions.bulma.io/0.7.2/documentation/overview/modular/

Fix: remove `<b>` tags

Describe the bug

Right now, <h1> elements include <b> tags:

<h1 id="title">
	<b>About</b>
</h1>

The <b> tag should not be used. Instead, the main stylesheet should use font-weight to set the weight of the <h1> element to bold if desired.

To Reproduce

Review source of Vue templates.

Expected behavior

<b> tags are not used for formatting.

Additional context

cc: @TeddTech

Fix: unexpected console statement (index.vue)

Describe the bug

In dev mode:

wecount.inclusivedesign.ca/pages/search/_query/index.vue
  72:4  warning  Unexpected console statement  no-console

✖ 1 problem (0 errors, 1 warning)

To Reproduce

Steps to reproduce the behavior:

  1. npm run dev
  2. Inspect terminal output.
  3. See error.

Expected behavior

No warnings.

Additional context

cc: @TeddTech

linting error: 'next' is not defined

Describe the bug

Running the linting task returns the following error:

/Users/jo/Documents/git/wecount.inclusivedesign.ca/nuxt.config.js
39:13 error 'next' is not defined no-undef

If next is a global function, this needs to be indicated as a global variable. However, it may just be something that actually hasn't been defined. If that's the case I wonder if it's related to #19

To Reproduce

Steps to reproduce the behavior:

  1. From the command line run npm run lint
  2. The linting error for nuxt.config.js should be returned

Expected behavior

Linting should return without errors.

Add linting task to CI

Describe the solution you'd like

Add the npm run lint task to CI. Probably run between npm install and npm test

Add Markdown Linting

Is your feature request related to a problem? Please describe.

We should define the syntax rules we use for Markdown Files and provide a linting tasks to verify them.

Update page templates to use Article component

Is your feature request related to a problem? Please describe.

All page templates should use the Article component.

Describe the solution you'd like

Update the pages/ directory to fix the routing issues identified in #39. Make sure the routes match those defined in #53. For every page (except News and Views), import the Article component and pass the title and content data to it.

Describe alternatives you've considered

Not applicable.

Additional context

Add information for running/building the site

Describe the solution you'd like

There should be information added to the README about how to build, run/test, and deploy the site. At the moment the package.json has dev, build, start, and generate scripts. It isn't clear when to use which or what they do. We'd have to look through the nuxt docs to look that up, but it should be easy for anyone to come and at least get it up and running to make a small change or test the site.

Fix: missing prop types (Post.vue)

Describe the bug

When running in dev mode:

wecount.inclusivedesign.ca/components/Post.vue
  48:10  warning  Prop "picture" should define at least its type  vue/require-prop-types
  48:21  warning  Prop "title" should define at least its type    vue/require-prop-types
  48:30  warning  Prop "date" should define at least its type     vue/require-prop-types
  48:38  warning  Prop "slug" should define at least its type     vue/require-prop-types

✖ 4 problems (0 errors, 4 warnings)

To Reproduce

Steps to reproduce the behavior:
1.npm run dev
2. Examine CLI console.

Expected behavior

No warning.

Additional context

cc: @TeddTech

Confirm that User Interface Options can override component-level styles

Is your feature request related to a problem? Please describe.

As it's likely that we will be integrating User Interface Options (UIO) into this project, we need to confirm that UIO can override styles within Vue components.

Describe the solution you'd like

  1. Test the site with the UIO+ Chrome extension.
  2. Document any issues.
  3. If necessary, move component-level styles into global stylesheet, adhering as closely to Vue best practices as possible.

Describe alternatives you've considered

Alternative approaches to be determined after testing.

Additional context

Tooling: add accessibility tests

Is your feature request related to a problem? Please describe.

Add automated testing for basic accessibility issues.

Describe the solution you'd like

Deque's axe-cli seems like a good option: https://github.com/dequelabs/axe-cli

Describe alternatives you've considered

Not applicable.

Additional context

Not applicable.

Error page is thrown when querying "" in search

Describe the bug

When querying "" in the search bar the error page is thrown.
Only effects some pages.

To Reproduce

Steps to reproduce the behavior:

  1. Go to search
  2. query ""

Expected behavior

should return all pages as results

Static site generation creates duplicate content

Describe the bug

A number of pages are duplicated when building the site statically using the nuxt generate command.

To Reproduce

Steps to reproduce the behavior:

  1. Run npm run generate.
  2. Examine the output.
  3. Note the presence of duplicate content (/About/ and /news/about/, /news/ and /news/news/, the main index.html page, /news/we-count/, and we-count/ — this last produces the generate error identified in #37):
├── About
│   └── index.html
├── index.html
├── news
│   ├── about
│   │   └── index.html
│   ├── index.html
│   ├── news
│   │   └── index.html
│   ├── the-importance-of-peripheral-vision
│   │   └── index.html
│   ├── walrus-talk
│   │   └── index.html
│   └── we-count
│       └── index.html
└── we-count
    └── index.html

Expected behavior

Site structure should be as follows:

├── about
│   └── index.html
├── index.html
├── news
    ├── index.html
    ├── the-importance-of-peripheral-vision
    │   └── index.html
    ├── walrus-talk
        └── index.html

Additional context

I expect this is caused by unnecessary templates in /pages.

Fix: explicit keys missing for component lists rendered with v-for

Describe the bug

In pages/tag/_query/index.vue:

<b-col v-for="x in row">: component lists rendered with v-for should have explicit keys. See https://vuejs.org/guide/list.html#key for more info.

<b-row v-for="row in groupedPosts">: component lists rendered with v-for should have explicit keys. See https://vuejs.org/guide/list.html#key for more info.

To Reproduce

  1. npm run dev
  2. Inspect terminal output.
  3. See error.

Expected behavior

No warnings.

Additional context

@cc: @TeddTech

Component: NewsItem

A component for rendering a post preview in the grid on the News and Views page.

Fix: missing prop type (Error.vue)

Describe the bug

When running in dev mode:

wecount.inclusivedesign.ca/layouts/error.vue
  30:10  warning  Prop "error" should define at least its type  vue/require-prop-types

✖ 1 problem (0 errors, 1 warning)

To Reproduce

  1. npm run dev
  2. Examine terminal output.
  3. See error.

Expected behavior

No warnings about this issue.

Additional context

cc: @TeddTech

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.