Compare commits
No commits in common. "1ae89f63d067e703eb39c9b0790772c3d08fcd54" and "75060070b999cf103abdf2b1dd9b3a1354494661" have entirely different histories.
1ae89f63d0
...
75060070b9
@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
# 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
|
|
4
Makefile
4
Makefile
@ -49,10 +49,8 @@ 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 ' '
|
||||||
|
|
||||||
css:
|
html:
|
||||||
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:
|
||||||
|
@ -44,7 +44,6 @@ PLUGINS = [
|
|||||||
"tag_cloud",
|
"tag_cloud",
|
||||||
"pdf-img",
|
"pdf-img",
|
||||||
"big-button",
|
"big-button",
|
||||||
"source-link",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
ALWAYS_MODIFIED = True
|
ALWAYS_MODIFIED = True
|
||||||
@ -91,7 +90,3 @@ 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"
|
|
||||||
|
@ -5,18 +5,16 @@ 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)
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
# 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.
|
|
@ -1 +0,0 @@
|
|||||||
from .source_link import *
|
|
@ -1,37 +0,0 @@
|
|||||||
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)
|
|
@ -350,33 +350,6 @@ main {
|
|||||||
padding-top: 1em;
|
padding-top: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.source {
|
|
||||||
text-align: center;
|
|
||||||
padding-top: 1em;
|
|
||||||
img {
|
|
||||||
border: 0;
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
background-color: @tag-bg;
|
|
||||||
padding: .2em .6em .2em;
|
|
||||||
font-size: .74em;
|
|
||||||
line-height: 1;
|
|
||||||
color: @tag-text-color;
|
|
||||||
text-align: center;
|
|
||||||
white-space: nowrap;
|
|
||||||
vertical-align: baseline;
|
|
||||||
border-radius: .25em;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
|
||||||
background-color: @tag-hover-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.tag-cloud {
|
.tag-cloud {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
a {
|
a {
|
||||||
|
2
theme/static/stylesheet/style.min.css
vendored
2
theme/static/stylesheet/style.min.css
vendored
File diff suppressed because one or more lines are too long
@ -48,16 +48,6 @@
|
|||||||
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 %}
|
||||||
|
Loading…
Reference in New Issue
Block a user