Coder Social home page Coder Social logo

tdwg-theme's Introduction

TDWG theme

A Pelican theme for the TDWG website.

Getting started

This theme was developed for the TDWG website. Although it wouldn't make sense to use it as is for any other website, you're welcome to fork and adapt it. tdwg is only used in the theme name: the rest of the naming is neutral. To get started, download the theme and reference its path in your Pelican settings. For example:

THEME = "../tdwg-theme" # If tdwg-theme is in the same directory as your website repo

Dependencies

This theme makes use of the following Pelican plugins:

  • pelican-page-order: to add page_order attribute to pages if one is not defined. Required: throws 'pelican.contents.Page object' has no attribute 'page_order' if not installed.
  • pelican-page-hierarchy: to create URL hierarchy for pages matching directory structure. Required: throws 'pelican.contents.Page object' has no attribute 'parents' if not installed.
  • pelican-toc: to assign ids to headers in pages/articles and render a table of content.
  • pelican-bootstrapify: to add Bootstrap classes to page/article content.
  • pelican-github-edit: to add a link to edit pages/articles on GitHub.
  • pelican-cover-image: to add cover image URL to pages/articles.
  • tipue_search: to enable Javascript site search.
  • summary: to only display non-generated summaries as lead paragraph.

Download these plugins to your plugins directory (like here) and define them in your website settings file (see Pelican documentation):

PLUGINS = [
    "pelican-page-order",
    "pelican-page-hierarchy",
    "pelican-toc",
    "pelican-bootstrapify",
    "pelican-github-edit",
    "pelican-cover-image",
    "tipue_search",
    "summary"
]

Repo structure

The repository structure is that of a Pelican theme. Files/directories indicated with GENERATED should not be edited manually.

├── README.md         : Description of this repository
├── LICENSE           : Project license
├── package.json      : npm package description, contains scripts for development
├── .gitignore        : Files and folders to be ignored by git (including node_modules)
│
├── node_modules      : Modules installed by npm, is gitignored. GENERATED
│
├── src
│   ├── js            : Theme specific Javascript files (look here if you want to adapt the JS)
│   └── scss          : Theme specific SCSS (look here if you want to adapt the CSS)
│
├── static            : All static files for this theme. Similar to a "dist" directory. GENERATED
│
└── templates         : Pelican Jinja templates (look here if you want to adapt the HTML)

Development

Bootstrap

This theme uses Bootstrap v4.0 as a framework to create a responsive website. The HTML is entirely structured around Bootstrap classes for layout, content, components and utilities, with as little deviation as possible. The CSS starts from Bootstrap's SCSS/SASS, with custom variable overwrites in src/scss/_variables.scss and custom CSS in src/scss/main.scss. These get bundled together with Bootstrap in a single static/css/main.css.

Update HTML

The HTML is structured in templates with a Jinja syntax. templates/base.html is the main template: all other templates are build upon it. See the Pelican documentation to understand what each template does.

No npm scripts need to be run to make HTML changes effective (the templates directory is read directly by Pelican).

Update SCSS and/or Javascript

To update the SCSS and/or JS, npm is required. It is used to install all dependencies (such as Bootstrap v4.0) and run development scripts (such as generating the CSS from SCSS).

Installation

  1. Clone this repo: git clone https://github.com/tdwg/tdwg-theme
  2. Verify npm is installed: node -v (tested with 3.10)
  3. Go to the root of this repository
  4. Install all dependencies with: npm install (will read package.json to create the node_modules directory)

Update SCSS

  1. Go to the src/scss
  2. Update the relevant .scss files
  3. Generate the CSS in static/css automatically on every change with npm run watch:css

Update JS

  1. Go to the src/js
  2. Update or add the relevant .js files
  3. Copy the JS to static/js automatically on every change with npm run watch:js

Important: do not touch files in the static directory: those are all generated! Look for the files in src instead. To completely rebuild the static directory, do npm run build:all

Contributors

List of contributors

License

MIT License

tdwg-theme's People

Contributors

dependabot[bot] avatar peterdesmet avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

halmgren

tdwg-theme's Issues

Dropdown disables top link

The website now has a hierarchical navigation in the navbar. It is implemented with bootstrap 4.0 dropdowns (see documentation). It also works on small screens.

