Skip to content

Commit

Permalink
Merge pull request #2 from shazz/other
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
shazz authored Aug 18, 2024
2 parents 0678109 + 8e1f9e5 commit 6bc963f
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 6 deletions.
1 change: 1 addition & 0 deletions pelican-plugins/series/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .series import *
72 changes: 72 additions & 0 deletions pelican-plugins/series/series.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# -*- coding: utf-8 -*-
"""
This plugin extends the original series plugin
by FELD Boris <[email protected]>
Copyright (c) Leonardo Giordani <[email protected]>
Joins articles in a series and provides variables to
manage the series in the template.
"""

from collections import defaultdict
from operator import itemgetter

from pelican import signals


def aggregate_series(generator):
series = defaultdict(list)

# This cycles through all articles in the given generator
# and collects the 'series' metadata, if present.
# The 'series_index' metadata is also stored, if specified
for article in generator.articles:
if 'series' in article.metadata:
article_entry = (
article.metadata.get('series_index', None),
article.metadata['date'],
article
)

series[article.metadata['series']].append(article_entry)

# This uses items() which on Python2 is not a generator
# but we are dealing with a small amount of data so
# there shouldn't be performance issues =)
for series_name, series_articles in series.items():
# This is not DRY but very simple to understand
forced_order_articles = [
art_tup for art_tup in series_articles if art_tup[0] is not None]

date_order_articles = [
art_tup for art_tup in series_articles if art_tup[0] is None]

forced_order_articles.sort(key=itemgetter(0))
date_order_articles.sort(key=itemgetter(1))

all_articles = forced_order_articles + date_order_articles
ordered_articles = [art_tup[2] for art_tup in all_articles]
enumerated_articles = enumerate(ordered_articles)

for index, article in enumerated_articles:
article.series = dict()
article.series['name'] = series_name
article.series['index'] = index + 1
article.series['all'] = ordered_articles
article.series['all_previous'] = ordered_articles[0: index]
article.series['all_next'] = ordered_articles[index + 1:]

if index > 0:
article.series['previous'] = ordered_articles[index - 1]
else:
article.series['previous'] = None

try:
article.series['next'] = ordered_articles[index + 1]
except IndexError:
article.series['next'] = None


def register():
signals.article_generator_finalized.connect(aggregate_series)
Binary file added themes/pelican-chunk/static/back3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions themes/pelican-chunk/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ body {
background-image: -moz-linear-gradient( rgba(0,0,0,0.22), rgba(255,255,255,0) 80px );
background-image: -webkit-linear-gradient( rgba(0,0,0,0.22), rgba(255,255,255,0) 80px );
color: #555;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 13px;
font-family: 'Lato', 'DM Serif Text', 'Courier New', Courier, monospace
font-size: 16px;
margin: 0;
text-align: center;
}
Expand Down Expand Up @@ -818,4 +818,4 @@ article.comment {
----------------------------------------------- */
.sharedaddy {
clear: both;
}
}
12 changes: 9 additions & 3 deletions themes/pelican-chunk/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
<link rel="stylesheet" type="text/css" href="{{ SITEURL }}/theme/css/style.css" />
<link rel='stylesheet' id='oswald-css' href='https://fonts.googleapis.com/css?family=Oswald&#038;ver=3.3.2'
type='text/css' media='all' />

<link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
rel="stylesheet" />

<style type="text/css">
body.custom-background {
background-color: #f5f5f5;
background-image: "{{ SITEURL }}/theme/back2.jpg";
background-image: "{{ SITEURL }}/theme/back3.png";
}
</style>
<link rel="alternate" type="application/atom+xml" title="{{ SITENAME }} — Flux Atom"
Expand All @@ -32,9 +38,9 @@
<body class="home blog custom-background {% if SINGLE_AUTHOR %}single-author{% endif %}">
<div id="container">
<div id="header">
<h1 id="site-title"><a href="{{ SITEURL }}">{{ SITENAME }}</a></h1>
<!-- <h1 id="site-title"><a href="{{ SITEURL }}">{{ SITENAME }}</a></h1> -->
{% if SITESUBTITLE %}<h2 id="site-description">{{ SITESUBTITLE }}</h2>{% endif %}
<img src="{{ SITEURL }}/theme/back2.jpg" width="100%">
<img src="{{ SITEURL }}/theme/back3.png" width="100%">
</div><!-- /#banner -->

<div id="menu">
Expand Down

0 comments on commit 6bc963f

Please sign in to comment.