Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SWIFTweb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTweb
Commits
18aabe0f
Commit
18aabe0f
authored
7 years ago
by
Josh Borrow
Browse files
Options
Downloads
Patches
Plain Diff
Sorted our items by date
parent
fbef9f76
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
compiler.py
+4
-0
4 additions, 0 deletions
compiler.py
filters.py
+33
-0
33 additions, 0 deletions
filters.py
templates/pubs.html
+2
-2
2 additions, 2 deletions
templates/pubs.html
templates/talks.html
+2
-2
2 additions, 2 deletions
templates/talks.html
with
41 additions
and
4 deletions
compiler.py
+
4
−
0
View file @
18aabe0f
...
...
@@ -10,6 +10,7 @@ from distutils.dir_util import copy_tree
import
jinja2
import
yaml
from
mdcomp
import
convert_text
import
filters
def
get_from_filesystem
(
template_names
,
template_dir
=
"
.
"
,
data_dir
=
"
../data
"
):
...
...
@@ -20,6 +21,9 @@ def get_from_filesystem(template_names, template_dir=".", data_dir="../data"):
template_loader
=
jinja2
.
FileSystemLoader
(
searchpath
=
template_dir
)
template_env
=
jinja2
.
Environment
(
loader
=
template_loader
)
# We need to register our custom filters.
template_env
.
filters
[
"
sort_cards
"
]
=
filters
.
sort_cards
templates
=
list
(
map
(
template_env
.
get_template
,
template_names
))
data
=
get_associated_data
(
template_names
,
data_dir
)
...
...
This diff is collapsed.
Click to expand it.
filters.py
0 → 100644
+
33
−
0
View file @
18aabe0f
"""
Some simple macros that are used to e.g. sort things within the jinja
templates. For the relevant documentation please see:
http://jinja.pocoo.org/docs/2.9/api/#custom-filters
Created 26-09-2017 by Josh Borrow (joshua.borrow@durham.ac.uk)
"""
import
dateutil.parser
as
dp
def
sort_cards
(
cards
):
"""
Sort the cards by date.
'
cards
'
should have the following structure:
[
{
...
date
:
"
date
"
},
]
A
list
will
be
returned
where
the
cards
are
sorted
by
date
.
"""
dates
=
[
dp
.
parse
(
card
[
"
date
"
])
for
card
in
cards
]
_
,
cards
=
zip
(
*
sorted
(
zip
(
dates
,
cards
)))
# We want the newest to appear first.
return
reversed
(
cards
)
This diff is collapsed.
Click to expand it.
templates/pubs.html
+
2
−
2
View file @
18aabe0f
...
...
@@ -9,7 +9,7 @@
<div
class=
"container"
>
{{ helper.navbar(navbar, link) }}
<div
class=
"cards"
>
{% for card in cards %}
{% for card in cards
|sort_cards
%}
<div
class=
"card"
>
<a
class=
"card-content"
href=
"{{ card.link }}"
>
{% if card.img %}
...
...
@@ -29,4 +29,4 @@
{% endfor %}
</div>
</div>
{% endblock %}
\ No newline at end of file
{% endblock %}
This diff is collapsed.
Click to expand it.
templates/talks.html
+
2
−
2
View file @
18aabe0f
...
...
@@ -6,7 +6,7 @@
<div
class=
"container"
>
{{ helper.navbar(navbar, link) }}
<div
class=
"cards"
>
{% for card in cards %}
{% for card in cards
|sort_cards
%}
<div
class=
"card"
>
<div
class=
"card-content"
>
<div>
...
...
@@ -40,4 +40,4 @@
<div
class=
"bottom-padder"
>
{# we need this to prevent overlapping #}
</div>
{% endblock %}
\ No newline at end of file
{% endblock %}
This diff is collapsed.
Click to expand it.
Josh Borrow
@jborrow
mentioned in issue
#2 (closed)
·
7 years ago
mentioned in issue
#2 (closed)
mentioned in issue #2
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment