Giter Club home page Giter Club logo

mischback.de's People

Contributors

dependabot[bot] avatar mischback avatar

Watchers

 avatar  avatar

mischback.de's Issues

Provide (custom) icons

Icons should be applied as eye candy to content boxes, navigation, etc.

To maintain scalability, the icons should be provided as SVGs. They may be created using Inkscape, but will require (manual) optimization.

  • Create Icons
    • Meta (articles, aside box)
    • Quote (articles, aside box (tubhrq))
    • Also in this series (articles, aside box)
      • some sort of bookshelf or something reminding a library
    • Tags (articles, aside box; main body of tags documents)
    • Development (main body of documents in this category)
    • Miscellaneous (main body of documents in this category)
    • Keyboard (main body of documents in this category; higher priority than misc) Not required without dynamic icons
    • /now (top navigation)
  • provide the means to include and style these icons
    • Preferred Approach
      • Async loading of a dedicated icon file (icons.svg) containing the icons as SVG symbols and inlining them using JavaScript not required, as use can be applied to an external resource from the DOM; NOT POSSIBLE from within the CSS!
      • Using JS (Progressive Enhancement) to inject the icons into the DOM (SVG use) NOT REQUIRED, see below
      • Just insert the icons at the required positions, using SVG use in combination with Sphinx's pathto() function
        • still requires some logic, but the "dynamic" icons are known at build time, so the icon can be finally determined. Skip dynamic icons for now.
        • set appropriate ARIA roles, so that the elements are marked as purely visual styling and are not considered for screen readers
        • don't have to meet the contrast requirements!
      • have the actual styling already included in the overall style.css

CSS Validation

  • html5validator can also be used to check CSS files
  • does this work for minimized files?

Blog-style *tags* for ``Sphinx``

The content will be ordered using big categories, like Development, Knives, Misc. For additional ordering / more specific sorting, blog-style tags may be used.

There is a corresponding question on SO; the highest rated answer mentions Sphinx's built-in index directive.

Sphinx's documentation has a guide on developing a recipe extension which also incorporates a custom index. This may be a really great resource, if the built-in index is not sufficient out of the box.

Internal Analysis Robot

Idea

Have the (generated) website placed in a container (e.g. Docker) and let it be analyzed by a robot / spider.

