From 75410353c13305e9a625f46d35cb502da7425286 Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Wed, 14 Jan 2015 10:43:55 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E4=B8=AD=E6=96=87=E5=AD=97=E4=BD=93?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pelican/themes/notmyidea/static/css/main.css | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index 2efb518d..aa77215e 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -12,7 +12,6 @@ @import url("reset.css"); @import url("pygment.css"); @import url("typogrify.css"); -@import url(//fonts.googleapis.com/css?family=Yanone+Kaffeesatz&subset=latin); /***** Global *****/ /* Body */ @@ -20,7 +19,7 @@ body { background: #F5F4EF; color: #000305; font-size: 87.5%; /* Base font size: 14px */ - font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; + font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; line-height: 1.429; margin: 0; padding: 0; @@ -39,7 +38,7 @@ h1, h2, h3, h4, h5, h6 { font-weight: 400; line-height: 1.1; margin-bottom: .8em; - font-family: 'Yanone Kaffeesatz', arial, serif; + font-family: 'Yanone Kaffeesatz', arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; } h3, h4, h5, h6 { margin-top: .8em; } From 9bdbfdb32c557d6fc8c674bb87c5cde2624d9c76 Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Thu, 15 Jan 2015 09:42:24 +0800 Subject: [PATCH 02/19] set margin bottom for ul, ol in default theme --- pelican/themes/notmyidea/static/css/main.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index 2efb518d..6dc10a6a 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -76,12 +76,12 @@ em, i {font-style: italic;} /* Lists */ ul { list-style: outside disc; - margin: 0em 0 0 1.5em; + margin: 0em 0 1em 1.5em; } ol { list-style: outside decimal; - margin: 0em 0 0 1.5em; + margin: 0em 0 1em 1.5em; } li { margin-top: 0.5em;} From 5d62ecc84dee12b6d76408371230b1cd3e6e96e9 Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Thu, 15 Jan 2015 10:29:22 +0800 Subject: [PATCH 03/19] update test cases --- pelican/tests/output/basic/theme/css/main.css | 4 ++-- pelican/tests/output/custom/theme/css/main.css | 4 ++-- pelican/tests/output/custom_locale/theme/css/main.css | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pelican/tests/output/basic/theme/css/main.css b/pelican/tests/output/basic/theme/css/main.css index 2efb518d..6dc10a6a 100644 --- a/pelican/tests/output/basic/theme/css/main.css +++ b/pelican/tests/output/basic/theme/css/main.css @@ -76,12 +76,12 @@ em, i {font-style: italic;} /* Lists */ ul { list-style: outside disc; - margin: 0em 0 0 1.5em; + margin: 0em 0 1em 1.5em; } ol { list-style: outside decimal; - margin: 0em 0 0 1.5em; + margin: 0em 0 1em 1.5em; } li { margin-top: 0.5em;} diff --git a/pelican/tests/output/custom/theme/css/main.css b/pelican/tests/output/custom/theme/css/main.css index 2efb518d..6dc10a6a 100644 --- a/pelican/tests/output/custom/theme/css/main.css +++ b/pelican/tests/output/custom/theme/css/main.css @@ -76,12 +76,12 @@ em, i {font-style: italic;} /* Lists */ ul { list-style: outside disc; - margin: 0em 0 0 1.5em; + margin: 0em 0 1em 1.5em; } ol { list-style: outside decimal; - margin: 0em 0 0 1.5em; + margin: 0em 0 1em 1.5em; } li { margin-top: 0.5em;} diff --git a/pelican/tests/output/custom_locale/theme/css/main.css b/pelican/tests/output/custom_locale/theme/css/main.css index 2efb518d..6dc10a6a 100644 --- a/pelican/tests/output/custom_locale/theme/css/main.css +++ b/pelican/tests/output/custom_locale/theme/css/main.css @@ -76,12 +76,12 @@ em, i {font-style: italic;} /* Lists */ ul { list-style: outside disc; - margin: 0em 0 0 1.5em; + margin: 0em 0 1em 1.5em; } ol { list-style: outside decimal; - margin: 0em 0 0 1.5em; + margin: 0em 0 1em 1.5em; } li { margin-top: 0.5em;} From c86c180e3f2319041fb15ca56120da82f142d921 Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Thu, 15 Jan 2015 13:47:40 +0800 Subject: [PATCH 04/19] =?UTF-8?q?=E6=8F=90=E5=8F=96=E5=87=BA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=81=9A=E6=88=90=E9=80=9A=E7=94=A8=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pelican/themes/notmyidea/templates/analytics.html | 11 +++++++++++ pelican/themes/notmyidea/templates/base.html | 3 ++- .../themes/notmyidea/templates/china_icp_license.html | 5 +++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 pelican/themes/notmyidea/templates/china_icp_license.html diff --git a/pelican/themes/notmyidea/templates/analytics.html b/pelican/themes/notmyidea/templates/analytics.html index e27adf82..9f500731 100644 --- a/pelican/themes/notmyidea/templates/analytics.html +++ b/pelican/themes/notmyidea/templates/analytics.html @@ -44,3 +44,14 @@ })(); {% endif %} +{% if BAIDU_ANALYTICS %} + +{% endif %} diff --git a/pelican/themes/notmyidea/templates/base.html b/pelican/themes/notmyidea/templates/base.html index d6b4cb35..1c09a194 100644 --- a/pelican/themes/notmyidea/templates/base.html +++ b/pelican/themes/notmyidea/templates/base.html @@ -74,9 +74,10 @@

The theme is by Smashing Magazine, thanks!

+ {% include 'china_icp_license.html' %} -{% include 'analytics.html' %} +{% include 'analytics.html' %} {% include 'disqus_script.html' %} diff --git a/pelican/themes/notmyidea/templates/china_icp_license.html b/pelican/themes/notmyidea/templates/china_icp_license.html new file mode 100644 index 00000000..cff5b061 --- /dev/null +++ b/pelican/themes/notmyidea/templates/china_icp_license.html @@ -0,0 +1,5 @@ +{% if CHINA_ICP_LICENSE %} +

+{{ CHINA_ICP_LICENSE }} +

+{% endif %} From 78e8078f2a9d91f0b34fe14da5be14cb49006d5e Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Fri, 16 Jan 2015 10:22:16 +0800 Subject: [PATCH 05/19] blockquote style --- pelican/themes/notmyidea/static/css/main.css | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index f841c463..d3973383 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -106,9 +106,24 @@ pre{background-color: rgb(238, 238, 238); padding: 10px; margin: 10px; overflow /* Quotes */ blockquote { - margin: 20px; - font-style: italic; + background: #f9f9f9; + border-left: 10px solid #ccc; + margin: 1.5em 10px; + padding: 0.5em 10px; + quotes: "\201C""\201D""\2018""\2019"; } +blockquote:before { + color: #ccc; + content: open-quote; + font-size: 4em; + line-height: 0.1em; + margin-right: 0.25em; + vertical-align: -0.4em; +} +blockquote p { + display: inline; +} + cite {} q {} From 1a5ca99a75a8ea0e1db71a45ccba994ce3926f50 Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Fri, 16 Jan 2015 13:56:31 +0800 Subject: [PATCH 06/19] update --- pelican/themes/notmyidea/static/css/main.css | 38 ++++++++++++++----- .../themes/notmyidea/static/css/pygment.css | 2 + pelican/themes/notmyidea/templates/base.html | 30 +++++++++------ 3 files changed, 50 insertions(+), 20 deletions(-) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index d3973383..c5b187be 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -102,7 +102,13 @@ dl {margin: 0 0 1.5em 0;} dt {font-weight: bold;} dd {margin-left: 1.5em;} -pre{background-color: rgb(238, 238, 238); padding: 10px; margin: 10px; overflow: auto;} +pre { + display: block; + padding: 0.5em; + background: #002b36; + color: #D9E9EB; + margin-bottom: 1em; +} /* Quotes */ blockquote { @@ -300,25 +306,39 @@ img.left, figure.left {float: left; margin: 0 2em 2em 0;} #extras a:hover, #extras a:active {color: #fff;} - /* Blogroll */ - #extras .blogroll { - float: left; - width: 615px; + /* Tags */ + #extras .tags { + width: 800px; } - #extras .blogroll li {float: left; margin: 0 20px 0 0; width: 185px;} + #extras .tags li {float: left; margin: 0 20px 0 0; width: 90px;} + + /* Blogroll */ + #extras .blogroll { + width: 550px; + margin-top: 2em; + float: left; + } + + #extras .blogroll li {float: left; margin: 0 20px 0 0; width: 90px;} + /* Social */ #extras .social { - float: right; - width: 175px; + width: 150px; + margin-top: 2em; + float: left; } - + #extras div[class='social'] a { background-repeat: no-repeat; background-position: 3px 6px; padding-left: 25px; } + + #extras .social li { + margin-top: 0; + } /* Icons */ .social a[href*='about.me'] {background-image: url('../images/icons/aboutme.png');} diff --git a/pelican/themes/notmyidea/static/css/pygment.css b/pelican/themes/notmyidea/static/css/pygment.css index fdd056f6..28039e6e 100644 --- a/pelican/themes/notmyidea/static/css/pygment.css +++ b/pelican/themes/notmyidea/static/css/pygment.css @@ -6,7 +6,9 @@ color:#408090; font-style:italic; } .err { +/* border:1px solid #FF0000; +*/ } .k { color:#007020; diff --git a/pelican/themes/notmyidea/templates/base.html b/pelican/themes/notmyidea/templates/base.html index 1c09a194..28111f12 100644 --- a/pelican/themes/notmyidea/templates/base.html +++ b/pelican/themes/notmyidea/templates/base.html @@ -39,9 +39,17 @@ {% block content %} {% endblock %}
+
+

Tags

+
    + {% for tag in tag_cloud %} +
  • {{ tag.0 }}
  • + {% endfor %} +
+
{% if LINKS %}
-

blogroll

+

Blogroll

    {% for name, link in LINKS %}
  • {{ name }}
  • @@ -51,18 +59,18 @@ {% endif %} {% if SOCIAL or FEED_ALL_ATOM or FEED_ALL_RSS %} {% endif %} From 19d59b598d1d8d39eca7287fa575c5765e820a29 Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Wed, 21 Jan 2015 17:33:00 +0800 Subject: [PATCH 07/19] update --- pelican/themes/notmyidea/static/css/main.css | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index c5b187be..d8802fe4 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -70,7 +70,10 @@ p { margin-top: 1em; margin-bottom: 1em;} strong, b {font-weight: bold;} -em, i {font-style: italic;} +em, i { + font-style: italic; + background-color: yellow; +} /* Lists */ ul { From a2d6e6eec95b73a499bf68421c5fd8b165c61f01 Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Fri, 23 Jan 2015 08:35:25 +0800 Subject: [PATCH 08/19] set pre style --- pelican/themes/notmyidea/static/css/main.css | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index c5b187be..563ed90c 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -103,11 +103,19 @@ dt {font-weight: bold;} dd {margin-left: 1.5em;} pre { + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; display: block; padding: 0.5em; background: #002b36; - color: #D9E9EB; + color: #DBDBD8; margin-bottom: 1em; + font-family: monospace, Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; +} + +pre * { + color: #DBDBD8 !important; } /* Quotes */ From f715798db39794ad8504e87680ec906975b4d0c7 Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Fri, 23 Jan 2015 17:21:49 +0800 Subject: [PATCH 09/19] update --- pelican/themes/notmyidea/static/css/main.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index 716a1ec3..4324c97c 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -117,10 +117,6 @@ pre { font-family: monospace, Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; } -pre * { - color: #DBDBD8 !important; -} - /* Quotes */ blockquote { background: #f9f9f9; From a4901b3f1ad68bb9112232f9b65f8bd9f43e1b80 Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Fri, 23 Jan 2015 17:24:30 +0800 Subject: [PATCH 10/19] =?UTF-8?q?pre=20=E5=A2=9E=E5=8A=A0=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pelican/themes/notmyidea/static/css/main.css | 1 + 1 file changed, 1 insertion(+) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index 4324c97c..d351f4d8 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -115,6 +115,7 @@ pre { color: #DBDBD8; margin-bottom: 1em; font-family: monospace, Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; + overflow-x: auto; } /* Quotes */ From 5144d1dac090963ec7de789ca1955e4b1bc2123d Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Fri, 23 Jan 2015 22:23:18 +0800 Subject: [PATCH 11/19] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20chrome=20=E4=B8=8BUI?= =?UTF-8?q?=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pelican/themes/notmyidea/static/css/main.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index d351f4d8..838358ce 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -118,6 +118,10 @@ pre { overflow-x: auto; } +.highlight { + overflow: auto; +} + /* Quotes */ blockquote { background: #f9f9f9; From 0ab2b57b66cedddec9aac27b3276beaf6a30af11 Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Fri, 23 Jan 2015 22:53:46 +0800 Subject: [PATCH 12/19] fix blockquote bug --- pelican/themes/notmyidea/static/css/main.css | 1 + 1 file changed, 1 insertion(+) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index 838358ce..eaf2ac16 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -129,6 +129,7 @@ blockquote { margin: 1.5em 10px; padding: 0.5em 10px; quotes: "\201C""\201D""\2018""\2019"; + overflow: auto; } blockquote:before { color: #ccc; From 1a8056d474dc1a3aa896d5887f5d31fd3fa6c464 Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Sat, 24 Jan 2015 15:20:01 +0800 Subject: [PATCH 13/19] update --- pelican/plugins/sitemap/Readme.rst | 65 +++++ pelican/plugins/sitemap/__init__.py | 1 + pelican/plugins/sitemap/sitemap.py | 243 +++++++++++++++++++ pelican/plugins/test.py | 22 ++ pelican/themes/notmyidea/static/css/main.css | 53 ++-- pelican/themes/notmyidea/templates/base.html | 1 + 6 files changed, 368 insertions(+), 17 deletions(-) create mode 100644 pelican/plugins/sitemap/Readme.rst create mode 100644 pelican/plugins/sitemap/__init__.py create mode 100644 pelican/plugins/sitemap/sitemap.py create mode 100644 pelican/plugins/test.py diff --git a/pelican/plugins/sitemap/Readme.rst b/pelican/plugins/sitemap/Readme.rst new file mode 100644 index 00000000..b58a8d50 --- /dev/null +++ b/pelican/plugins/sitemap/Readme.rst @@ -0,0 +1,65 @@ +Sitemap +------- + +The sitemap plugin generates plain-text or XML sitemaps. You can use the +``SITEMAP`` variable in your settings file to configure the behavior of the +plugin. + +The ``SITEMAP`` variable must be a Python dictionary and can contain three keys: + +- ``format``, which sets the output format of the plugin (``xml`` or ``txt``) + +- ``priorities``, which is a dictionary with three keys: + + - ``articles``, the priority for the URLs of the articles and their + translations + + - ``pages``, the priority for the URLs of the static pages + + - ``indexes``, the priority for the URLs of the index pages, such as tags, + author pages, categories indexes, archives, etc... + + All the values of this dictionary must be decimal numbers between ``0`` and ``1``. + +- ``changefreqs``, which is a dictionary with three items: + + - ``articles``, the update frequency of the articles + + - ``pages``, the update frequency of the pages + + - ``indexes``, the update frequency of the index pages + + Valid frequency values are ``always``, ``hourly``, ``daily``, ``weekly``, ``monthly``, + ``yearly`` and ``never``. + +If a key is missing or a value is incorrect, it will be replaced with the +default value. + +The sitemap is saved in ``/sitemap.``. + +.. note:: + ``priorities`` and ``changefreqs`` are information for search engines. + They are only used in the XML sitemaps. + For more information: + +**Example** + +Here is an example configuration (it's also the default settings): + +.. code-block:: python + + PLUGINS=['pelican.plugins.sitemap',] + + SITEMAP = { + 'format': 'xml', + 'priorities': { + 'articles': 0.5, + 'indexes': 0.5, + 'pages': 0.5 + }, + 'changefreqs': { + 'articles': 'monthly', + 'indexes': 'daily', + 'pages': 'monthly' + } + } diff --git a/pelican/plugins/sitemap/__init__.py b/pelican/plugins/sitemap/__init__.py new file mode 100644 index 00000000..ce88f33c --- /dev/null +++ b/pelican/plugins/sitemap/__init__.py @@ -0,0 +1 @@ +from .sitemap import * diff --git a/pelican/plugins/sitemap/sitemap.py b/pelican/plugins/sitemap/sitemap.py new file mode 100644 index 00000000..aab48aca --- /dev/null +++ b/pelican/plugins/sitemap/sitemap.py @@ -0,0 +1,243 @@ +# -*- coding: utf-8 -*- +''' +Sitemap +------- + +The sitemap plugin generates plain-text or XML sitemaps. +''' + +from __future__ import unicode_literals + +import collections +import os.path + +from datetime import datetime +from logging import warning, info +from codecs import open +from pytz import timezone + +from pelican import signals, contents +from pelican.utils import get_date + +TXT_HEADER = """{0}/index.html +{0}/archives.html +{0}/tags.html +{0}/categories.html +""" + +XML_HEADER = """ + +""" + +XML_URL = """ + +{0}/{1} +{2} +{3} +{4} + +""" + +XML_FOOTER = """ + +""" + + +def format_date(date): + if date.tzinfo: + tz = date.strftime('%z') + tz = tz[:-2] + ':' + tz[-2:] + else: + tz = "-00:00" + return date.strftime("%Y-%m-%dT%H:%M:%S") + tz + +class SitemapGenerator(object): + + def __init__(self, context, settings, path, theme, output_path, *null): + + self.output_path = output_path + self.context = context + self.now = datetime.now() + self.siteurl = settings.get('SITEURL') + + + self.default_timezone = settings.get('TIMEZONE', 'UTC') + self.timezone = getattr(self, 'timezone', self.default_timezone) + self.timezone = timezone(self.timezone) + + self.format = 'xml' + + self.changefreqs = { + 'articles': 'monthly', + 'indexes': 'daily', + 'pages': 'monthly' + } + + self.priorities = { + 'articles': 0.5, + 'indexes': 0.5, + 'pages': 0.5 + } + + config = settings.get('SITEMAP', {}) + + if not isinstance(config, dict): + warning("sitemap plugin: the SITEMAP setting must be a dict") + else: + fmt = config.get('format') + pris = config.get('priorities') + chfreqs = config.get('changefreqs') + + if fmt not in ('xml', 'txt'): + warning("sitemap plugin: SITEMAP['format'] must be `txt' or `xml'") + warning("sitemap plugin: Setting SITEMAP['format'] on `xml'") + elif fmt == 'txt': + self.format = fmt + return + + valid_keys = ('articles', 'indexes', 'pages') + valid_chfreqs = ('always', 'hourly', 'daily', 'weekly', 'monthly', + 'yearly', 'never') + + if isinstance(pris, dict): + # We use items for Py3k compat. .iteritems() otherwise + for k, v in pris.items(): + if k in valid_keys and not isinstance(v, (int, float)): + default = self.priorities[k] + warning("sitemap plugin: priorities must be numbers") + warning("sitemap plugin: setting SITEMAP['priorities']" + "['{0}'] on {1}".format(k, default)) + pris[k] = default + self.priorities.update(pris) + elif pris is not None: + warning("sitemap plugin: SITEMAP['priorities'] must be a dict") + warning("sitemap plugin: using the default values") + + if isinstance(chfreqs, dict): + # .items() for py3k compat. + for k, v in chfreqs.items(): + if k in valid_keys and v not in valid_chfreqs: + default = self.changefreqs[k] + warning("sitemap plugin: invalid changefreq `{0}'".format(v)) + warning("sitemap plugin: setting SITEMAP['changefreqs']" + "['{0}'] on '{1}'".format(k, default)) + chfreqs[k] = default + self.changefreqs.update(chfreqs) + elif chfreqs is not None: + warning("sitemap plugin: SITEMAP['changefreqs'] must be a dict") + warning("sitemap plugin: using the default values") + + def write_url(self, page, fd): + + if getattr(page, 'status', 'published') != 'published': + return + + # We can disable categories/authors/etc by using False instead of '' + if not page.save_as: + return + + page_path = os.path.join(self.output_path, page.save_as) + if not os.path.exists(page_path): + return + + lastdate = getattr(page, 'date', self.now) + try: + lastdate = self.get_date_modified(page, lastdate) + except ValueError: + warning("sitemap plugin: " + page.save_as + " has invalid modification date,") + warning("sitemap plugin: using date value as lastmod.") + lastmod = format_date(lastdate) + + if isinstance(page, contents.Article): + pri = self.priorities['articles'] + chfreq = self.changefreqs['articles'] + elif isinstance(page, contents.Page): + pri = self.priorities['pages'] + chfreq = self.changefreqs['pages'] + else: + pri = self.priorities['indexes'] + chfreq = self.changefreqs['indexes'] + + pageurl = '' if page.url == 'index.html' else page.url + + if self.format == 'xml': + fd.write(XML_URL.format(self.siteurl, pageurl, lastmod, chfreq, pri)) + else: + fd.write(self.siteurl + '/' + pageurl + '\n') + + def get_date_modified(self, page, default): + if hasattr(page, 'modified'): + if isinstance(page.modified, datetime): + return page.modified + return get_date(page.modified) + else: + return default + + def set_url_wrappers_modification_date(self, wrappers): + for (wrapper, articles) in wrappers: + lastmod = datetime.min.replace(tzinfo=self.timezone) + for article in articles: + lastmod = max(lastmod, article.date.replace(tzinfo=self.timezone)) + try: + modified = self.get_date_modified(article, datetime.min).replace(tzinfo=self.timezone) + lastmod = max(lastmod, modified) + except ValueError: + # Supressed: user will be notified. + pass + setattr(wrapper, 'modified', str(lastmod)) + + def generate_output(self, writer): + path = os.path.join(self.output_path, 'sitemap.{0}'.format(self.format)) + + pages = self.context['pages'] + self.context['articles'] \ + + [ c for (c, a) in self.context['categories']] \ + + [ t for (t, a) in self.context['tags']] \ + + [ a for (a, b) in self.context['authors']] + + self.set_url_wrappers_modification_date(self.context['categories']) + self.set_url_wrappers_modification_date(self.context['tags']) + self.set_url_wrappers_modification_date(self.context['authors']) + + for article in self.context['articles']: + pages += article.translations + + info('writing {0}'.format(path)) + + with open(path, 'w', encoding='utf-8') as fd: + + if self.format == 'xml': + fd.write(XML_HEADER) + else: + fd.write(TXT_HEADER.format(self.siteurl)) + + FakePage = collections.namedtuple('FakePage', + ['status', + 'date', + 'url', + 'save_as']) + + for standard_page_url in ['index.html', + 'archives.html', + 'tags.html', + 'categories.html']: + fake = FakePage(status='published', + date=self.now, + url=standard_page_url, + save_as=standard_page_url) + self.write_url(fake, fd) + + for page in pages: + self.write_url(page, fd) + + if self.format == 'xml': + fd.write(XML_FOOTER) + + +def get_generators(generators): + return SitemapGenerator + + +def register(): + signals.get_generators.connect(get_generators) diff --git a/pelican/plugins/test.py b/pelican/plugins/test.py new file mode 100644 index 00000000..20f50809 --- /dev/null +++ b/pelican/plugins/test.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# ---------------------------------------- +# Just say "Hello world!". +# ---------------------------------------- +import sitemap + + +# ---------------------------------------- +# test cases +# ---------------------------------------- +def run_doctest(): + '''python -B <__file__> -v + ''' + import doctest + doctest.testmod() + + +if '__main__' == __name__: + print "Hello world!" + diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index eaf2ac16..836d98eb 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -154,23 +154,42 @@ div.note { max-width: 300px; } -/* Tables */ -table {margin: .5em auto 1.5em auto; width: 98%;} - - /* Thead */ - thead th {padding: .5em .4em; text-align: left;} - thead td {} - - /* Tbody */ - tbody td {padding: .5em .4em;} - tbody th {} - - tbody .alt td {} - tbody .alt th {} - - /* Tfoot */ - tfoot th {} - tfoot td {} +table { + background: white; + margin-bottom: 1.25rem; + border: solid 2px #ecf0f1; +} +table thead, +table tfoot { + background: whitesmoke; +} +table thead tr th, +table thead tr td, +table tfoot tr th, +table tfoot tr td { + padding: 0.5rem 0.625rem 0.625rem; + font-size: 0.875rem; + font-weight: bold; + color: #2c3e50; + text-align: left; +} +table tr th, +table tr td { + padding: 0.5625rem 0.625rem; + font-size: 0.875rem; + color: #34495e; +} +table tr.even, table tr.alt, table tr:nth-of-type(even) { + background: #f9f9f9; +} +table thead tr th, +table tfoot tr th, +table tbody tr td, +table tr td, +table tfoot tr td { + display: table-cell; + line-height: 1.125rem; +} /* HTML5 tags */ header, section, footer, diff --git a/pelican/themes/notmyidea/templates/base.html b/pelican/themes/notmyidea/templates/base.html index 28111f12..24583307 100644 --- a/pelican/themes/notmyidea/templates/base.html +++ b/pelican/themes/notmyidea/templates/base.html @@ -81,6 +81,7 @@ Proudly powered by Pelican, which takes great advantage of Python. +

    The theme is by Smashing Magazine, thanks!

    {% include 'china_icp_license.html' %} From 74599ae42d01008db9423af5f04117ee87eaf87f Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Fri, 30 Jan 2015 11:01:35 +0800 Subject: [PATCH 14/19] update css --- pelican/themes/notmyidea/static/css/main.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index 836d98eb..9aa31f1f 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -111,8 +111,8 @@ pre { -webkit-border-radius: 5px; display: block; padding: 0.5em; - background: #002b36; - color: #DBDBD8; + background: #4dd6f9; + color: #0f0f0e; margin-bottom: 1em; font-family: monospace, Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; overflow-x: auto; From 160d2d287c65dce650080518d392394aaa2af8ac Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Thu, 5 Feb 2015 08:19:25 +0800 Subject: [PATCH 15/19] =?UTF-8?q?=E4=B8=AD=E6=96=87=E6=A5=B7=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pelican/themes/notmyidea/static/css/main.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index 9aa31f1f..d981241a 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -19,7 +19,7 @@ body { background: #F5F4EF; color: #000305; font-size: 87.5%; /* Base font size: 14px */ - font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; + font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, KaiTi, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; line-height: 1.429; margin: 0; padding: 0; @@ -38,7 +38,7 @@ h1, h2, h3, h4, h5, h6 { font-weight: 400; line-height: 1.1; margin-bottom: .8em; - font-family: 'Yanone Kaffeesatz', arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; + font-family: 'Yanone Kaffeesatz', arial, KaiTi, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; } h3, h4, h5, h6 { margin-top: .8em; } @@ -114,7 +114,7 @@ pre { background: #4dd6f9; color: #0f0f0e; margin-bottom: 1em; - font-family: monospace, Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; + font-family: monospace, Arial, KaiTi, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; overflow-x: auto; } From 2bf55027815cbc847bb6b6b99edb8254cac6dd2a Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Thu, 5 Feb 2015 08:31:51 +0800 Subject: [PATCH 16/19] =?UTF-8?q?=E5=8F=AA=E6=9C=89=20title=20=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=A5=B7=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pelican/themes/notmyidea/static/css/main.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index d981241a..224b0199 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -19,7 +19,7 @@ body { background: #F5F4EF; color: #000305; font-size: 87.5%; /* Base font size: 14px */ - font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, KaiTi, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; + font-family: 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; line-height: 1.429; margin: 0; padding: 0; @@ -114,7 +114,7 @@ pre { background: #4dd6f9; color: #0f0f0e; margin-bottom: 1em; - font-family: monospace, Arial, KaiTi, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; + font-family: monospace, Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; overflow-x: auto; } From b1973f3bd793e9fedfa41ae5fd39781f94cc791d Mon Sep 17 00:00:00 2001 From: Zhongwei Sun Date: Thu, 5 Feb 2015 10:37:15 +0800 Subject: [PATCH 17/19] update --- pelican/themes/notmyidea/static/css/main.css | 9 ++++++--- pelican/themes/notmyidea/templates/article_infos.html | 6 +++--- pelican/themes/notmyidea/templates/index.html | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pelican/themes/notmyidea/static/css/main.css b/pelican/themes/notmyidea/static/css/main.css index 224b0199..e37918bc 100644 --- a/pelican/themes/notmyidea/static/css/main.css +++ b/pelican/themes/notmyidea/static/css/main.css @@ -10,7 +10,9 @@ /* Imports */ @import url("reset.css"); +/* @import url("pygment.css"); +*/ @import url("typogrify.css"); /***** Global *****/ @@ -99,7 +101,8 @@ li { margin-top: 0.5em;} margin-bottom: 1px; } -.readmore { float: right } +.readmore { +} dl {margin: 0 0 1.5em 0;} dt {font-weight: bold;} @@ -111,8 +114,8 @@ pre { -webkit-border-radius: 5px; display: block; padding: 0.5em; - background: #4dd6f9; - color: #0f0f0e; + background: #001f3f; + color: hsla(210, 100%, 75%, 1.0); margin-bottom: 1em; font-family: monospace, Arial, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif; overflow-x: auto; diff --git a/pelican/themes/notmyidea/templates/article_infos.html b/pelican/themes/notmyidea/templates/article_infos.html index 718967e0..6ffd30a8 100644 --- a/pelican/themes/notmyidea/templates/article_infos.html +++ b/pelican/themes/notmyidea/templates/article_infos.html @@ -1,17 +1,17 @@