Static sites: Difference between revisions

From Nasqueron Agora
(Created page with "'''Static sites''' are used in two context at Nasqueron: # '''Information static sites.''' Sites with only static content # '''JavaScript front-end clients.''' Sites with dynamic back-end: the HTML site uses JS to communicate with the back-end through a REST API. == Static site template == We build the first sites from the Foundation CSS framework ZURB template. This approach works well for pure static sites, or for JS clients to query an API like we do in {{repo|infr...")
 
 
(9 intermediate revisions by 2 users not shown)
Line 5: Line 5:


== Static site template ==
== Static site template ==
Static sites are composed from HTML, CSS and JS assets. They can be pure static sites, or clients for dynamic sites with JavaScript code to query an API, like {{repo|infra-www}}.
We build the first sites from the Foundation CSS framework ZURB template.
We build the first sites from the Foundation CSS framework ZURB template.


Line 19: Line 22:
don't use this template.
don't use this template.


=== Create a site in 2023 ===
=== Build mechanism ===
To get the build mechanism right, as of 2023-05-28, take it from
 
the {{repo|join}} and {{repo|infra-www}}:
Currently, the build mechanism and the template are to be extracted from two different places:
 
  +-----------------+      +-------------------------------------+
  | Build mechanism |      | Site assets: SCSS, JS, HTML, data.  |
  |                |      |                                    |
  | [ Gulp ]        |      | [ Foundation + Handlebars ]        |
  +-----------------+      +-------------------------------------+
          ^                                    ^
  +-----------------+      +-------------------------------------+
  | Copy it from an |      | Take the up-to-date last version    |
  | existing site:  |      | from the Foundation Zurb template:  |
  | infra-www repo  |      | foundation/foundation-zurb-template |
  +-----------------+      +-------------------------------------+
 
=== Create a static site manually ===
 
'''Step 1.''' To get the build mechanism right, as of 2023-05-28, take it from
the {{repo|join}} or from the {{repo|infra-www}} repository:
 
    git clone https://devcentral.nasqueron.org/source/infra-www.git your-awesome-site
    cd your-awesome-site
    rm -rf src/ .git Jenkinsfile


    git clone ...
You'll then get a folder with a correct build mechanism.
    cd ...
    rm -rf src/ .git


You'll then get a folder with a correct build mechanism, and can create from
'''Step 2.''' Initialize your own repository:
there your own repository:


     git init .
     git init .
Line 35: Line 56:
     git commit -m "Build a new static site"
     git commit -m "Build a new static site"


