From fe29b0b5c0454a7ac103417cb1748bffc6f7e1c3 Mon Sep 17 00:00:00 2001 From: delisma Date: Wed, 22 May 2024 11:04:04 -0400 Subject: [PATCH] feat: Add CMS settings --- .github/worklows/cypress.yml | 30 +++++++++++++ .gitignore | 5 ++- Gemfile | 5 +-- Gemfile.lock | 70 +++++++++++++++-------------- _includes/resources-inc/footer.html | 17 +++++-- _includes/resources-inc/head.html | 17 +++++++ _layouts/core.html | 14 +++--- cypress.json | 4 ++ cypress/integration/cms_spec.js | 26 +++++++++++ en/admin/config.yml | 33 ++++++++++++++ en/admin/index.html | 14 ++++++ netlify.toml | 4 ++ 12 files changed, 191 insertions(+), 48 deletions(-) create mode 100644 .github/worklows/cypress.yml create mode 100644 _includes/resources-inc/head.html create mode 100644 cypress.json create mode 100644 cypress/integration/cms_spec.js create mode 100644 en/admin/config.yml create mode 100644 en/admin/index.html create mode 100644 netlify.toml diff --git a/.github/worklows/cypress.yml b/.github/worklows/cypress.yml new file mode 100644 index 00000000..1f7e7400 --- /dev/null +++ b/.github/worklows/cypress.yml @@ -0,0 +1,30 @@ +name: Cypress Tests + +on: [push, pull_request] + +jobs: + cypress-run: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Install dependencies + run: npm install + + - name: Start Jekyll server + run: | + gem install bundler jekyll + bundle install + nohup bundle exec jekyll serve --host 0.0.0.0 & + + - name: Wait for Jekyll to start + run: npx wait-on http://localhost:4000 + + - name: Run Cypress tests + run: npx cypress run \ No newline at end of file diff --git a/.gitignore b/.gitignore index 40da2e53..fc1b0024 100644 --- a/.gitignore +++ b/.gitignore @@ -33,8 +33,11 @@ Temporary Items #IDE .vscode/ +node_modules/ # Jekyll .jekyll-cache _site -vendor \ No newline at end of file +vendor +Gemifile +Gemfile.lock diff --git a/Gemfile b/Gemfile index d08d3e6f..7b8ffa59 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,3 @@ -# frozen_string_literal: true - source "https://rubygems.org" -gem "jekyll-seo-tag" -gem "jekyll-remote-theme", github: "benbalter/jekyll-remote-theme", branch: "master" \ No newline at end of file +gem "jekyll-remote-theme", github: "benbalter/jekyll-remote-theme", branch: "master" diff --git a/Gemfile.lock b/Gemfile.lock index 69296789..7ff76c7d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,73 +12,77 @@ GIT GEM remote: https://rubygems.org/ specs: - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) + bigdecimal (3.1.8) colorator (1.1.0) - concurrent-ruby (1.1.10) + concurrent-ruby (1.3.1) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) eventmachine (1.2.7) - ffi (1.15.5) + ffi (1.17.0-arm64-darwin) forwardable-extended (2.6.0) + google-protobuf (4.27.0-arm64-darwin) + bigdecimal + rake (>= 13) http_parser.rb (0.8.0) - i18n (1.10.0) + i18n (1.14.5) concurrent-ruby (~> 1.0) - jekyll (4.2.2) + jekyll (4.3.3) addressable (~> 2.4) colorator (~> 1.0) em-websocket (~> 0.5) i18n (~> 1.0) - jekyll-sass-converter (~> 2.0) + jekyll-sass-converter (>= 2.0, < 4.0) jekyll-watch (~> 2.0) - kramdown (~> 2.3) + kramdown (~> 2.3, >= 2.3.1) kramdown-parser-gfm (~> 1.0) liquid (~> 4.0) - mercenary (~> 0.4.0) + mercenary (>= 0.3.6, < 0.5) pathutil (~> 0.9) - rouge (~> 3.0) + rouge (>= 3.0, < 5.0) safe_yaml (~> 1.0) - terminal-table (~> 2.0) - jekyll-sass-converter (2.2.0) - sassc (> 2.0.1, < 3.0) - jekyll-seo-tag (2.8.0) - jekyll (>= 3.8, < 5.0) + terminal-table (>= 1.8, < 4.0) + webrick (~> 1.7) + jekyll-sass-converter (3.0.0) + sass-embedded (~> 1.54) jekyll-watch (2.2.1) listen (~> 3.0) - kramdown (2.3.2) + kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) - liquid (4.0.3) - listen (3.7.1) + liquid (4.0.4) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) mercenary (0.4.0) pathutil (0.16.2) forwardable-extended (~> 2.6) - public_suffix (4.0.6) - rb-fsevent (0.11.1) - rb-inotify (0.10.1) + public_suffix (5.0.5) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) ffi (~> 1.0) - rexml (3.2.5) - rouge (3.28.0) + rexml (3.2.8) + strscan (>= 3.0.9) + rouge (4.2.1) rubyzip (2.3.2) safe_yaml (1.0.5) - sassc (2.4.0) - ffi (~> 1.9) - terminal-table (2.0.0) - unicode-display_width (~> 1.1, >= 1.1.1) - unicode-display_width (1.8.0) + sass-embedded (1.77.4-arm64-darwin) + google-protobuf (>= 3.25, < 5.0) + strscan (3.1.0) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + unicode-display_width (2.5.0) + webrick (1.8.1) PLATFORMS - universal-darwin-20 - universal-darwin-21 - x86_64-linux + arm64-darwin-22 DEPENDENCIES jekyll-remote-theme! - jekyll-seo-tag BUNDLED WITH - 2.3.9 + 2.4.13 diff --git a/_includes/resources-inc/footer.html b/_includes/resources-inc/footer.html index baa24023..8461defe 100644 --- a/_includes/resources-inc/footer.html +++ b/_includes/resources-inc/footer.html @@ -3,9 +3,20 @@ {%- if page.script.first -%} {%- for js in page.script -%} - + {%- endfor -%} {%- elsif page.script -%} - + {%- endif -%} -{% if site.analytics.adobe %}{% include /providers/adobefooter.html %}{% endif %} \ No newline at end of file +{% if site.analytics.adobe %}{% include /providers/adobefooter.html %}{% endif %} + \ No newline at end of file diff --git a/_includes/resources-inc/head.html b/_includes/resources-inc/head.html new file mode 100644 index 00000000..dbb48fb9 --- /dev/null +++ b/_includes/resources-inc/head.html @@ -0,0 +1,17 @@ + + + +{%- if page.css.first -%} + {%- for sheet in page.css -%} + {%- if sheet.first -%} + + {%- elsif sheet -%} + + {%- endif -%} + {%- endfor -%} +{%- elsif page.css -%} + +{%- endif -%} + \ No newline at end of file diff --git a/_layouts/core.html b/_layouts/core.html index 733eb196..2b906573 100644 --- a/_layouts/core.html +++ b/_layouts/core.html @@ -8,16 +8,16 @@ {%- endcapture -%} - - + + {% include license.html %} -{{ page-title }} | {{ site.title[ page.language ] }} - + {{ page-title }} | {{ site.title[ page.language ] }} + {% include metadata.html %} {% include resources-inc/head.html %} {% include analytics.html %} - - + + {%- if page.archived -%} {% include headers-includes/archive.html %} {%- endif -%} @@ -26,5 +26,5 @@ {{ content }} {% include footers/footer.html %} {% include resources-inc/footer.html %} - + \ No newline at end of file diff --git a/cypress.json b/cypress.json new file mode 100644 index 00000000..2c8313bf --- /dev/null +++ b/cypress.json @@ -0,0 +1,4 @@ +{ + "baseUrl": "http://localhost:4000", + "watchForFileChanges": false +} \ No newline at end of file diff --git a/cypress/integration/cms_spec.js b/cypress/integration/cms_spec.js new file mode 100644 index 00000000..25e4724b --- /dev/null +++ b/cypress/integration/cms_spec.js @@ -0,0 +1,26 @@ +describe('DecapCMS Integration', () => { + it('should load the CMS login page', () => { + cy.visit('/admin'); + cy.contains('Login').should('be.visible'); + }); + + it('should allow a user to log in', () => { + cy.visit('/admin'); + cy.get('input[name="email"]').type('david.elisma@cds-snc.ca'); + cy.get('input[name="password"]').type('your-password'); + cy.get('button[type="submit"]').click(); + cy.contains('Collections').should('be.visible'); + }); + + it('should allow creating a new post', () => { + cy.visit('/admin'); + cy.get('input[name="email"]').type('david.elisma@cds-snc.ca'); + cy.get('input[name="password"]').type('your-password'); + cy.get('button[type="submit"]').click(); + cy.contains('New Post').click(); + cy.get('input[name="title"]').type('My New Post'); + cy.get('textarea[name="body"]').type('This is the content of my new post.'); + cy.contains('Save').click(); + cy.contains('Saved').should('be.visible'); + }); + }); \ No newline at end of file diff --git a/en/admin/config.yml b/en/admin/config.yml new file mode 100644 index 00000000..a46661f5 --- /dev/null +++ b/en/admin/config.yml @@ -0,0 +1,33 @@ +backend: + name: git-gateway + branch: content # Branch to update (optional; defaults to master) +# This line should *not* be indented +media_folder: "en/images/thumbs" # Media files will be stored in the repo under images/uploads +public_folder: "/en/images/thumbs" + +collections: + - name: "blog" # Used in routes, e.g., /admin/collections/blog + label: "Blog" # Used in the UI + folder: "en/_posts" # The path to the folder where the documents are stored + create: true # Allow users to create new documents in this collection + slug: "{{year}}/{{month}}/{{day}}/{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md + identifier_field: slug + fields: # The fields for each document, usually in front matter + - { label: "Alternate language page url", name: "altLangPage", widget: "string" } + - { label: "Title", name: "title", widget: "string" } + - { label: "Publish Date", name: "date", widget: "datetime" } + - { label: "Description", name: "description", widget: "string" } + - { label: "Thumbnail image", name: "thumbnail", widget: "image" } + - { label: "Body", name: "body", widget: "markdown" } + - name: "pages" + label: "Pages" + folder: "pages" + create: true + slug: "{{slug}}" + fields: + - { label: "Layout", name: "layout", widget: "string" } + - { label: "Body", name: "body", widget: "markdown" } + +logo_url: https://wet-boew.github.io/themes-dist/GCWeb/GCWeb/assets/sig-blk-en.svg +publish_mode: editorial_workflow +site_url: https://blog.canada.ca \ No newline at end of file diff --git a/en/admin/index.html b/en/admin/index.html new file mode 100644 index 00000000..171620a9 --- /dev/null +++ b/en/admin/index.html @@ -0,0 +1,14 @@ + + + + + + + Canada.ca Design System Content Manager + + + + + + + \ No newline at end of file diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 00000000..a87d0645 --- /dev/null +++ b/netlify.toml @@ -0,0 +1,4 @@ +[[redirects]] + from = "/admin" + to = "/admin/" + status = 200 \ No newline at end of file