Skip to content

Commit

Permalink
fix paths in base template, allow custom configuration. update README
Browse files Browse the repository at this point in the history
  • Loading branch information
EsGeh authored and EsGeh committed Nov 29, 2019
1 parent 6b1d7f6 commit 33f78f2
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 7 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ After you have compiled the publication to "django", you might want to import it

That's all.

### Configure Project specific Information

- You might want to tweak the CMS pages: log in to the CMS and do it
- You might want to configer organisation information (org. name, logo, ...):

1. edit `res/custom_config/*`
2. $ ./scripts/init.py --skip-db

## Run the Webserver

$ ./scripts/run.py
Expand Down
Empty file added res/custom_config/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions res/custom_config/custom_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


organisation = {
'name' : "ORGANISATION NAME",
'homepage' : "#"
}
32 changes: 32 additions & 0 deletions src/eoa/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from django.conf import settings # import the settings file

from os import environ
from pathlib import Path
import sys
from importlib import import_module
import importlib.util


def load_module( path, module_name ):
spec = importlib.util.spec_from_file_location(
module_name,
path
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(
module
)
return module

def custom_cfg(request):
# return the value you want as a dictionnary.
# The values will be added to the template context
# for all templates:
custom_config = load_module(
Path(environ['RES_DIR']) / "custom_config/custom_config.py",
"custom_config"
)

return {
'organisation': custom_config.organisation
}
3 changes: 2 additions & 1 deletion src/eoa/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
'django.template.context_processors.tz',
'sekizai.context_processors.sekizai',
'django.template.context_processors.static',
'cms.context_processors.cms_settings'
'cms.context_processors.cms_settings',
'eoa.context_processors.custom_cfg'
],
'loaders': [
'django.template.loaders.filesystem.Loader',
Expand Down
12 changes: 6 additions & 6 deletions src/eoa/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1"/>
{% block metatags %}{% endblock metatags %}
{% block hyperimage %}{% endblock hyperimage %}
<link rel="shortcut icon" href="{% static 'assets/images/favicon.png' %}"/>
<link rel="shortcut icon" href="{% static 'favicon.png' %}"/>
<link rel="apple-touch-icon" href="{% static 'assets/images/favicon-apple.png' %}"/>
<link href="{% static '852a3afcc3d6f07ad520.app.css' %}" rel="stylesheet"/>
<link href="{% static 'app.css' %}" rel="stylesheet"/>
{% render_block "css" %}
</head>
<body>
Expand All @@ -23,7 +23,7 @@
<div class="blocklogo container">
<div class="blocklogo__logo">
<a href="{% page_url 'intropage' %}">
<img class="blocklogo__img" src="{% static 'assets/images/mprl_logo_281x165.png' %}" alt="logo" data-object-fit="cover"/>
<img class="blocklogo__img" src="{% static 'assets/images/logo.png' %}" alt="logo" data-object-fit="cover"/>
</a>
</div>
</div>
Expand Down Expand Up @@ -67,13 +67,13 @@
<footer class="footer">
<div class="footer__content">
<div class="footer-menu"><a href="{% page_url 'contact' %}">Contact</a><a href="{% page_url 'imprint' %}">Imprint</a><a class="share" href="#">Share<span>this Page</span></a></div>
<div class="footer-logo"><a href="https://mpiwg-berlin.mpg.de/">
<h2>Max Planck Institute for the History of Science</h2></a></div>
<div class="footer-logo"><a href="{{ organisation.homepage }}">
<h2>{{ organisation.name }}</h2></a></div>
</div>
</footer>
</div>
{% block hyperimagebottom %}{% endblock hyperimagebottom %}
<script type="text/javascript" src="{% static '852a3afcc3d6f07ad520.app.js' %}"></script>
<script type="text/javascript" src="{% static 'app.js' %}"></script>
{% render_block "js" %}
</body>
</html>

0 comments on commit 33f78f2

Please sign in to comment.