Get data from server for projects details
This commit is contained in:
parent
6123001eb1
commit
42193b8246
2 changed files with 21 additions and 8 deletions
|
@ -1,11 +1,32 @@
|
||||||
|
from collections import namedtuple
|
||||||
from project.common.views import CustomTemplate, MarkdownView
|
from project.common.views import CustomTemplate, MarkdownView
|
||||||
|
|
||||||
|
|
||||||
|
ProjectDetails = namedtuple('ProjectDetails', ['title', 'image'])
|
||||||
|
|
||||||
|
PROJECT_DETAILS = {
|
||||||
|
'hipchat-emoticons-for-all': ProjectDetails('Hipchat Emoticons Plugin', 'https://hipchat-magnolia-cdn.atlassian.com/assets/img/hipchat/hipchat_og_image.jpg'),
|
||||||
|
'attack-on-blocks': ProjectDetails('Attack on Blocks Game', 'https://image.freepik.com/free-vector/space-invaders-game_62147502273.jpg')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class AllView(CustomTemplate):
|
class AllView(CustomTemplate):
|
||||||
template_name = 'projects/all.html'
|
template_name = 'projects/all.html'
|
||||||
|
|
||||||
|
|
||||||
class ProjectView(MarkdownView):
|
class ProjectView(MarkdownView):
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
try:
|
||||||
|
details = PROJECT_DETAILS[kwargs['project']]
|
||||||
|
context['html_title'] = details.title
|
||||||
|
context['page_title'] = details.title
|
||||||
|
context['header_image'] = details.image
|
||||||
|
except:
|
||||||
|
context['html_title'] = kwargs['project']
|
||||||
|
context['page_title'] = kwargs['project']
|
||||||
|
return context
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
self.markdown = 'projects/{0}.md'.format(kwargs['project'])
|
self.markdown = 'projects/{0}.md'.format(kwargs['project'])
|
||||||
return super().dispatch(request, *args, **kwargs)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
|
@ -6,12 +6,4 @@
|
||||||
<div class="container markdown-content">
|
<div class="container markdown-content">
|
||||||
{{ markdown_content | safe }}
|
{{ markdown_content | safe }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
$(window).load(function () {
|
|
||||||
const TITLE = $('.markdown-content h1').text();
|
|
||||||
$('.header h1').text(TITLE);
|
|
||||||
window.updateTitle(TITLE);
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Reference in a new issue