Warning, /eic.github.io/_about/howto.md is written in an unsupported language. File is not indexed.
0001 ---
0002 title: How-to
0003 name: howto
0004 layout: default
0005
0006 tables:
0007 table1:
0008 width: 20%
0009 columns: [30%, 70%]
0010 headers: [col1, col2]
0011 rows:
0012 - [ a, b ]
0013 - [ x, y ]
0014 table2:
0015 width: 20%
0016 columns: [50%, 50%]
0017 headers: [col1, col2]
0018 rows:
0019 - [ a,
0020 "this is an example of a very wide column which can potentially span many text rows in the same cell" ]
0021 - [ x,
0022 "two lines
0023 in YAML" ]
0024 ---
0025 {% include layouts/title.md %}
0026
0027 * TOC
0028 {:toc}
0029 <hr/>
0030 #### Overview
0031 The following will be of interest to the collaborators interested in contributing to this
0032 site or involved in its maintenance.
0033
0034 We use GitHub to manage the code for this site. Please take a look at the
0035 {% include navigation/findlink.md name='github_site' tag='GitHub repository' %}
0036 to get an idea of the general organization of the data, layouts and supporing logic.
0037 The idea is to shape the code and content in a way that is easy to navigate
0038 and modify. The following sections explain how this is achieved.
0039 Development of this site involves the following aspects:
0040 * adding and modifying the structured data content
0041 * adding "assets" i.e. documents, images etc - although this needs to be done sparingly: one
0042 needs to keep in mind that there are practical limits on the size of any repository, as well
0043 as hard limits on repositories of sites which are hosted as "GitHub pages"
0044 * interfacing the navigation tools on this site, which for the most part consists
0045 of the top navigation bar and the dropdown menus
0046
0047 <hr/>
0048 #### Navigation Mechanics
0049 ##### The Menu System
0050 Entries in the navigation bar on top are named similar to the folders in this
0051 project, for example the "Software" is associated with the folder "_software" etc.
0052 These folders are treated as "collections" by the Jekyll framework and they need to be declared
0053 in the main configuration file
0054 <a href="https://github.com/eic/eic.github.io/blob/master/_config.yml" target="_blank">_config.yml</a>.
0055 As one can see in
0056 <a href="https://github.com/eic/eic.github.io/blob/master/_includes/layouts/navbar.html" target="_blank">the navigation bar code</a>,
0057 its menu entries are generated automatically based on the content of the file
0058 <a href="https://raw.githubusercontent.com/eic/eic.github.io/master/_data/menus.yml" target="_blank">_data/menus.yml</a>.
0059 The content and order of top entries in the navigation bar as well as content and ordering of all items in all dropdown
0060 menus are defined in that file.
0061
0062 If a menu entry in
0063 <a href="https://raw.githubusercontent.com/eic/eic.github.io/master/_data/menus.yml" target=_blank>_data/menus.yml</a>
0064 is an external link, there is no additional source code (i.e. markdown page content is not necessary).
0065 Examples are easy to spot in the menu definition file
0066 <a href="https://raw.githubusercontent.com/eic/eic.github.io/master/_data/menus.yml" target=_blank>_data/menus.yml</a>.
0067
0068 Menu entry descriptions in *menu.yml* can also have optional attributes:
0069 * **"div"**: to include a divider right above an entry in a dropdown menu the
0070 following line should be added respective section of the _data/menus.yml file: "*div: yes*".
0071 * **"exclude"** - mainly for development purposes; if a section of the menu
0072 needs to be ignored when building the site one can just easily add "*exclude: yes*" to the repective section.
0073 * **"label"**: to insert a label into a dropdown menu. The label won't have any links or page associations, it's just a visual guide.
0074
0075 ##### Front Matter
0076 "Front Matter" is a piece of YAML code (typically short) embedded on the very top of a
0077 Markdown-formatted document which can contain any sort of data, for example variables
0078 used to render the page or define a tag so it can be more easily referenced in this way.
0079 The data in the Front Matter is accessible in a way similar to object attributes.
0080 Importantly, when present the Front Matter serves to inform {% include navigation/findlink.md name='Jekyll' %}
0081 that this particular page needs to be rendered into HTML for inclusion in the site being built. Otherwise
0082 it won't be included in the site. In summary, most of the files used to build the site
0083 are expected to be in the Markdown (MD) format, and **each MD file is to be equipped with the
0084 "front matter" section**, which could look like the excerpt below.
0085 ```yaml
0086 ---
0087 title: My Cool Software
0088 name: my_cool_software
0089 category: mysoftware
0090 layout: default
0091 ---
0092 ```
0093
0094 <hr/>
0095 #### Helper macros
0096 ##### Tables
0097 **All tables on this site have added CSS styling to enhance appearance and readability.**
0098
0099 To define tables within pages one can use built-in Markdown table styling capabilities,
0100 for example this snippet of Markdown code
0101
0102 ```
0103 | Language | Lines of code | Description |
0104 |--------------------------|-------------------------------------|-------------|
0105 | C++ | 101 | Module 1 |
0106 | Python | 37 | Module 2 |
0107 | Ruby | 53 | Parser |
0108 {:.table-bordered}
0109 ```
0110
0111 ...will be rendered as
0112
0113 | Language | Lines of code | Description |
0114 |--------------------------|-------------------------------------|-------------|
0115 | C++ | 101 | Module 1 |
0116 | Python | 37 | Module 2 |
0117 | Ruby | 53 | Parser |
0118 {:.table-bordered}
0119
0120 <br/>
0121 Main disadvantage of this method is difficulty in editing large table cells
0122 (i.e. cells with a large amount of content).
0123 There is also an option to embed HTML directly. Both Markdown and plain HTML
0124 options will work but have limitations for example multiple tables present
0125 on the same page may end up having diferent widths, and column within individual tables
0126 may also have inconsistent column widths. This detracts from the page readability.
0127
0128 For greater control and ease of editing data there is also a macro called
0129 **big_table.md** deployed on this site
0130 which is illustrated in the following example. Assume the following content has been added
0131 to the *front matter* of a page:
0132 ```yaml
0133 tables:
0134 table1:
0135 width: 20%
0136 columns: [30%, 70%]
0137 headers: [col1, col2]
0138 rows:
0139 - [ a, b ]
0140 - [ x, y ]
0141 ```
0142 ...and the source of the page contains:
0143 > {% raw %}
0144 > {% include layouts/big_table.md table=page.tables.table1 %}
0145 > {% endraw %}
0146
0147 This will result in the following content on the page:
0148 {% include layouts/big_table.md table=page.tables.table1 %}
0149 <br/>
0150 Note how the table and column widths are configured in the example above.
0151 More tables can be easily added by putting the content in blocks of the front matter
0152 and then referring to them using the macro, as needed.
0153
0154 Individual cells can contain long strings and/or strings split over multiple lines as
0155 long as these are double-quote delimited in the front matter. Example:
0156 ```yaml
0157 tables:
0158 table2:
0159 width: 20%
0160 columns: [50%, 50%]
0161 headers: [col1, col2]
0162 rows:
0163 - [ a,
0164 "this is an example of a very wide column which can potentially span many text rows in the same cell" ]
0165 "two lines
0166 in YAML" ]
0167 ```
0168 {% include layouts/big_table.md table=page.tables.table2 %}
0169
0170
0171 <br/>
0172 ##### Links
0173 Frequently used **external** links are located in the following registry:
0174 <a href="https://raw.githubusercontent.com/eic/eic.github.io/master/_data/links.yml" target=_blank>_data/links.yml</a>.
0175
0176 They can be easily inserted in pages in a consistent manner by their mneumonic name using
0177 a macro as decribed below. This simplifies handling user-unfriendly links and ensures they
0178 remain the same across the site and makes
0179 it easy to point to a different resource when necessary. For example, this piece of code
0180 > {% raw %}
0181 > {% include navigation/findlink.md name='Jekyll' %}
0182 > {% endraw %}
0183
0184 will result in the link: {% include navigation/findlink.md name='Jekyll' %}. If you would like the displayed
0185 link name to be different, the optional "tag" argument for the macro will do that. Example:
0186 > {% raw %}
0187 > {% include navigation/findlink.md name='github_site' tag='repository' %}
0188 > {% endraw %}
0189
0190 will result in the following link: {% include navigation/findlink.md name='github_site' tag='repository' %}.
0191 Links will automatically open in a new tab. There is a similar macro for use with links to **internal**
0192 pages on the site. Example:
0193 > {% raw %}
0194 > {% include navigation/pagelink.md folder=site.about name='howto' tag='"How-to" page' %}
0195 > {% endraw %}
0196
0197 will result in: {% include navigation/pagelink.md folder=site.about name='howto' tag='"How-to" page' %} (this happens
0198 to point to the page you are reading now).
0199 Primary advantage of this macro is that it allows renaming the source file - while keeping the same "name" attribute
0200 in the Front Matter section the links will still be correct.
0201
0202 ##### Images
0203 Users and developers have complete freedom in how they incorporate images into pages on this site.
0204 In many cases handling images will be facilitated by adding an image to the following registry:
0205 <a href="https://raw.githubusercontent.com/eic/eic.github.io/master/_data/gallery.yml" target=_blank>_data/gallery.yml</a>.
0206 Note that items in *gallery.yml* contains references to paths of images. While any image can reside in any folder it
0207 is recommended to keep the image files under *asset/images* in one of the following four folders:
0208 * site
0209 * software
0210 * support
0211 * tutorials
0212
0213 The *site* folder is used for keeping elements of the site look and feel, the *software* one is used
0214 to keep various software-related diagrams, and the rest are self-explanatory. Once an image is added to
0215 to the appropriate folder and *gallery.yml* one cab use a simple macro to refer to it by its mneumonic
0216 name and automatically add it to pages on this site, as illustrated in the following example. The PNG
0217 file containing the "news banner" image is added to the *site* folder under *assets/images* and this
0218 lines are added to *gallery.yaml*:
0219 ```yaml
0220 - name: news_banner
0221 path: '/assets/images/site/EICUG-SWG-News-Banner.png'
0222 title: 'EICUG SWG News Banner'
0223 type: logo
0224 ```
0225 Then, this line of code included in the page
0226 > {% raw %}
0227 > {% include images/image.md name='news_banner' width='400' %}
0228 > {% endraw %}
0229
0230 ...will produce
0231
0232 {% include images/image.md name='news_banner' width='400' %}
0233
0234 If you are adding a software-related diagram, it should go into the "software" folder and
0235 the *gallery.yml* should reference it accordingly.
0236 This helps to ensure consistency of image links throughout the site and remove
0237 the need to include cumbersome HTML in the page code. It also makes it possible to move
0238 the content across folders if necessary and only make changes to the path in one place.
0239
0240 ##### Documents
0241 Similar to the logic presented above, it is preferable to create references to documents (both internal to the site
0242 but also as references to cloud storage such as Zenodo) in an organized manner. Similar to examples above,
0243 there is a registry of documents on the site:
0244 <a href="https://raw.githubusercontent.com/eic/eic.github.io/master/_data/documents.yml" target=_blank>_data/documents.yml</a>.
0245 It is quite small as the time of writing but is expected to grow. Documents can be referred to their names and links
0246 autogeneraged by using a macro such as one in this example:
0247 {% raw %}
0248 {% include documents/doc.md name='Jung-MCValidation.pdf' %}
0249 {% endraw %}
0250
0251 One of the advantages of this approach is that the source of the document can be relocated within the site
0252 or even uploaded to an external resources while the links in the site code will remain valid provided
0253 corrections are made in just one place: _documents.yml.
0254
0255 <hr/>
0256 #### Managing Data
0257 Jekyll is fairly flexible when it comes to storing and manipulating structured data.
0258 The data component of the site can reside in the "front matter" section of the Markdown-formatted
0259 files or in separate YAML (or JSON, CSV etc) data sources. The front matter approach works well
0260 for small sites. For scalability, it is recommended to rely mostly on dedicated data files (i.e.
0261 files in the "<a href="https://github.com/eic/eic.github.io/tree/master/_data" target="_blank">_data</a>" folder)
0262 and keep the content of the front matter sections of individual MD files to a minimum.
0263
0264 The {% include navigation/findlink.md name='Liquid' %} template language
0265 features a variety of filters that can be applied to the data stored in YAML and other data sources
0266 as well as in the front matter blocks of pages, and decent (not perfect) support for collections,
0267 iterators and flow control constructs.
0268
0269 Information assets on this site (e.g. imaged, PDF files etc) are stored in the aptly named
0270 "<a href="https://github.com/eic/eic.github.io/tree/master/assets/" target="_blank">assets</a>"
0271 folder and its subsiduaries. This convention should be kept going forward.
0272
0273 #### Formatting
0274 We aim to provide a uniform look and feel across the site. To that end, whenever possible
0275 the head (title) of each page is formatted by using the standard include layouts/title.md - please
0276 look a the code for examples of its use. It's renders the page title from the front matter sections.
0277
0278 Headers of sections within a page are currently formatted in Markdown as "header level 4" i.e. prepended
0279 with four hash characters like in **"#### My section header"**. Take a look at the header (Formatting)
0280 of this section to get an idea of how it's rendered.
0281
0282 Blockquotes are used to put emphasis on quoted text. The standard way of doing it in Markdown is to
0283 prepend the lines that need this formatting with the '>' character. For example:
0284 ```
0285 >Blockquote!
0286 ```
0287 ...will produce
0288 >Blockquote!
0289
0290 Language-aware code highlighting capability has been integrated and
0291 can be easily used via the fenced code blocks i.e. blocks delimited by
0292 triple backticks, with an optional shortcut for the programming language name.
0293 For example,
0294
0295
0296
0297 ```bash
0298 export foo="foo"
0299 echo $foo
0300 ls -l .
0301 ```
0302
0303 will be rendered as:
0304 ```bash
0305 export foo="foo"
0306 echo $foo
0307 ls -l .
0308 ```
0309
0310 and
0311
0312 ```python
0313 def my_function():
0314 print("Hello from a function")
0315 ```
0316
0317 will show as:
0318
0319 ```python
0320 def my_function():
0321 print("Hello from a function")
0322 ```
0323
0324
0325 For C++, the opening line should be triple backticks followed by "c++"
0326 similar to examples above and the code will be rendered accordingly such as:
0327
0328 ```c++
0329 class MyClass { // The class
0330 public: // Access specifier
0331 int myNum; // Attribute (int variable)
0332 string myString; // Attribute (string variable)
0333 };
0334 ```
0335
0336 <hr/>
0337 #### Development and Deployment
0338 ##### Ruby and Jekyll
0339 To productively participate in the development of this site one needs to learn the basics of the
0340 {% include navigation/findlink.md name='Jekyll' %} framework and install it on
0341 a development machine. This is relatively straighforward but may depend on the OS specifics.
0342
0343 Once the environment is in place, any modification can be validated immediately since
0344 the locally running development server provided by Jekyll will render the site
0345 on the local host. Basic knowledge of the {% include navigation/findlink.md name='Liquid' %}
0346 template language and in particular the "filters" that are part of it is extremely helpful.
0347
0348 ##### GitHub Pages
0349 As already mentioned, we use GitHub to manage the code for this site. A fork/pull request process is optimal,
0350 but if you prefer direct push for some reason please get in touch with the group. To get access to the code,
0351 create a clone of the website repository and move to the directory created:
0352
0353 ```bash
0354 git clone https://github.com/eic/eic.github.io.git
0355 cd eic.github.io
0356 ```
0357
0358 The repository is configured for ''GitHub Pages''.
0359 This means that once modified contents are committed to the repository and you perform *git push*, the
0360 {% include navigation/findlink.md name='github_pages' tag='GitHub pages system' %} will build the
0361 site and make it publicly available at [https://eic.github.io/](https://eic.github.io/). Errors in the
0362 updated code may result either in failed deployment or a broken instance of the site. For that reason
0363 it is desirable to assess the result of changes before publishing them.
0364 To achieve this, you need to install Jekyll on your local machine, as detailed below.
0365
0366 ##### Jekyll
0367 Instructions can be found on Jekyll [web site](https://jekyllrb.com/docs/installation/) but the short story is:
0368
0369 * Install {% include navigation/findlink.md name='ruby_downloads' tag='Ruby' %} and {% include navigation/findlink.md name='rubygems_downloads' tag='RubyGems' %}
0370 * Install Bundler (a Ruby package manager): `gem install bundler`
0371 * Install/update your Jekyll installation (must be done regularly):
0372 ```bash
0373 bundler update
0374 ```
0375 * Run Jekyll (in the eic.github.io directory):
0376 ```bash
0377 bundler exec jekyll serve
0378 ```
0379
0380 Once Jekyll has been started you can view the web site by connecting to `localhost:4000`.
0381 Changes made to files are immediately compiled and reflected on the
0382 displayed site (at the next page load). The optimal workflow is to make changes and debug
0383 entirely locally before doing a 'git commit' and pushing to GitHub.
0384
0385 Examples of Jekyll commands
0386 ```bash
0387 # Start a new Jekyll project
0388 ## NB. this is a little tricky e.g. you would need to pick a correct
0389 ## Gemfile and perhaps use --force
0390 ## A little experimentation is in order
0391 jekyll new myblog
0392
0393 # Clean stale CSS etc, also run after modifyig _config.yml.
0394 bundle exec jekyll clean
0395 # Serve content while filtering out some annoying warning messages
0396 bundle exec jekyll serve 2>&1 | grep -v ': Using'
0397 ```
0398
0399 If you get this far, you are ready to start modifying the site. A word of caution - please check the output
0400 of the jekyll compiler for error messages. Normally the code compiles and you just reload the page to see
0401 the result, but if there was an error and you are not checking the compiler's windown the behavior of the
0402 page will be puzzling.
0403
0404
0405 [top](#how-to)
0406