Check every document and track the following information:

  • internal links incoming (must be derived from analyzing other documents!)
  • internal links outgoing (tracked by document, including counts, disregarding #targets)
  • external links outgoing (tracked by URI, including counts, disregarding #targets)

Implementation in Python, most-likely multithreaded with a configurable number of worker threads beside the main management thread.

Make ``content_tags`` a standalone extension

Original Implementation #14 / #18

Additional Issues

Just collecting this here, will be converted into actual issues when moving to dedicated repository.

  • provide required templates from within the extension
    • might require manipulation of Sphinx's template search path
  • ensure compatibility with existing themes
  • display tags in sidebar (??)
  • move KeyError handling to CTTag.rm_doc() (L291)

Create the Colorscheme

  • Readability is the primary factor
    • high contrast values (foreground/background; minimum is AA)
    • generally greyscale with popping contrast colors
    • outstanding color for hyperlinks in the text body
  • use rgb() / rgba() instead of #rrggbb

Deployment

Things to consider for the deployment (might be relevant for the webserver configuration)

  • Use .build/404/index.html as custom 404 handler
  • map /favicon.ico to the actual location in _static/icons/

Webfont Improvements

This is a follow up to #30.

Pareto 20%

Related / Follow up

  • #34 for further technical optimization.

Build the custom theme

  • #23
  • #27
  • #30
  • Sphinx exposes docutils admonitions. As of now, the usage of note and important may be assumed. Additionally I want to provide a tldr admonition for short summaries.
  • Breadcrumbs
    • should look like /home/[CATEGORY]
    • Implemented as theme option (ea6aa0d), not included in styling (as of now)
    • certainly not useful at the top of the content, as this is directly below the actual navigation
    • might be useful at the bottom of the content!
    • included (basic) styling (ab75812)
    • the styling needs more attention:
      • clearer distinction between the (clickable) links and the (automatically inserted) path separators
      • keep it unobstrusive (is this even a word?)
      • add some nerdyness, e.g. using a ::before element to insert $ pwd --> moved to #122
  • #36
  • #49
  • #31
  • #41
  • #28
  • #42
  • Permalinks in/to headlines
    • Do we really want this?
    • Change symbol to #
    • low contrast to background, but visible (A rating? --> #28)
    • This should be directly controllable from Sphinx's configuration...
  • Favicon
    • completed for SVG-based favicon, provided with <link rel= ... in the layout's <head>
    • Is an .ico really required for a 2024 project with a rather moder audience?
  • HTML <title> must be set to an actual title, depending on the document
  • Inline Code Highlighting: Is this required somewhere?! --> moved to #122
  • create the build pipeline for JavaScripts --> included in #54
  • cache-busting of static assets --> included in #54

Choose a SSG

Choose a Static Site Generator

Prerequisites

  • use a Static Site Generator
  • prefer Python-based SSGs but don't rule out anything
  • Content may be split into categories, e.g.
    • development for everything related to IT: programming, administration, projects, ...
    • there may be more categories, but as of now it is questionable, if they should be a dedicated category
    • miscellaneous for everything that does not fit clearly into one of the other categories

Assumptions

  • primarily text-based content
  • mostly in English without need for a l10n engine
  • certain pages in German (without need for a l10n engine)
  • a minimal set of pages in English and German (probably candidates for a l10n engine, but may aswell be provided as dedicated documents)
  • this is not a blog, so content doesn't need to be sorted / sortable by date
  • webserver is available (Nginx, full HTTPS-compliant)

Functional Requirements

  • [MUST] use rst or md source files without limiting authoring
  • [SHOULD] clearly readable / easily consumable content
  • [SHOULD] high contrast values
  • [MUST] works on different screen sizes / resolutions (smartphone to desktop)
  • [MUST] usable with mouse, (keyboard) and finger (touch)
  • [CAN] optimized images per viewport resolution
  • [SHOULD] technically optimized static assets (minimized, compressed)
  • [SHOULD] include a whiff of geekiness into the visual design
  • [MUST] use HTML5 semantic markup
  • [SHOULD] Javascript is only used for eye candy applications and the website is usable without JS (progressive enhancement)
  • [MUST] no external JS dependencies (e.g. no jQuery)
  • [MUST] host all static assets on the server (no CDN assets)
  • [MUST] presentation is realized with CSS
  • [SHOULD] CSS is generated from SASS/SCSS
  • [MUST] visual design does not depend on images/graphics (pure CSS)
  • [MUST] have everything under version control
  • [SHOULD] build time does not really matter, but publishing should not take more than one command
  • [CAN] Deployment from CI

DSGVO-compatible server configuration

This will still need more research!

Ok, so the DSGVO / GDPR considers even the users' IP address personal data, which means, that storing and processing this data is regulated (strictly).

On the other hand, protecting my own server, e.g. fail2ban, works by analyzing the log files and requires the real IP addresses to work properly.

Resources

Related

Keychron V4

Little overview article regarding my Keychron V4, including the performed hardware mods.

Meta

  • How are the keyboard-related articles organized?
    • /misc/keyboards/... ?
    • /misc/keyboards/qmk/...

Custom Extension: Spotlight

The category overview pages should provide a spotlight, a box with images linking to selected articles.

Functional Requirements

  • selection of spotlights from within the category's index.rst document
    • in file's meta fields
    • in file's body
  • requires:
    • image source file
    • caption / title
    • link target document
  • image source file must be included in the build
    • added to the document's dependencies
    • marked to be copied to .build
    • tbc

Dependencies

Create the Readme

  • give executive summary
  • lots of badges
  • licensing
    • source: MIT
    • content: tbd, some CC with attribution?

Update SCSS pipeline

As of now, the project uses python-libsass, but libsass is considered deprecated and will not longer receive updates.

Actually I encountered a bug during theme development: while using rgba(0, 0, 0, 0.95), python-libsass generates "black", which is - obviously - wrong. A manual test with dart-sass is successful.

Implementation Idea

Move project-specific extensions into a dedicated directory / package

Currently, Sphinx's configuration file conf.py acts like one of the project's extensions.

While this works reasonably well for small use-cases (see #5), it is not the desired result.

To Do:

Sphinx's most basic tutorial places the (custom) extension in a folder _ext in the source directory.

From my understanding, the _ext directory may be placed anywhere. It has to be added to Python's PATH. See the section on extending sys.path.

Namespacing might be an issue, so make sure that the project's dedicated extensions don't conflict with other existing extensions (or other packages).

Steps

  • create [REPO_ROOT]/extensions/mischback
  • add [REPO_ROOT]/extensions to Python path
    • in conf.py:
      import sys
      
      # add the project-specific extensions directory to Python's path
      sys.path.append(join(REPO_ROOT, "extensions"))
  • create [REPO_ROOT]/extensions/mischback/sphinx_jinja2_debug.py:
    def activate_jinja2_debug_ext(app):
        """Activate Jinja2 debug extension.
    
        This function is intended to be connected to ``Sphinx``'s
        ``builder-inited`` event (see
        https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx-core-events)
        and will then navigate from the app to the ``jinja.Environment`` and call
        its ``add_extension()`` method.
        """
        if hasattr(app.builder, "templates"):
            app.builder.templates.environment.add_extension("jinja2.ext.debug")
    
    def setup(app):
        """Register the extension with Sphinx.
    
        This function is required by ``Sphinx``'s extension interface, see
        https://www.sphinx-doc.org/en/master/development/tutorials/helloworld.html#writing-the-extension
        for reference.
    
        It connects this plugins (only) function with the ``"builder-inited"`` event, see
        https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx-core-events
        for reference.
        """
        app.connect("builder-inited", activate_jinja2_debug_ext)
  • use the new extension
    • in conf.py:
      extensions = [
          # ...
          "mischback.sphinx_jinja2_debug",
      ]
  • make the extensions setup() function return the (desired) dictionary (see dry-coding here)

Activate ``Jinja2``'s ``debug`` extension

Problem

For theme development it is not strictly required but would be nice to determine, what is placed in the rendering context.

Jinja2 >= 3.0.0 does provide the jinja2.ext.debug extension, which does provide a {% debug %} tag for this purpose.

However, that Jinja2 extension is not activated by Sphinx (which is good and expected).

Possible Solution A

The extension might be activated by calling add_extension("jinja2.ext.debug") on the Jinja Environment object (Reference).

Tracking this object down is not as simple as expected, but probably it can be achieved this way:

# in file conf.py

def activate_jinja2_debug_ext(app):
    """Activate Jinja2 debug extension.

    Prototype of this function is based on 
    https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx-core-events

    FIXME: If this works, make sure to add documentation, using the references
           from the research. Quite a ride through ``sphinx`` source code!
    """
    app.builder.templates.environment.add_extension("jinja2.ext.debug")

def setup(app):
    # Connect a custom handler to the ``builder-inited`` event.
    #
    # https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx-core-events
    app.connect("builder-inited", activate_jinja2_debug_ext)
# sphinx.application
# ``_init_builder()`` suggests, there is an attribute ``builder`` on the ``app`` object
# see ``create_builder()``, which calls ``sphinx.registry.create_builder()``;
# both of these functions return a ``Builder`` instance

# sphinx.builders (in ``create_template_bridge()``)
Builder.templates = BuiltinTemplateLoader() 

# sphinx.jinja2glue
BuiltinTemplateLoader.environment = SandboxedEnvironment()  # this is from jinja2.sandbox

Resources (``sphinx``)

Extensions / Plugins

Guides / Articles

Subsetting of fonts

Fonts are one of the crucial assets of the website.

They have direct impact on the layout / theme (obviously) and the overall usability of the website. Furthermore, search engines reward fast loading times, tiny to none layout shifts, ...

As of now, the project uses three different fonts:

  • Mona Sans (default font for text bodies, sans-serif, variable font)
  • Crimson Pro (serif, just used for quotes)
  • Hack (monospaced, for source code)

All of them do include a rather huge set of glyphs, most likely a lot of them will be completely unused. Subsetting removes glyphs from the font, making the required filesize smaller.

Follow up to #30, related to #55

Requirements

  • include subsetting into the build process
  • remove all un-used features of the fonts
  • determine un-used glyphs automatically
  • output format should be woff2
  • Licensing might be an issue
    • SIL OFL v1.1 prohibits, that derivative works (and subsetting the font might count as that) are distributed under the same name

Font Selection

This issue tracks the initial implementation of fonts.

Pareto 80%

Related / Follow up

  • #55 for improvements of the webfont implementation
  • #34 for further technical optimization

Integrate images into build

While working on #31 one (unresolved) issue was, that the images are not actually part of the repository and thus, can not be considered/checked/processed during CI.

There are some possible solutions:

  1. Integrate the images into the repository
    While this is possible to track binary files with git, it's not desired, as it may lead to a bloated repository, as every updated version of an image would result in an additional blob, effectively doubling the size, making the repo grow
  2. Use git-lfs
    git-lfs stores only references to the binary files in the repository and stores the actual files elsewhere. This is kind of desired, but may require an external git-lfs server, because GitHub has quite strict rules about storage capacity and bandwidth. This external git-lfs server may need massive storage capacity, as it will hold all versions of any binary asset.
  3. Going old school and keeping track of the images manually in an ignored folder.
    This is the current approach. It only requires the images to be available locally. CI can not create a full build of the website!
  4. Manual replication of git-lfs
    Store only references (and possibly hashes) of the files within a JSON file in the repository. During CI, download the files from a (known) source, compare the file hashes and create a full build.

Related

Back to Top button

Articles tend to be quite long, so the primary navigation (in the page's header) is most likely not visible. On the other hand, the user might find that the article is not living up to their expectations, so they want to re-navigate while they are in the middle of the page, so the secondary navigation (in the page's footer) is not (yet) available, either.

Requirements

  • hide button until primary navigation is not visible
  • on mobile devices/single column layout only show the button, when the user swiped up. It is assumed that the button will cover parts of the content, which is not desired. But when the user scrolls up (just a tiny bit), it is assumed that they would like to return to the top, so support them with a button.
  • on desktop devices/two column layout the button may be placed in the area of the aside and can always be visible.
  • icon and text (for accessiblity reasons)
  • styling in the site's style.css
  • required JS is provided as Progressive Enhancement, meaning visitors without activated JS simply get no button, but there is no error either.

Resources

Related articles

The articles should have an aside box providing related articles.

This information should be provided as file-wide meta data. This may require another custom extension.

Requirements

  • specify file path to the related file
  • automatically add a link to that file in the aside box
  • use the target's title as title of the link

Beautify HTML build artifacts

Originally prettier was used to beautify HTML build artifacts. While implementing #7 in #20 this proved to raise several issues.

  • as of now, prettier is used to beautify the HTML after generating it from Sphinx/Jinja2
  • prettier is highly opinionated and is meant to not be configurable (see prettier/prettier#5246)
  • there are alternatives to prettier for the given task, current favourite would be html-tidy, which is available with Python bindings
  • KEEP prettier for formatting SCSS/TypeScript source code during pre-commit

As an alternative to prettier tidy-html5 might be used. It has Python bindings provided by uTidyLib.

Implementation Idea

  • use utidylib's bindings in a Sphinx extension, hooked to the build-finished event

Caveats

  • utidylib does not install the required tidy package / binary / library
  • How can this be done in a (semi automatical) way? I don't know why, but it just works in CI.

Required "legal" content

There are some legal requirements, even for a personal website (sigh)...

Resources (German)

Responsive Image Extension doesn't work for an image included in two different documents

Description

While working on the category overviews, an existing image was included for testing. However, on running Sphinx, only one instance of the image was picked up by the extension, the other got marked as No responsive image sources, creating non-responsive image for ....

Quick Research

The problem might be in ResponsiveImageCollector.collect_source(). The ref_path or the conversion into a Path object results in a non-existing path (below the document's own path).

To reproduce:

  • turn on Sphinx's verbose logging
  • check the extension's logging messages for Responsive image source not found: [PATH]

Stroke text

I want stroke text, which is no part of Sphinx by default!

Related

Resources

  • https://github.com/sphinx-notes/strike
    • this is - more or less - a ready-to-use extension
    • Problem: it uses a <span> element (and the corresponding styling) intead of the (desired) (semantic) elements (<s> / <del>)

Responsive Images

Though I have already created a tool to generate the required image variants to make responsive images work (ImP), this might not be sufficient / desired for this project.

Requirements

  • determine required image sizes
    • 320px
    • 480px
    • 640px
    • 960px
    • 1280px
    • 1600px
    • 1920px
  • integrate in the overall build process (pre-processing, Sphinx processing, post-processing)
  • skip image processing during (local) development
  • determine file formats
    • PNG (-> default and fallback format)
    • WebP(?)
    • Avif(?)
  • control which image sizes / file formats will be generated by using a configuration file (or include this configuration in one of the existing configuration files conf.py or pyproject.toml )
  • rely on libvips / pyvips
  • integrate into the layout
    • Images still should have horizontal margins in mobile layout, see admonitions for reference!

Build pipeline

Create an actual build pipeline:

Stages

  • Staging
    • CSS assets -> included in #126
      • introduce logic for a development build -> included in #126
      • provide the actual cache busting setup -> included in #126
        • compilation of stylesheet from theme/mischback/_src/style/style.scss into theme/mischback/static/style.css
        • run sphinx build to generate the HTML output (in .build); this step will place the stylesheet in .build/_static/style.css
        • run PostCSS against .build/_static/style.css
          • using the HTML output as input for purgecss
          • autoprefixer
          • cssnano
        • run PostHTML to perform the actual cache busting
        • run a custom Python script to perform the actual cache busting --> #126

Dependencies

Reference

  • colorizer, which was one of the sidetracks that significantly impacted building this website, has the additional benefit of having implemented a working cache busting in its v2 branch.
  • Related: #61

Create the overall structural layout

General

  • semantic markup
    • ARIA roles where required
  • responsive layout, without JS, pure HTML/CSS

Layout

  • [Desktop] 2 columns, centered in the page body
    • Header spans both columns and includes the primary navigation
    • Main column contains the actual text body, including images. The width is determined by a maximum readable line length, depending on the font-size, probably specified in rem
    • Aside column contains additional content in boxes. This might be meta information like tags, or totally unrelated stuff (like quotes/tubhrq)
    • Footer spans both columns and includes three columns
      • the primary navigation
      • administrative navigation (required links to privacy document(s), ...)
      • copyright notice
  • [Mobile] On smaller screens, switch to a one column layout
    • Define the required breakpoint for media queries in a central position
    • Include the media queries in the SASS files, where they need to be applied
    • Header includes the primary navigation
      • keep the primary navigation as long as possible, then switch to a burger menu
      • Burger Menu with pure HTML/CSS !!!
    • Main Column contains the actual text body, including images. width will generally be 100%, might add some horizontal margins
      • Admonitions should retain their boxed look
    • Aside column below the main column, width at 100%, but keep the boxes (vertically stacked)
    • Footer, columns will now be rows

Templates

  • Article
  • Indexes
  • Tag Index
  • Tag (detail)

System Font Stacks

Font selection was a real issue while coming up with a design, and finally three major fonts were selected and are - as of now - provided as web fonts.

Everything is working fine, but...

  • fonts add around 250kb to the website's weight
  • they add build complexity (if/when further optimisation is applied, see #34)
  • external dependencies mean possible licensing issues (this should have been covered during selection already, but license terms might change and have to be watched; see #30)
  • Flash of invisible Text (FOIT) / Flash of unstyled Text (FOUT) will happen!

As an alternative, system font stacks may be used. The major drawback is loosing some control of the actual design, as the available fonts may deviate heavily between different users/devices.

ToDo

  • select visually fitting font-stacks
    • great starting point: https://github.com/system-fonts/modern-font-stacks
      • Neo Grotesque for Mona Lisa
        • checked on Windows / Edge:
          • basically a drop in replacement, no adjustments required!
        • checked on Windows / Chrome
        • checked on Ubuntu / Firefox
        • checked on Ubuntu / Chromium
        • checked on Android / Chrome
      • Slab Seric for Crimson Pro
        • checked on Windows / Edge
          • too heavy, too big -> adjustments required!
        • checked on Windows / Chrome
        • checked on Ubuntu / Firefox
        • checked on Ubuntu / Chromium
        • checked on Android / Chrome
      • Old Style for Crimson Pro
        • checked on Windows / Edge
          • slightly too big for tubhrq
          • quotation mark in tubhrq is not the desired look
          • admonition titles are ok'ish
        • checked on Windows / Chrome
        • checked on Ubuntu / Firefox
        • checked on Ubuntu / Chromium
        • checked on Android / Chrome

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.