[geany/www.geany.org] 5171e3: Add Geany-Themes page with theme preview

Enrico Tröger git-noreply at xxxxx
Sun Jun 23 09:26:40 UTC 2019


Branch:      refs/heads/issue5_geany_themes_preview
Author:      Enrico Tröger <enrico.troeger at uvena.de>
Committer:   Enrico Tröger <enrico.troeger at uvena.de>
Date:        Sun, 23 Jun 2019 09:26:40 UTC
Commit:      5171e31573551a6f318936474378acd637ca61c7
             https://github.com/geany/www.geany.org/commit/5171e31573551a6f318936474378acd637ca61c7

Log Message:
-----------
Add Geany-Themes page with theme preview

The themes in the preview list are loaded from the Geany-Themes
repository on Github on the fly (but cached for one hour).


Modified Paths:
--------------
    page_content/download/themes.md
    static_docs/github_client.py
    static_docs/templates/pages/download/themes.html
    static_docs/urls.py
    static_docs/views.py

Modified: page_content/download/themes.md
10 lines changed, 10 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,10 @@
+## Geany Themes
+
+Geany-Themes is a collection of color schemes for Geany, either written originally by the Geany community or ported from color schemes for other editors.
+These schemes are compatible with Geany 1.22 and greater.
+
+To use one the themes below, download the configuration file and save it to the folder `colorschemes` in your Geany configuration directory (usually `~/.config/geany/colorschemes/`).
+
+For more information and detailed configuration instructions, see https://github.com/geany/geany-themes.
+
+


Modified: static_docs/github_client.py
8 lines changed, 5 insertions(+), 3 deletions(-)
===================================================================
@@ -30,9 +30,11 @@ class GitHubApiClient:
     """"""
 
     # ----------------------------------------------------------------------
-    def get_file_contents(self, filename):
-        url_parameters = dict(user=GITHUB_USER,
-                              repository=GITHUB_REPOSITORY,
+    def get_file_contents(self, filename, user=None, repository=None):
+        user = user or GITHUB_USER
+        repository = repository or GITHUB_REPOSITORY
+        url_parameters = dict(user=user,
+                              repository=repository,
                               filename=filename)
         url = 'https://api.github.com/repos/%(user)s/%(repository)s/contents/%(filename)s' % \
             url_parameters


Modified: static_docs/templates/pages/download/themes.html
65 lines changed, 65 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,65 @@
+{% extends "pages/richtextpage.html" %}
+
+{% load mezzanine_tags pages_tags static %}
+
+{% block extra_css %}
+<link rel="stylesheet" href="{% static "mezzanine/css/magnific-popup.css" %}">
+<style>
+    .img-thumbnail {
+        cursor: zoom-in;
+    }
+</style>
+{% endblock %}
+
+{% block richtext_content %}
+{{ block.super }}
+
+<h3>Available Themes</h3>
+
+<div class="row">
+
+{% for theme in theme_index.values|dictsort:"name" %}
+    <div class="col-md-4">
+        <div class="panel panel-default">
+            <div class="panel-heading">
+                <strong>{{ theme.name }}</strong>
+                <span class="pull-right"><a href="{{ theme.colorscheme }}">Download</a></span>
+            </div>
+            <div class="panel-body gallery">
+                <a href="{{ theme.screenshot }}" title="{{ theme.name }} - {{ theme.description }}">
+                    <img
+                        src="data:image/png;base64,{{ theme.thumbnail }}"
+                        width="64"
+                        height="64"
+                        class="img-responsive img-thumbnail center-block"
+                        alt="Thumbnail of colorscheme {{ theme.name }}" />
+                </a>
+                <div class="text-center">{{ theme.description }}</div>
+            </div>
+        </div>
+    </div>
+
+    {% if forloop.counter|divisibleby:3 %}
+        </div>
+        <div class="row">
+    {% endif %}
+{% endfor %}
+</div>
+
+{% endblock %}
+
+{% block extra_js %}
+{{ block.super }}
+<script src="{% static "mezzanine/js/magnific-popup.js" %}"></script>
+<script>
+$(document).ready(function() {
+    $('.gallery').magnificPopup({
+        delegate: 'a',
+        type: 'image',
+        gallery: {
+            enabled: true,
+        }
+    });
+});
+</script>
+{% endblock %}


Modified: static_docs/urls.py
4 lines changed, 3 insertions(+), 1 deletions(-)
===================================================================
@@ -14,10 +14,12 @@
 
 from django.conf.urls import url
 
-from static_docs.views import I18NStatisticsView, ReleaseNotesView, ToDoView
+from static_docs.views import I18NStatisticsView, ReleaseNotesView, ThemesView, ToDoView
 
 
 urlpatterns = (  # pylint: disable=invalid-name
+    url(r'^download/themes/$', ThemesView.as_view(), name='themes'),
+
     url(r'^documentation/todo/$', ToDoView.as_view(), name='todo'),
 
     url(r'^documentation/releasenotes/$', ReleaseNotesView.as_view(), name='releasenotes'),


Modified: static_docs/views.py
29 lines changed, 27 insertions(+), 2 deletions(-)
===================================================================
@@ -56,9 +56,9 @@ def __init__(self, *args, **kwargs):
         self._file_contents = None
 
     # ----------------------------------------------------------------------
-    def _fetch_file_via_github_api(self, filename):
+    def _fetch_file_via_github_api(self, filename, user=None, repository=None):
         client = GitHubApiClient()
-        self._file_contents = client.get_file_contents(filename)
+        self._file_contents = client.get_file_contents(filename, user=user, repository=repository)
 
 
 class ReleaseNotesView(StaticDocsView):
@@ -240,3 +240,28 @@ def _get_i18n_statistics(self):
             settings.STATIC_DOCS_GEANY_I18N_STATISTICS_FILENAME)
         with open(filename) as input_file:
             return json.load(input_file)
+
+
+class ThemesView(StaticDocsView):
+    """
+    Fetch the Geany-Themes index from https://github.com/geany/geany-themes/tree/master/index
+    """
+
+    template_name = "pages/download/themes.html"
+
+    # ----------------------------------------------------------------------
+    def get_context_data(self, **kwargs):
+        theme_index = self._get_theme_index()
+        context = super(ThemesView, self).get_context_data(**kwargs)
+        context['theme_index'] = theme_index
+        return context
+
+    # ----------------------------------------------------------------------
+    @cache_function(CACHE_TIMEOUT_1HOUR)
+    def _get_theme_index(self):
+        self._fetch_file_via_github_api('index/index.json', repository='geany-themes')
+        return self._parse_themes_index()
+
+    # ----------------------------------------------------------------------
+    def _parse_themes_index(self):
+        return json.loads(self._file_contents)



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list