lists.geany.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
List overview
Commits
June 2019
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
commits@lists.geany.org
1 participants
70 discussions
Start a n
N
ew thread
[geany/www.geany.org] b79915: Improve logging of Github API requests
by Enrico Tröger
30 Jun '19
30 Jun '19
Branch: refs/heads/master Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: Enrico Tröger <enrico.troeger(a)uvena.de> Date: Sun, 30 Jun 2019 21:39:52 UTC Commit: b79915df440a371cee1135cdaa20045bce0ee37e
https://github.com/geany/www.geany.org/commit/b79915df440a371cee1135cdaa200…
Log Message: ----------- Improve logging of Github API requests Log warnings for non-200 HTTP status codes and add the API error message to the log message. Also log a warning if the API rate limiting is exceeded. Modified Paths: -------------- static_docs/github_client.py Modified: static_docs/github_client.py 41 lines changed, 32 insertions(+), 9 deletions(-) =================================================================== @@ -48,8 +48,8 @@ def get_file_contents(self, filename, user=None, repository=None): def _request(self, url, status_404_expected=False): try: with requests.get(url, timeout=HTTP_REQUEST_TIMEOUT, stream=False) as response: + self._log_request(response, status_404_expected) self._log_rate_limit(response) - self._log_request(response) # error out on 4xx and 5xx status codes response.raise_for_status() except requests.exceptions.HTTPError as exc: @@ -62,17 +62,40 @@ def _request(self, url, status_404_expected=False): # ---------------------------------------------------------------------- def _log_rate_limit(self, response): - rate_limit_remaining = response.headers['X-RateLimit-Remaining'] + rate_limit_remaining = int(response.headers['X-RateLimit-Remaining']) rate_limit = response.headers['X-RateLimit-Limit'] - logger.info('Github rate limits: %s/%s', rate_limit_remaining, rate_limit) + log_message = 'Github rate limits: {}/{}'.format(rate_limit_remaining, rate_limit) + if rate_limit_remaining > 0: + logger.info(log_message) + else: + logger.warning(log_message) # ---------------------------------------------------------------------- - def _log_request(self, response): - logger.info( - 'Requesting "{} {}" took {}s'.format( - response.request.method, - response.request.url, - response.elapsed.total_seconds())) + def _log_request(self, response, status_404_expected): + # try to parse response as JSON (if it is a API error) and set the message + # as reason or just use the plain text from the response + if response.status_code >= 400: + try: + response_json = response.json() + reason = response_json.get('message') + except ValueError: + reason = response.text() + else: + reason = response.reason + + log_message = 'Requesting "{} {}" took {}s: {} ({})'.format( + response.request.method, + response.request.url, + response.elapsed.total_seconds(), + response.status_code, + reason) + + if response.status_code == 200: + logger.info(log_message) + elif response.status_code == 404 and status_404_expected: + logger.info(log_message) + else: + logger.warning(log_message) # ---------------------------------------------------------------------- def _parse_fetch_file_response(self, response_json): -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/www.geany.org] 16a8f5: Improve error handling on Github API requests
by Enrico Tröger
30 Jun '19
30 Jun '19
Branch: refs/heads/master Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: Enrico Tröger <enrico.troeger(a)uvena.de> Date: Sun, 30 Jun 2019 21:34:26 UTC Commit: 16a8f5c38e7213b7fb07cb79e91d81763320bb9c
https://github.com/geany/www.geany.org/commit/16a8f5c38e7213b7fb07cb79e91d8…
Log Message: ----------- Improve error handling on Github API requests Before any HTTP or Github API errors were ignored and the code crashed later on processing the missing responses. Now, "requests" raises an appropriate error and we stop trying to process a missing response. Also use a common method for making requests to reduce code duplication. Modified Paths: -------------- static_docs/github_client.py Modified: static_docs/github_client.py 54 lines changed, 34 insertions(+), 20 deletions(-) =================================================================== @@ -33,19 +33,33 @@ class GitHubApiClient: 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 - with requests.get(url, timeout=HTTP_REQUEST_TIMEOUT, stream=False) as response: - response_json = response.json() - self._log_rate_limit(response) - self._log_request(response) + url = '{api_base_url}repos/{user}/{repository}/contents/{filename}'.format( + api_base_url=GITHUB_API_URL, + user=user, + repository=repository, + filename=filename) + response = self._request(url) + response_json = response.json() # parse response return self._parse_fetch_file_response(response_json) + # ---------------------------------------------------------------------- + def _request(self, url, status_404_expected=False): + try: + with requests.get(url, timeout=HTTP_REQUEST_TIMEOUT, stream=False) as response: + self._log_rate_limit(response) + self._log_request(response) + # error out on 4xx and 5xx status codes + response.raise_for_status() + except requests.exceptions.HTTPError as exc: + if exc.response.status_code == 404 and status_404_expected: + return None + else: + raise + + return response + # ---------------------------------------------------------------------- def _log_rate_limit(self, response): rate_limit_remaining = response.headers['X-RateLimit-Remaining'] @@ -71,26 +85,26 @@ def _parse_fetch_file_response(self, response_json): # ---------------------------------------------------------------------- def get_release_by_tag(self, tag_name): - url = '
https://api.github.com/repos/{user}/{repository}/releases/tags/{tag_name}
'.format( + url = '{api_base_url}repos/{user}/{repository}/releases/tags/{tag_name}'.format( + api_base_url=GITHUB_API_URL, user=GITHUB_USER, repository=GITHUB_REPOSITORY, tag_name=tag_name) - with requests.get(url, timeout=HTTP_REQUEST_TIMEOUT, stream=False) as response: - response_json = response.json() - self._log_rate_limit(response) - if response.status_code == 404: - return None + response = self._request(url, status_404_expected=True) + if response: + response_json = response.json() + return response_json - return response_json + return None # ---------------------------------------------------------------------- def get_latest_release(self): - url = '
https://api.github.com/repos/{user}/{repository}/releases/latest
'.format( + url = '{api_base_url}repos/{user}/{repository}/releases/latest'.format( + api_base_url=GITHUB_API_URL, user=GITHUB_USER, repository=GITHUB_REPOSITORY) - with requests.get(url, timeout=HTTP_REQUEST_TIMEOUT, stream=False) as response: - response_json = response.json() - self._log_rate_limit(response) + response = self._request(url) + response_json = response.json() return response_json -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/www.geany.org] 3b62ba: Exclude API or legacy URLs from /sitemap.xml
by Enrico Tröger
30 Jun '19
30 Jun '19
Branch: refs/heads/master Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: Enrico Tröger <enrico.troeger(a)uvena.de> Date: Sun, 30 Jun 2019 12:46:03 UTC Commit: 3b62baf048984a1bf60549470c360403f9283a52
https://github.com/geany/www.geany.org/commit/3b62baf048984a1bf60549470c360…
Log Message: ----------- Exclude API or legacy URLs from /sitemap.xml Those URLs cannot or should not be called directly and so also not indexed by search engines. Modified Paths: -------------- geany/sitemaps.py latest_version/urls.py pastebin/urls.py Modified: geany/sitemaps.py 24 lines changed, 16 insertions(+), 8 deletions(-) =================================================================== @@ -92,9 +92,10 @@ class StaticSitemap(sitemaps.Sitemap): priority = 0.5 # ---------------------------------------------------------------------- - def __init__(self, domain, patterns): + def __init__(self, domain, patterns, exclude_views=None): self._domain = domain self._patterns = patterns + self._exclude_views = exclude_views or list() self._site = None self._url_mapping = {} self._get_site() @@ -111,7 +112,8 @@ def get_static_items(self): # ---------------------------------------------------------------------- def _initialize(self): for pattern in self._patterns: - if getattr(pattern, 'name', None) is not None: + view_name = getattr(pattern, 'name', None) + if view_name is not None and view_name not in self._exclude_views: url_resolved = self._resolve_url(pattern.name) if url_resolved: self._url_mapping[pattern.name] = url_resolved @@ -153,11 +155,11 @@ def __init__(self): self._static_items = None # ---------------------------------------------------------------------- - def add(self, generator_class, url_patterns, site_domain=None): + def add(self, generator_class, url_patterns, site_domain=None, exclude_views=None): if site_domain is None: site = Site.objects.get(id=settings.SITE_ID) site_domain = site.domain - sitemap_generator_item = (generator_class, url_patterns, site_domain) + sitemap_generator_item = (generator_class, url_patterns, site_domain, exclude_views) self._sitemap_generators.append(sitemap_generator_item) # ---------------------------------------------------------------------- @@ -176,17 +178,23 @@ def get_all_items(self): # ---------------------------------------------------------------------- def _get_static_items(self): static_items = list() - for sitemap_generator_class, url_patterns, site_domain in self._sitemap_generators: - generator = sitemap_generator_class(site_domain, url_patterns) + for generator_class, url_patterns, site_domain, exclude_views in self._sitemap_generators: + generator = generator_class( + site_domain, + url_patterns, + exclude_views=exclude_views) items = generator.get_static_items() static_items.extend(items) return static_items # ---------------------------------------------------------------------- def _get_dynamic_items(self): dynamic_items = list() - for sitemap_generator_class, url_patterns, site_domain in self._sitemap_generators: - generator = sitemap_generator_class(site_domain, url_patterns) + for generator_class, url_patterns, site_domain, exclude_views in self._sitemap_generators: + generator = generator_class( + site_domain, + url_patterns, + exclude_views=exclude_views) items = generator.get_dynamic_items() dynamic_items.extend(items) return dynamic_items Modified: latest_version/urls.py 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -32,4 +32,4 @@ ) # register our urlpatterns to the global sitemap generator -sitemap_registry.add(StaticSitemap, urlpatterns) +sitemap_registry.add(StaticSitemap, urlpatterns, exclude_views=['latest_version_legacy']) Modified: pastebin/urls.py 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -57,4 +57,4 @@ # Sitemap framework -sitemap_registry.add(StaticSitemap, urlpatterns) +sitemap_registry.add(StaticSitemap, urlpatterns, exclude_views=['snippet_api']) -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/www.geany.org] 23cb6f: Add new, clean URL for querying the latest version: /service/version/
by Enrico Tröger
30 Jun '19
30 Jun '19
Branch: refs/heads/master Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: Enrico Tröger <enrico.troeger(a)uvena.de> Date: Sun, 30 Jun 2019 12:19:49 UTC Commit: 23cb6f471f60938418a31914e93523f5fafabcfb
https://github.com/geany/www.geany.org/commit/23cb6f471f60938418a31914e9352…
Log Message: ----------- Add new, clean URL for querying the latest version: /service/version/ This URL is used by the UpdateChecker plugin. Modified Paths: -------------- latest_version/urls.py Modified: latest_version/urls.py 9 lines changed, 7 insertions(+), 2 deletions(-) =================================================================== @@ -19,11 +19,16 @@ urlpatterns = ( # pylint: disable=invalid-name - # compat / special url for the UpdateChecker Geany plugin + # special url for the UpdateChecker Geany plugin url( - r'^service/version.php', + r'^service/version/', TemplateView.as_view(template_name='latest_version.txt', content_type='text/plain'), name='latest_version'), + # legacy url for the UpdateChecker Geany plugin + url( + r'^service/version.php', + TemplateView.as_view(template_name='latest_version.txt', content_type='text/plain'), + name='latest_version_legacy'), ) # register our urlpatterns to the global sitemap generator -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/www.geany.org] 1ab6c2: Merge pull request #8 from geany/issue5_geany_themes_preview
by Enrico Tröger
30 Jun '19
30 Jun '19
Branch: refs/heads/master Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: GitHub <noreply(a)github.com> Date: Sun, 30 Jun 2019 12:11:17 UTC Commit: 1ab6c22629c745106a4debb44f3903ef0a7e5b5b
https://github.com/geany/www.geany.org/commit/1ab6c22629c745106a4debb44f390…
Log Message: ----------- Merge pull request #8 from geany/issue5_geany_themes_preview Add Geany-Themes page with theme preview Modified Paths: -------------- geany/templates/home.html 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: geany/templates/home.html 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -151,7 +151,7 @@ <h2 class="text-center">Great Community</h2> <h2 class="text-center">Easily Customizable</h2> <p> Many parts of Geany are heavily customizable like color themes - (<a href="
https://github.com/geany/geany-themes
">Geany Themes project</a>) or + (<a href="{% url "page" "download/themes" %}">Geany Themes</a>) or adding new filetypes. </p> <p> 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 17 lines changed, 14 insertions(+), 3 deletions(-) =================================================================== @@ -30,15 +30,18 @@ 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 with requests.get(url, timeout=HTTP_REQUEST_TIMEOUT, stream=False) as response: response_json = response.json() self._log_rate_limit(response) + self._log_request(response) # parse response return self._parse_fetch_file_response(response_json) @@ -49,6 +52,14 @@ def _log_rate_limit(self, response): rate_limit = response.headers['X-RateLimit-Limit'] logger.info('Github rate limits: %s/%s', rate_limit_remaining, rate_limit) + # ---------------------------------------------------------------------- + def _log_request(self, response): + logger.info( + 'Requesting "{} {}" took {}s'.format( + response.request.method, + response.request.url, + response.elapsed.total_seconds())) + # ---------------------------------------------------------------------- def _parse_fetch_file_response(self, response_json): content = response_json['content'] Modified: static_docs/templates/pages/download/themes.html 63 lines changed, 63 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,63 @@ +{% 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 }}" + 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 64 lines changed, 62 insertions(+), 2 deletions(-) =================================================================== @@ -19,6 +19,7 @@ import re from django.conf import settings +from django.core.cache import cache from django.http import Http404 from django.views.generic.base import TemplateView from mezzanine_pagedown.filters import plain as markdown_plain @@ -30,6 +31,9 @@ RELEASE_REGEXP = re.compile(r'^Geany (?P<version>[0-9\.]+) \((?P<date>.*)\)$') DATE_PATTERNS_TO_BE_IGNORED = ('TBD', 'TBA', 'unreleased') +CACHE_KEY_THEME_INDEX_MD5_HASH = 'THEME_INDEX_MD5_HASH' +CACHE_KEY_THEME_INDEX = 'THEME_INDEX' + logger = logging.getLogger(__name__) # pylint: disable=invalid-name @@ -56,9 +60,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 +244,59 @@ 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 + + # ---------------------------------------------------------------------- + def _get_theme_index(self): + """ + Refresh the theme index by: + - querying the MD5 hash from Github + - compare the freshly retrieved MD5 hash against the cached one + - load the whole theme index if: + - the MD5 hashes differ + - the MD5 hash was not retrieved yet or has been expired from cache + - the theme index was not retrieved yet or has been expired from cache + - after loading the whole theme index cache it long (24 hours) + - store the freshly retrieved MD5 hash in the cache + """ + theme_index_md5_hash = self._query_theme_index_md5_hash() + cached_theme_index_md5_hash = cache.get(CACHE_KEY_THEME_INDEX_MD5_HASH) + theme_index = cache.get(CACHE_KEY_THEME_INDEX) + + # theme index has been changed remotely? + if theme_index_md5_hash != cached_theme_index_md5_hash or theme_index is None: + logger.debug('Refresh theme index from Github (MD5: {})'.format(theme_index_md5_hash)) + # query whole theme index + theme_index = self._query_parse_themes_index() + # cache it for later + cache.set(CACHE_KEY_THEME_INDEX, theme_index, CACHE_TIMEOUT_24HOURS) + + # cache MD5 hash + cache.set(CACHE_KEY_THEME_INDEX_MD5_HASH, theme_index_md5_hash, CACHE_TIMEOUT_24HOURS) + + return theme_index + + # ---------------------------------------------------------------------- + def _query_theme_index_md5_hash(self): + self._fetch_file_via_github_api('index/index.json.md5', repository='geany-themes') + return self._file_contents.strip() + + # ---------------------------------------------------------------------- + def _query_parse_themes_index(self): + self._fetch_file_via_github_api('index/index.json', repository='geany-themes') + theme_index = json.loads(self._file_contents) + return theme_index -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/www.geany.org] a6909b: Merge pull request #12 from geany/issue6_content_license
by Enrico Tröger
30 Jun '19
30 Jun '19
Branch: refs/heads/master Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: GitHub <noreply(a)github.com> Date: Sun, 30 Jun 2019 12:10:27 UTC Commit: a6909bc60cca88c564af78bfb8a61a039febf50f
https://github.com/geany/www.geany.org/commit/a6909bc60cca88c564af78bfb8a61…
Log Message: ----------- Merge pull request #12 from geany/issue6_content_license Add "CC BY-SA" notice to footer Modified Paths: -------------- geany/templates/skel.html Modified: geany/templates/skel.html 4 lines changed, 3 insertions(+), 1 deletions(-) =================================================================== @@ -58,7 +58,9 @@ <div class="well"> <p> <a href="{% url 'page' "about/privacy" %}">Privacy Statement</a> - - Contents Copyright {% now "Y" %} ‐ The Geany development team + ‐ Contents Copyright {% now "Y" %} + ‐ The Geany contributors + ‐ Licensed under <a href="
https://creativecommons.org/licenses/by-sa/4.0/
">CC BY-SA</a> </p> </div> </div> -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/www.geany.org] 52941f: Log request duration of Github API calls
by Enrico Tröger
30 Jun '19
30 Jun '19
Branch: refs/heads/issue5_geany_themes_preview Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: Enrico Tröger <enrico.troeger(a)uvena.de> Date: Sun, 30 Jun 2019 12:08:45 UTC Commit: 52941f97ac36ae834b4ecd65c93bdab7f034372c
https://github.com/geany/www.geany.org/commit/52941f97ac36ae834b4ecd65c93bd…
Log Message: ----------- Log request duration of Github API calls Modified Paths: -------------- static_docs/github_client.py Modified: static_docs/github_client.py 9 lines changed, 9 insertions(+), 0 deletions(-) =================================================================== @@ -41,6 +41,7 @@ def get_file_contents(self, filename, user=None, repository=None): with requests.get(url, timeout=HTTP_REQUEST_TIMEOUT, stream=False) as response: response_json = response.json() self._log_rate_limit(response) + self._log_request(response) # parse response return self._parse_fetch_file_response(response_json) @@ -51,6 +52,14 @@ def _log_rate_limit(self, response): rate_limit = response.headers['X-RateLimit-Limit'] logger.info('Github rate limits: %s/%s', rate_limit_remaining, rate_limit) + # ---------------------------------------------------------------------- + def _log_request(self, response): + logger.info( + 'Requesting "{} {}" took {}s'.format( + response.request.method, + response.request.url, + response.elapsed.total_seconds())) + # ---------------------------------------------------------------------- def _parse_fetch_file_response(self, response_json): content = response_json['content'] -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/www.geany.org] 668492: Add Geany-Themes page with theme preview
by Enrico Tröger
30 Jun '19
30 Jun '19
Branch: refs/heads/issue5_geany_themes_preview Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: Enrico Tröger <enrico.troeger(a)uvena.de> Date: Sun, 30 Jun 2019 12:08:45 UTC Commit: 668492803592cde2c30254b0dbc5fb61001187f7
https://github.com/geany/www.geany.org/commit/668492803592cde2c30254b0dbc5f…
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: -------------- geany/templates/home.html 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: geany/templates/home.html 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -151,7 +151,7 @@ <h2 class="text-center">Great Community</h2> <h2 class="text-center">Easily Customizable</h2> <p> Many parts of Geany are heavily customizable like color themes - (<a href="
https://github.com/geany/geany-themes
">Geany Themes project</a>) or + (<a href="{% url "page" "download/themes" %}">Geany Themes</a>) or adding new filetypes. </p> <p> 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 63 lines changed, 63 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,63 @@ +{% 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 }}" + 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 64 lines changed, 62 insertions(+), 2 deletions(-) =================================================================== @@ -19,6 +19,7 @@ import re from django.conf import settings +from django.core.cache import cache from django.http import Http404 from django.views.generic.base import TemplateView from mezzanine_pagedown.filters import plain as markdown_plain @@ -30,6 +31,9 @@ RELEASE_REGEXP = re.compile(r'^Geany (?P<version>[0-9\.]+) \((?P<date>.*)\)$') DATE_PATTERNS_TO_BE_IGNORED = ('TBD', 'TBA', 'unreleased') +CACHE_KEY_THEME_INDEX_MD5_HASH = 'THEME_INDEX_MD5_HASH' +CACHE_KEY_THEME_INDEX = 'THEME_INDEX' + logger = logging.getLogger(__name__) # pylint: disable=invalid-name @@ -56,9 +60,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 +244,59 @@ 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 + + # ---------------------------------------------------------------------- + def _get_theme_index(self): + """ + Refresh the theme index by: + - querying the MD5 hash from Github + - compare the freshly retrieved MD5 hash against the cached one + - load the whole theme index if: + - the MD5 hashes differ + - the MD5 hash was not retrieved yet or has been expired from cache + - the theme index was not retrieved yet or has been expired from cache + - after loading the whole theme index cache it long (24 hours) + - store the freshly retrieved MD5 hash in the cache + """ + theme_index_md5_hash = self._query_theme_index_md5_hash() + cached_theme_index_md5_hash = cache.get(CACHE_KEY_THEME_INDEX_MD5_HASH) + theme_index = cache.get(CACHE_KEY_THEME_INDEX) + + # theme index has been changed remotely? + if theme_index_md5_hash != cached_theme_index_md5_hash or theme_index is None: + logger.debug('Refresh theme index from Github (MD5: {})'.format(theme_index_md5_hash)) + # query whole theme index + theme_index = self._query_parse_themes_index() + # cache it for later + cache.set(CACHE_KEY_THEME_INDEX, theme_index, CACHE_TIMEOUT_24HOURS) + + # cache MD5 hash + cache.set(CACHE_KEY_THEME_INDEX_MD5_HASH, theme_index_md5_hash, CACHE_TIMEOUT_24HOURS) + + return theme_index + + # ---------------------------------------------------------------------- + def _query_theme_index_md5_hash(self): + self._fetch_file_via_github_api('index/index.json.md5', repository='geany-themes') + return self._file_contents.strip() + + # ---------------------------------------------------------------------- + def _query_parse_themes_index(self): + self._fetch_file_via_github_api('index/index.json', repository='geany-themes') + theme_index = json.loads(self._file_contents) + return theme_index -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/www.geany.org] 668492: Add Geany-Themes page with theme preview
by Enrico Tröger
30 Jun '19
30 Jun '19
Branch: refs/heads/master Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: Enrico Tröger <enrico.troeger(a)uvena.de> Date: Sun, 30 Jun 2019 12:08:45 UTC Commit: 668492803592cde2c30254b0dbc5fb61001187f7
https://github.com/geany/www.geany.org/commit/668492803592cde2c30254b0dbc5f…
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: -------------- geany/templates/home.html 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: geany/templates/home.html 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -151,7 +151,7 @@ <h2 class="text-center">Great Community</h2> <h2 class="text-center">Easily Customizable</h2> <p> Many parts of Geany are heavily customizable like color themes - (<a href="
https://github.com/geany/geany-themes
">Geany Themes project</a>) or + (<a href="{% url "page" "download/themes" %}">Geany Themes</a>) or adding new filetypes. </p> <p> 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 63 lines changed, 63 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,63 @@ +{% 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 }}" + 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 64 lines changed, 62 insertions(+), 2 deletions(-) =================================================================== @@ -19,6 +19,7 @@ import re from django.conf import settings +from django.core.cache import cache from django.http import Http404 from django.views.generic.base import TemplateView from mezzanine_pagedown.filters import plain as markdown_plain @@ -30,6 +31,9 @@ RELEASE_REGEXP = re.compile(r'^Geany (?P<version>[0-9\.]+) \((?P<date>.*)\)$') DATE_PATTERNS_TO_BE_IGNORED = ('TBD', 'TBA', 'unreleased') +CACHE_KEY_THEME_INDEX_MD5_HASH = 'THEME_INDEX_MD5_HASH' +CACHE_KEY_THEME_INDEX = 'THEME_INDEX' + logger = logging.getLogger(__name__) # pylint: disable=invalid-name @@ -56,9 +60,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 +244,59 @@ 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 + + # ---------------------------------------------------------------------- + def _get_theme_index(self): + """ + Refresh the theme index by: + - querying the MD5 hash from Github + - compare the freshly retrieved MD5 hash against the cached one + - load the whole theme index if: + - the MD5 hashes differ + - the MD5 hash was not retrieved yet or has been expired from cache + - the theme index was not retrieved yet or has been expired from cache + - after loading the whole theme index cache it long (24 hours) + - store the freshly retrieved MD5 hash in the cache + """ + theme_index_md5_hash = self._query_theme_index_md5_hash() + cached_theme_index_md5_hash = cache.get(CACHE_KEY_THEME_INDEX_MD5_HASH) + theme_index = cache.get(CACHE_KEY_THEME_INDEX) + + # theme index has been changed remotely? + if theme_index_md5_hash != cached_theme_index_md5_hash or theme_index is None: + logger.debug('Refresh theme index from Github (MD5: {})'.format(theme_index_md5_hash)) + # query whole theme index + theme_index = self._query_parse_themes_index() + # cache it for later + cache.set(CACHE_KEY_THEME_INDEX, theme_index, CACHE_TIMEOUT_24HOURS) + + # cache MD5 hash + cache.set(CACHE_KEY_THEME_INDEX_MD5_HASH, theme_index_md5_hash, CACHE_TIMEOUT_24HOURS) + + return theme_index + + # ---------------------------------------------------------------------- + def _query_theme_index_md5_hash(self): + self._fetch_file_via_github_api('index/index.json.md5', repository='geany-themes') + return self._file_contents.strip() + + # ---------------------------------------------------------------------- + def _query_parse_themes_index(self): + self._fetch_file_via_github_api('index/index.json', repository='geany-themes') + theme_index = json.loads(self._file_contents) + return theme_index -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/www.geany.org] 52941f: Log request duration of Github API calls
by Enrico Tröger
30 Jun '19
30 Jun '19
Branch: refs/heads/master Author: Enrico Tröger <enrico.troeger(a)uvena.de> Committer: Enrico Tröger <enrico.troeger(a)uvena.de> Date: Sun, 30 Jun 2019 12:08:45 UTC Commit: 52941f97ac36ae834b4ecd65c93bdab7f034372c
https://github.com/geany/www.geany.org/commit/52941f97ac36ae834b4ecd65c93bd…
Log Message: ----------- Log request duration of Github API calls Modified Paths: -------------- static_docs/github_client.py Modified: static_docs/github_client.py 9 lines changed, 9 insertions(+), 0 deletions(-) =================================================================== @@ -41,6 +41,7 @@ def get_file_contents(self, filename, user=None, repository=None): with requests.get(url, timeout=HTTP_REQUEST_TIMEOUT, stream=False) as response: response_json = response.json() self._log_rate_limit(response) + self._log_request(response) # parse response return self._parse_fetch_file_response(response_json) @@ -51,6 +52,14 @@ def _log_rate_limit(self, response): rate_limit = response.headers['X-RateLimit-Limit'] logger.info('Github rate limits: %s/%s', rate_limit_remaining, rate_limit) + # ---------------------------------------------------------------------- + def _log_request(self, response): + logger.info( + 'Requesting "{} {}" took {}s'.format( + response.request.method, + response.request.url, + response.elapsed.total_seconds())) + # ---------------------------------------------------------------------- def _parse_fetch_file_response(self, response_json): content = response_json['content'] -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
← Newer
1
2
3
4
5
6
7
Older →
Jump to page:
1
2
3
4
5
6
7
Results per page:
10
25
50
100
200