However: clicking the top level page now open/closes the dropdown and it is no longer possible to open the page itself (even though it exists, e.g. https://dev.tdwg.org/conferences/). Any of you web developers have a solution for this?

Thoughts:

  1. A hover would be nice, but should disabled on mobile devices as these don't support hover. OKFN has a nice implementation (hover + side menu on small screens).
  2. Bootstrap split button dropdowns might be an option, but I haven't seen it yet in menus and it might be unintuitive.
  3. I'd like an option with minimal deviation from bootstrap.
  4. You could wonder if we need those top level pages, but we do as they provide a nice start page for that section, rather than diving in immediately. Also: the URL structure implies that they exist (one level up).

/cc @MortenHofft

For reference, here's the bootstrap html:

<ul class="navbar-nav mr-auto">
{% for p in pages|sort(attribute="page_order") %}
{% if p.parent == None %} {# Top level pages only #}
{% if p.children %} {# If children, create dropdown #}
<li class="nav-item dropdown{% if p == page %} active{% endif %}">
<a class="nav-link dropdown-toggle" href="{{ SITEURL }}/{{ p.url }}" id="{{ p.url }}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ p.title }}
</a>
<div class="dropdown-menu" aria-labelledby="{{ p.url }}">
{% for child in p.children|sort(attribute="page_order") %}
{% if child.divider == "above" %}
<div class="dropdown-divider"></div>
{% endif %}
<a class="dropdown-item{% if child == page %} active{% endif %}" href="{{ SITEURL }}/{{ child.url}}">{{ child.title }}</a>
{% if child.divider == "below" %}
<div class="dropdown-divider"></div>
{% endif %}
{% endfor %}
</div>
</li>
{% else %}
<li class="nav-item{% if p == page %} active{% endif %}">
<a class="nav-link" href="{{ SITEURL }}/{{ p.url }}">{{ p.title }}</a>
</li>
{% endif %}
{% endif %}
{% endfor %}
</ul>

Assets served over https are blocked by CORS policy

The dev TDWG theme is currently served at https://dev.tdwg.org/theme/css/main.css and can thus be used by satellite websites, like the new beta Darwin Core quick reference guide: http://rawgit.com/tdwg/dwc/master/www/guides/index.html

Although the CSS can be read perfectly by the guide, access to the referenced font-awesome font is blocked by Cross-origin resource sharing policy, I assume because the guide is served over http (here rawgit, but would be the same for a GitHub pages website) and is trying to access a (potentially sensitive) https resource:

Access to Font at 'https://dev.tdwg.org/theme/fonts/font-awesome/fontawesome-webfont.woff2?v=4.7.0' from origin 'http://rawgit.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://rawgit.com' is therefore not allowed access.
Access to Font at 'https://dev.tdwg.org/theme/fonts/font-awesome/fontawesome-webfont.woff?v=4.7.0' from origin 'http://rawgit.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://rawgit.com' is therefore not allowed access.
Access to Font at 'https://dev.tdwg.org/theme/fonts/font-awesome/fontawesome-webfont.ttf?v=4.7.0' from origin 'http://rawgit.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://rawgit.com' is therefore not allowed access.

As a result, font-awesome icons are not rendered. Other than forcing every TDWG satellite website to use https, is there anything that can be done at https://dev.tdwg.org to allow access? @MattBlissett?

Note: eventually the guide will use the production css from https://tdwg.org/theme/css/main.css, but until that is available, the dev css is used. Note, if tdwg.org will be served over https, the same error will pop up again.

Review and implement suggested changes for DwC ref guide

Suggested by @timrobertson100:

One suggestion for consideration is more whitespace preceding the classes to break up the page a bit (e.g. https://dwc.tdwg.org/terms/#event).
I would consider removing the whitespace between the terms, reduce the font size a bit and bring back the vertical border between the label and the value – but that is like the old one.

Old one: https://web.archive.org/web/20090309033514/http:/rs.tdwg.org:80/dwc/terms/index.htm#SamplingEvent

  • More whitespace above h2
  • Remove whitespace between terms: wontfix, is useful to differentiate terms visually
  • Reduce font size
  • Bring back vertical border between label and value
  • Have label be same size
  • Avoid content breaking out of box
  • Use other way of adding property tag (currently annoying when selecting term name)

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.