13 Commits

17 changed files with 690 additions and 425 deletions

15
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,15 @@
---
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black

View File

@@ -49,8 +49,10 @@ help:
@echo 'Set the RELATIVE variable to 1 to enable relative urls ' @echo 'Set the RELATIVE variable to 1 to enable relative urls '
@echo ' ' @echo ' '
html: css:
lessc $(BASEDIR)/theme/static/stylesheet/style.less $(BASEDIR)/theme/static/stylesheet/style.min.css -x lessc $(BASEDIR)/theme/static/stylesheet/style.less $(BASEDIR)/theme/static/stylesheet/style.min.css -x
html: css
$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS) $(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
clean: clean:

View File

@@ -3,34 +3,35 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import os import os
import sys import sys
sys.path.append(os.curdir) sys.path.append(os.curdir)
from globalconf import * from globalconf import *
AUTHOR = 'Benjamin Bertrand' AUTHOR = "Benjamin Bertrand"
SITENAME = 'OpyTex' SITENAME = "OpyTex"
SITETITLE = 'OpyTex' SITETITLE = "OpyTex"
SITESUBTITLE = "2021-2022" SITESUBTITLE = "2022-2023"
SITEURL = '' SITEURL = ""
CC_LICENSE_COMMERCIAL = True CC_LICENSE_COMMERCIAL = True
CC_LICENSE = True CC_LICENSE = True
PATH = './content' PATH = "./content"
TIMEZONE = 'Europe/Paris' TIMEZONE = "Europe/Paris"
DEFAULT_LANG = 'fr' DEFAULT_LANG = "fr"
# Uncomment following line if you want document-relative URLs when developing # Uncomment following line if you want document-relative URLs when developing
#RELATIVE_URLS = True # RELATIVE_URLS = True
# Files places # Files places
IGNORE_FILES = ['venv', '.git', 'tools'] IGNORE_FILES = ["venv", ".git", "tools"]
# Pages, articles and static # Pages, articles and static
#PAGE_PATHS = ['pages'] # PAGE_PATHS = ['pages']
ARTICLE_PATHS = ['.'] ARTICLE_PATHS = ["."]
STATIC_PATHS = ['.'] STATIC_PATHS = ["."]
INDEX_SAVE_AS = 'blog_index.html' INDEX_SAVE_AS = "blog_index.html"
# #
USE_FOLDER_AS_CATEGORY = False USE_FOLDER_AS_CATEGORY = False
@@ -38,17 +39,19 @@ USE_FOLDER_AS_CATEGORY = False
# Plugins # Plugins
PLUGIN_PATHS = ["plugins"] PLUGIN_PATHS = ["plugins"]
PLUGINS = [ PLUGINS = [
'i18n_subsites', "i18n_subsites",
"always_modified", "always_modified",
"tag_cloud", "tag_cloud",
'pdf-img', "pdf-img",
"big-button",
"source-link",
] ]
ALWAYS_MODIFIED = True ALWAYS_MODIFIED = True
# Mirror source structure # Mirror source structure
PATH_METADATA = '(?P<path_no_ext>.*)\..*' PATH_METADATA = "(?P<path_no_ext>.*)\..*"
ARTICLE_URL = ARTICLE_SAVE_AS = PAGE_URL = PAGE_SAVE_AS = '{path_no_ext}.html' ARTICLE_URL = ARTICLE_SAVE_AS = PAGE_URL = PAGE_SAVE_AS = "{path_no_ext}.html"
# USE_FOLDER_AS_CATEGORY = True # USE_FOLDER_AS_CATEGORY = True
# DEFAULT_CATEGORY = "Autre" # DEFAULT_CATEGORY = "Autre"
@@ -56,7 +59,7 @@ ARTICLE_URL = ARTICLE_SAVE_AS = PAGE_URL = PAGE_SAVE_AS = '{path_no_ext}.html'
# Readers # Readers
READERS = {"html": None} READERS = {"html": None}
# Everythings in french # Everythings in french
JINJA_ENVIRONMENT = {'extensions': ['jinja2.ext.i18n']} JINJA_ENVIRONMENT = {"extensions": ["jinja2.ext.i18n"]}
# Default theme language. # Default theme language.
I18N_TEMPLATES_LANG = "en" I18N_TEMPLATES_LANG = "en"
# Your language. # Your language.
@@ -78,7 +81,7 @@ DISPLAY_PAGES_ON_SIDE = False
TOCTREE = True TOCTREE = True
TAG_CLOUD = True TAG_CLOUD = True
#SITELOGO = "" # SITELOGO = ""
LINKS = () LINKS = ()
DEFAULT_PAGINATION = 10 DEFAULT_PAGINATION = 10
@@ -88,3 +91,7 @@ CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None AUTHOR_FEED_RSS = None
# SOURCE LINK
GIT_SOURCE_BASE_URL = "https://git.opytex.org/lafrite/2022-2023/src/branch/main"
SOURCE_ICON_URL = "https://git.opytex.org/assets/img/logo.svg"

View File

@@ -5,16 +5,18 @@ If "modified" date/time is not defined in article metadata, fall back to the "cr
from pelican import signals from pelican import signals
from pelican.contents import Content, Article from pelican.contents import Content, Article
def add_modified(content): def add_modified(content):
if not isinstance(content, Article): if not isinstance(content, Article):
return return
if not content.settings.get('ALWAYS_MODIFIED', False): if not content.settings.get("ALWAYS_MODIFIED", False):
return return
if hasattr(content, 'date') and not hasattr(content, 'modified'): if hasattr(content, "date") and not hasattr(content, "modified"):
content.modified = content.date content.modified = content.date
content.locale_modified = content.locale_date content.locale_modified = content.locale_date
def register(): def register():
signals.content_object_init.connect(add_modified) signals.content_object_init.connect(add_modified)

View File

View File

@@ -0,0 +1 @@
from .big_button import *

View File

@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*-
"""
big_button tags for reStructuredText
==============================
This plugin allows you to use big_button tags from within reST documents.
.. big_button::
:title: Title
:link: ""
:color: default
Description
"""
from __future__ import unicode_literals
from docutils import nodes
from docutils.parsers.rst import directives, Directive
class BigButton(Directive):
optional_arguments = 0
final_argument_whitespace = True
has_content = True
required_arguments = 0
optional_arguments = 0
final_argument_whitespace = False
option_spec = {
"title": directives.unicode_code,
"link": directives.path,
}
def settings(self):
self.options['content'] = '\n'.join(self.content)
if not self.options.get('title'):
self.options['title'] = 0
if not self.options.get('link'):
self.options['link'] = 0
def html(self):
html = "<div class='button'>\n"
if self.options["link"]:
html += f"<a href={self.options['link']}>"
else:
html += f"<div class='nolink'>"
if self.options["title"]:
html += f"<h3> {self.options['title']}</h3>"
if self.content:
html += "<div class='content'>"
html += f"{self.options['content']}"
html += "</div>"
if self.options["link"]:
html += "</a>"
else:
html += "</div>"
html += "</div>"
return html
def run(self):
self.settings()
return [nodes.raw('', self.html(), format='html')]
def register():
directives.register_directive("big_button", BigButton)

View File

@@ -0,0 +1,31 @@
# Pelican source link plugin
This plugin for [Pelican](https://github.com/getpelican/pelican/) generate two attributes for articles:
- `source_link`: link to the source of the article from your forge
- `path_source_link`: link to the path of the article from your forge
## Installation
Then, add the plugin to your pelicanconf.py file:
```python
PLUGINS = [
# other plugins...
"source_link",
]
```
## Usage
To use the plugin, define a constant named `GIT_SOURCE` in your pelicanconf.py file:
```python
GIT_SOURCE_BASE_URLL = "https://github.com/your-username/your-repo"
```
This constant should contain the base URL of your Git repository where your source code is stored.
Once the constant is defined, the plugin will generate a `source_link` and a `path_source_link` attributes for each article in your Pelican project.
Those links are generated based on the article's source path relative to the root directory of your Pelican project. If the constant PATH is defined in pelicanconf.py, the plugin will use this value as the root directory. Otherwise, it will use the default value of "", which assumes that your Pelican project is located in the same directory as your pelicanconf.py file.

View File

@@ -0,0 +1 @@
from .source_link import *

View File

@@ -0,0 +1,37 @@
from pelican import signals
import logging
import os
logger = logging.getLogger(__name__)
from pelican.settings import DEFAULT_CONFIG
def set_default_settings(settings):
settings.setdefault("GIT_SOURCE_BASE_URL", None)
def init_default_config(pelican):
set_default_settings(DEFAULT_CONFIG)
if pelican:
set_default_settings(pelican.settings)
def source_link_generator(article_generator):
git_source = article_generator.settings.get(
"GIT_SOURCE_BASE_URL", DEFAULT_CONFIG["GIT_SOURCE_BASE_URL"]
)
root_path = article_generator.settings.get("PATH", DEFAULT_CONFIG.get("PATH", ""))
for article in article_generator.articles:
article_path = os.path.abspath(os.path.join(root_path, article.source_path))
relative_path = os.path.relpath(article_path, root_path)
if git_source.endswith("/"):
article.source_link = f"{git_source}{relative_path}"
else:
article.source_link = f"{git_source}/{relative_path}"
article.path_source_link = "/".join(article.source_link.split("/")[:-1])
def register():
signals.initialized.connect(init_default_config)
signals.article_generator_finalized.connect(source_link_generator)

View File

@@ -11,7 +11,7 @@ sys.path.append(os.curdir)
from pelicanconf import * from pelicanconf import *
# If your site is available via HTTPS, make sure SITEURL begins with https:// # If your site is available via HTTPS, make sure SITEURL begins with https://
SITEURL = 'https://opytex.org/enseignements/2021-2022/' SITEURL = 'https://opytex.org/enseignements/2022-2023/'
RELATIVE_URLS = False RELATIVE_URLS = False
FEED_ALL_ATOM = 'feeds/all.atom.xml' FEED_ALL_ATOM = 'feeds/all.atom.xml'

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -4,6 +4,7 @@
@white: #ffffff; @white: #ffffff;
@grey: #333333; @grey: #333333;
@light-grey: #eeeeee; @light-grey: #eeeeee;
@med-light-grey: #d9d8d8;
@med-grey: #999999; @med-grey: #999999;
@dark-grey: #242121; @dark-grey: #242121;
@@ -20,7 +21,7 @@
@link-hover-color: @light-orange; @link-hover-color: @light-orange;
// Sidebar (aside) // Sidebar (aside)
@sidebar-bg: @grey; @sidebar-bg: @dark-grey;
@sidebar-text-color: @white; @sidebar-text-color: @white;
@sidebar-link-color: @white; @sidebar-link-color: @white;
@sidebar-link-hover-color: @light-grey; @sidebar-link-hover-color: @light-grey;
@@ -28,8 +29,10 @@
// NavBar // NavBar
@navbar-bg: @dark-grey; @navbar-bg: @dark-grey;
@navbar-text-color: @white; @navbar-text-color: @white;
@navbar-toctree-l1-sel-bg: @dark-grey;
@navbar-toctree-l1-sel-txt: @light-grey; @navbar-toctree-l1-sel-bg: @med-light-grey;
@navbar-toctree-l1-sel-txt: @grey;
@navbar-toctree-l2-bg: @med-grey; @navbar-toctree-l2-bg: @med-grey;
@navbar-toctree-l2-txt: @grey; @navbar-toctree-l2-txt: @grey;
@navbar-toctree-l2-sel-bg: @light-grey; @navbar-toctree-l2-sel-bg: @light-grey;

View File

@@ -48,6 +48,16 @@
mod=article.locale_modified, mod=article.locale_modified,
category='<a href="%s/%s">%s</a>'|format(SITEURL, article.category.url, article.category)|safe) }} category='<a href="%s/%s">%s</a>'|format(SITEURL, article.category.url, article.category)|safe) }}
</div> </div>
{% if 'GIT_SOURCE_BASE_URL' %}
<div class="source">
<a href="{{ article.path_source_link}}">
<img src={{ SOURCE_ICON_URL }} alt="source icon" ario>
source et documents
</a>
</div>
{% endif %}
<div class="tag-cloud"> <div class="tag-cloud">
<p> <p>
{% if 'post_stats' in PLUGINS %} {% if 'post_stats' in PLUGINS %}

View File

@@ -86,6 +86,9 @@
</div> </div>
<nav> <nav>
<label for="toggle"></label>
<input type="checkbox" id="toggle">
{% if TOCTREE %} {% if TOCTREE %}
{% include "partial/toctree.html" %} {% include "partial/toctree.html" %}
{% endif %} {% endif %}

View File

@@ -1,4 +1,5 @@
<ul class="toctree"> <ul class="toctree">
<h2>Niveaux</h2>
{% for cat, articles in categories|sort %} {% for cat, articles in categories|sort %}
{% if (article and article.category == cat) or category == cat %} {% if (article and article.category == cat) or category == cat %}
<li class="toctree-l1 current"><a href="{{ SITEURL }}/{{ cat.url }}">{{ cat | upper }}</a> <li class="toctree-l1 current"><a href="{{ SITEURL }}/{{ cat.url }}">{{ cat | upper }}</a>