Skip to content

Commit 4534be1

Browse files
committed
wishlist, plugin update
1 parent 64f7a57 commit 4534be1

File tree

4 files changed

+51
-24
lines changed

4 files changed

+51
-24
lines changed

content/pages/wishlist.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ url: wishlist/
88
## Всякое разное
99

1010
* Хорошая сумка для походной аптечки (гермомешок, внутри несессер с трёмя секциями, что то вроде Deuter First Aid Kit Dry M)
11+
* Торцевая разделочная доска (например [доска от mtmwood](http://mtmwood.com/serial.php))
1112
* Велоперчатки Pearl iZUMi Mens ELITE Gel-Vent размер M
1213
* Трекинговый рюкзак Deuter Aircontact PRO 70+15
1314
* Самонадувающийся коврик Thermarest PROLITE REGULAR 183х51

fabfile.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
DEPLOY_PATH = env.deploy_path
1212

1313
# Remote server configuration
14-
production = 'lib@libc6.org:22'
15-
dest_path = '/var/www/lib/libc6.org/public'
14+
production = 'www-data@libc6.org:22'
15+
dest_path = '/var/www/libc6.org/public'
1616

1717
# Rackspace Cloud Files configuration settings
1818

plugins/neighbors/Readme.rst

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Usage
3636
</a>
3737
</li>
3838
{% endif %}
39-
{% if article.next_article %}
39+
{% if article.next_article_in_category %}
4040
<li>
4141
<a href="{{ SITEURL }}/{{ article.next_article_in_category.url}}">
4242
{{ article.next_article_in_category.title }}
@@ -63,17 +63,17 @@ Therefor the usage with subcategories is:
6363
.. code-block:: html+jinja
6464

6565
<ul>
66-
{% if article.prev_article_subcategory1 %}
66+
{% if article.prev_article_in_subcategory1 %}
6767
<li>
6868
<a href="{{ SITEURL }}/{{ article.prev_article_in_subcategory1.url}}">
6969
{{ article.prev_article_in_subcategory1.title }}
7070
</a>
7171
</li>
7272
{% endif %}
73-
{% if article.next_article %}
73+
{% if article.next_article_in_subcategory1 %}
7474
<li>
75-
<a href="{{ SITEURL }}/{{ article.next_article_subcategory1.url}}">
76-
{{ article.next_article_subcategory1.title }}
75+
<a href="{{ SITEURL }}/{{ article.next_article_in_subcategory1.url}}">
76+
{{ article.next_article_in_subcategory1.title }}
7777
</a>
7878
</li>
7979
{% endif %}
@@ -86,7 +86,7 @@ Therefor the usage with subcategories is:
8686
</a>
8787
</li>
8888
{% endif %}
89-
{% if article.next_article %}
89+
{% if article.next_article_in_subcategory2 %}
9090
<li>
9191
<a href="{{ SITEURL }}/{{ article.next_article_in_subcategory2.url}}">
9292
{{ article.next_article_in_subcategory2.title }}

plugins/sitemap/sitemap.py

+42-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# -*- coding: utf-8 -*-
1+
# -*- coding: utf-8 -*-
22
'''
33
Sitemap
44
-------
@@ -8,12 +8,14 @@
88

99
from __future__ import unicode_literals
1010

11+
import re
1112
import collections
1213
import os.path
1314

1415
from datetime import datetime
1516
from logging import warning, info
1617
from codecs import open
18+
from pytz import timezone
1719

1820
from pelican import signals, contents
1921
from pelican.utils import get_date
@@ -46,7 +48,7 @@
4648

4749
def format_date(date):
4850
if date.tzinfo:
49-
tz = date.strftime('%s')
51+
tz = date.strftime('%z')
5052
tz = tz[:-2] + ':' + tz[-2:]
5153
else:
5254
tz = "-00:00"
@@ -61,6 +63,11 @@ def __init__(self, context, settings, path, theme, output_path, *null):
6163
self.now = datetime.now()
6264
self.siteurl = settings.get('SITEURL')
6365

66+
67+
self.default_timezone = settings.get('TIMEZONE', 'UTC')
68+
self.timezone = getattr(self, 'timezone', self.default_timezone)
69+
self.timezone = timezone(self.timezone)
70+
6471
self.format = 'xml'
6572

6673
self.changefreqs = {
@@ -75,6 +82,8 @@ def __init__(self, context, settings, path, theme, output_path, *null):
7582
'pages': 0.5
7683
}
7784

85+
self.sitemapExclude = []
86+
7887
config = settings.get('SITEMAP', {})
7988

8089
if not isinstance(config, dict):
@@ -83,6 +92,7 @@ def __init__(self, context, settings, path, theme, output_path, *null):
8392
fmt = config.get('format')
8493
pris = config.get('priorities')
8594
chfreqs = config.get('changefreqs')
95+
self.sitemapExclude = config.get('exclude', [])
8696

8797
if fmt not in ('xml', 'txt'):
8898
warning("sitemap plugin: SITEMAP['format'] must be `txt' or `xml'")
@@ -128,15 +138,19 @@ def write_url(self, page, fd):
128138
if getattr(page, 'status', 'published') != 'published':
129139
return
130140

131-
page_path = os.path.join(self.output_path, page.url)
141+
# We can disable categories/authors/etc by using False instead of ''
142+
if not page.save_as:
143+
return
144+
145+
page_path = os.path.join(self.output_path, page.save_as)
132146
if not os.path.exists(page_path):
133147
return
134148

135149
lastdate = getattr(page, 'date', self.now)
136150
try:
137151
lastdate = self.get_date_modified(page, lastdate)
138152
except ValueError:
139-
warning("sitemap plugin: " + page.url + " has invalid modification date,")
153+
warning("sitemap plugin: " + page.save_as + " has invalid modification date,")
140154
warning("sitemap plugin: using date value as lastmod.")
141155
lastmod = format_date(lastdate)
142156

@@ -150,25 +164,35 @@ def write_url(self, page, fd):
150164
pri = self.priorities['indexes']
151165
chfreq = self.changefreqs['indexes']
152166

153-
167+
pageurl = '' if page.url == 'index.html' else page.url
168+
169+
#Exclude URLs from the sitemap:
154170
if self.format == 'xml':
155-
fd.write(XML_URL.format(self.siteurl, page.url, lastmod, chfreq, pri))
171+
flag = False
172+
for regstr in self.sitemapExclude:
173+
if re.match(regstr, pageurl):
174+
flag = True
175+
break
176+
if not flag:
177+
fd.write(XML_URL.format(self.siteurl, pageurl, lastmod, chfreq, pri))
156178
else:
157-
fd.write(self.siteurl + '/' + loc + '\n')
179+
fd.write(self.siteurl + '/' + pageurl + '\n')
158180

159-
def get_date_modified(self, page, defalut):
181+
def get_date_modified(self, page, default):
160182
if hasattr(page, 'modified'):
161-
return get_date(getattr(page, 'modified'))
183+
if isinstance(page.modified, datetime):
184+
return page.modified
185+
return get_date(page.modified)
162186
else:
163-
return defalut
187+
return default
164188

165189
def set_url_wrappers_modification_date(self, wrappers):
166190
for (wrapper, articles) in wrappers:
167-
lastmod = datetime.min
191+
lastmod = datetime.min.replace(tzinfo=self.timezone)
168192
for article in articles:
169-
lastmod = max(lastmod, article.date)
193+
lastmod = max(lastmod, article.date.replace(tzinfo=self.timezone))
170194
try:
171-
modified = self.get_date_modified(article, datetime.min);
195+
modified = self.get_date_modified(article, datetime.min).replace(tzinfo=self.timezone)
172196
lastmod = max(lastmod, modified)
173197
except ValueError:
174198
# Supressed: user will be notified.
@@ -186,7 +210,7 @@ def generate_output(self, writer):
186210
self.set_url_wrappers_modification_date(self.context['categories'])
187211
self.set_url_wrappers_modification_date(self.context['tags'])
188212
self.set_url_wrappers_modification_date(self.context['authors'])
189-
213+
190214
for article in self.context['articles']:
191215
pages += article.translations
192216

@@ -202,15 +226,17 @@ def generate_output(self, writer):
202226
FakePage = collections.namedtuple('FakePage',
203227
['status',
204228
'date',
205-
'url'])
229+
'url',
230+
'save_as'])
206231

207232
for standard_page_url in ['index.html',
208233
'archives.html',
209234
'tags.html',
210235
'categories.html']:
211236
fake = FakePage(status='published',
212237
date=self.now,
213-
url=standard_page_url)
238+
url=standard_page_url,
239+
save_as=standard_page_url)
214240
self.write_url(fake, fd)
215241

216242
for page in pages:

0 commit comments

Comments
 (0)