Then, copy a fresh <code>src/</code> folder from the [https://github.com/foundation/foundation-zurb-template foundation/foundation-zurb-template] repository.
At that stage, you've a correct build mechanism, configured for your website,
but no template or content.
 
'''Step 3.''' Add the Foundation template:
 
Copy a fresh <code>src/</code> folder from the [https://github.com/foundation/foundation-zurb-template foundation/foundation-zurb-template] repository:
 
    git clone https://github.com/foundation/foundation-zurb-template /tmp/template
    mv /tmp/template/src .
    rm -rf /tmp/template
 
And that's it. You can now work on it and build your site.
 
You should get the following structure:
<pre>
.
├── config.yml
├── gulpfile.babel.js
├── Jenkinsfile
├── package.json
├── readme.md
└── src
    ├── assets
    │   ├── img
    │   ├── js
    │   │   ├── app.js
    │   │   └── lib
    │   │      └── foundation-explicit-pieces.js
    │   └── scss
    │      ├── _settings.scss
    │      ├── app.scss
    │      ├── components
    │      └── global
    │          └── _typography.scss
    ├── data
    ├── layouts
    │   └── default.html
    ├── pages
    │   └── index.html
    ├── partials
    └── styleguide
        ├── index.md
        └── template.html
 
14 directories, 14 files
</pre>


Follow your README instructions to build your site: <code>yarn install</code> then <code>yarn install</code>
'''Enjoy.''' Follow your README instructions to install Node dependencies and build your site:
and you're ready to work on it and build your site :)


=== Upsection ===
    yarn install
We need to maintain dependencies for the Gulp/handlebars site builder
    yarn start
across several repositories. The dependencies are brittle, security issues
will require to upgrade to a version of a package invoked by gulp-<feature>,
but gulp-<feature> will be abandoned and unmaintained. That's the usual
scenario. When it's maintained, the way to load the library in JS has changed.


That hard maintenance problem requires an unified solution, to be able to do it
'''Who to contact for support.''' {{u|Dereckson}} maintains those instructions and this build mechanism.
one for all the sites. '''Upsection''' is the name of this ongoing effort to
maintain, and provide a tool to populate the dependencies and build the site
with a simple `make`. Proof of concept lives in {{repo|upsection}}.


A second advantage is the current repository creation process is a little
'''Note about Jenkins.''' We're currently looking how to switch from the old Jenkins deployment method to the new [[Alkane]] one, so don't commit a Jenkinsfile (excepted if you solve that exact problem of course), we'll figure it as soon as your site is ready to be published.
bit cumbersome, as highlighted by the previous sections instructions to
fetch the build mechanism and the src/ folder in two different sources.


Upsection repository contains our full usable template in ONE place.
=== Upsection ===
''See also [[Upsection]].''


As of 2023-05, Upsection dependencies aren't up-to-date, so you'll need if you use it
Upsection allows to deploy the latest version of the site builder.
to upgrade Node packages to the one used in {{repo|join}} or {{repo|infra-www}}.


== Build Vue.js application ==
== Build Vue.js application ==
Line 67: Line 123:
<code>npm init vue@latest</code>
<code>npm init vue@latest</code>


'''Who to contact for support.''' {{u|Inidal}} maintains those instructions and this build mechanism.
[[Category:Contributor guide]]
[[Category:Reference]]
[[Category:Reference]]

Latest revision as of 00:27, 17 November 2024

Static sites are used in two context at Nasqueron:

  1. Information static sites. Sites with only static content
  2. JavaScript front-end clients. Sites with dynamic back-end: the HTML site uses JS to communicate with the back-end through a REST API.

Static site template

Static sites are composed from HTML, CSS and JS assets. They can be pure static sites, or clients for dynamic sites with JavaScript code to query an API, like infra-www.

We build the first sites from the Foundation CSS framework ZURB template.

This approach works well for pure static sites, or for JS clients to query an API like we do in infra-www.

Your site is composed of two parts:

  • a src/ folder with your site assets (JS, CSS), pages and data
  • a build mechanism driven by Gulp

This is perfect to quickly assemble a site, especially as we can do it on Jenkins for CD.

If you use frameworks like React/Vue and want to make them manage your site routing and structure, don't use this template.

Build mechanism

Currently, the build mechanism and the template are to be extracted from two different places:

  +-----------------+       +-------------------------------------+
  | Build mechanism |       | Site assets: SCSS, JS, HTML, data.  |
  |                 |       |                                     |
  | [ Gulp ]        |       | [ Foundation + Handlebars ]         |
  +-----------------+       +-------------------------------------+
          ^                                     ^
  +-----------------+       +-------------------------------------+
  | Copy it from an |       | Take the up-to-date last version    |
  | existing site:  |       | from the Foundation Zurb template:  |
  | infra-www repo  |       | foundation/foundation-zurb-template |
  +-----------------+       +-------------------------------------+

Create a static site manually

Step 1. To get the build mechanism right, as of 2023-05-28, take it from the join or from the infra-www repository:

   git clone https://devcentral.nasqueron.org/source/infra-www.git your-awesome-site
   cd your-awesome-site
   rm -rf src/ .git Jenkinsfile

You'll then get a folder with a correct build mechanism.

Step 2. Initialize your own repository:

   git init .
   $EDITOR .babelrc .browserslistrc config.yml gulpfile.babel.js package.json readme.md
   git add .
   git commit -m "Build a new static site"

At that stage, you've a correct build mechanism, configured for your website, but no template or content.

Step 3. Add the Foundation template:

Copy a fresh src/ folder from the foundation/foundation-zurb-template repository:

   git clone https://github.com/foundation/foundation-zurb-template /tmp/template
   mv /tmp/template/src .
   rm -rf /tmp/template

And that's it. You can now work on it and build your site.

You should get the following structure:

.
├── config.yml
├── gulpfile.babel.js
├── Jenkinsfile
├── package.json
├── readme.md
└── src
    ├── assets
    │   ├── img
    │   ├── js
    │   │   ├── app.js
    │   │   └── lib
    │   │       └── foundation-explicit-pieces.js
    │   └── scss
    │       ├── _settings.scss
    │       ├── app.scss
    │       ├── components
    │       └── global
    │           └── _typography.scss
    ├── data
    ├── layouts
    │   └── default.html
    ├── pages
    │   └── index.html
    ├── partials
    └── styleguide
        ├── index.md
        └── template.html

14 directories, 14 files

Enjoy. Follow your README instructions to install Node dependencies and build your site:

   yarn install
   yarn start

Who to contact for support. Dereckson maintains those instructions and this build mechanism.

Note about Jenkins. We're currently looking how to switch from the old Jenkins deployment method to the new Alkane one, so don't commit a Jenkinsfile (excepted if you solve that exact problem of course), we'll figure it as soon as your site is ready to be published.

Upsection

See also Upsection.

Upsection allows to deploy the latest version of the site builder.

Build Vue.js application

Nidal uses another strategy for servpulse: Vue.js provides a CLI tool to bootstrap a web site, and Foundation is added afterwards:

npm init vue@latest

Who to contact for support. Inidal maintains those instructions and this build mechanism.