if re.match(mail_re, link, re.I):
return 'mailto:' + link
elif re.match(url_re, link, re.I):
- return 'http://' + link
+ return 'https://' + link
return None
# find out our URL, needed for syndication
try:
n = os.environ['SERVER_NAME']
- p = os.environ['SERVER_PORT']
+ # Removed port because it messes up when behind a proxy
+ #p = os.environ['SERVER_PORT']
s = os.environ['SCRIPT_NAME']
- if p == '80': p = ''
- else: p = ':' + p
- full_url = 'http://%s%s%s' % (n, p, s)
+ #if p == '80': p = ''
+ #else: p = ':' + p
+ full_url = 'https://%s%s' % (n, s)
except KeyError:
full_url = 'Not needed'
import re
rst = re.sub(r'.. youtube:: (.*)', r'''.. raw:: html
- <div style="text-align: center; margin-bottom: 8pt">
- <object width="500" height="375">
- <param name="movie"
- value="http://www.youtube.com/v/\1&hl=en&fs=1"
- ></param>
- <param name="allowFullScreen" value="true"></param>
- <param name="allowscriptaccess" value="always"></param>
- <embed src="http://www.youtube.com/v/\1&hl=en&fs=1"
- type="application/x-shockwave-flash" allowscriptaccess="always"
- allowfullscreen="true" width="500" height="375"></embed>
- </object>
- </div>''', rst)
+ <iframe width="560" height="315"
+ src="https://www.youtube.com/embed/\1"
+ frameborder="0" allowfullscreen></iframe>
+ ''', rst)
rst = re.sub(r'.. vimeo:: (\w*)', r'''.. raw:: html
- <div style="text-align: center; margin-bottom: 8pt">
- <object width="500" height="375">
- <param name="allowfullscreen" value="true" />
- <param name="allowscriptaccess" value="always" />
- <param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=\1&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00ADEF&fullscreen=1" />
- <embed src="http://vimeo.com/moogaloop.swf?clip_id=\1&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00ADEF&fullscreen=1"
- type="application/x-shockwave-flash"
- allowfullscreen="true"
- allowscriptaccess="always"
- width="500"
- height="375">
- </embed>
- </object>
- </div>''', rst)
+ <iframe src="https://player.vimeo.com/video/\1"
+ width="500" height="281" frameborder="0"
+ webkitallowfullscreen mozallowfullscreen
+ allowfullscreen></iframe>
+ ''', rst)
rst = re.sub(r'.. grooveshark:: (\w*)', r'''.. raw:: html
- <div class="grooveshark">
- <object width="220" height="300">
- <param name="movie"
- value="http://listen.grooveshark.com/widget.swf" />
- <param name="wmode" value="window" />
- <param name="allowScriptAccess" value="always" />
- <param name="flashvars"
- value="hostname=cowbell.grooveshark.com&playlistID=\1&style=metal&p=0" />
- <embed src="http://listen.grooveshark.com/widget.swf"
- type="application/x-shockwave-flash"
- width="220" height="300"
- flashvars="hostname=cowbell.grooveshark.com&playlistID=\1&style=metal&p=0"
- allowScriptAccess="always" wmode="window" />
- </object>
- </div>''', rst)
+ Grooveshark is no more! This was supposed to show \1.
+ ''', rst)
return rst_to_html(rst)
def to_vars(self):
'uuid': self.uuid,
'tags': self.get_tags_links(),
'comments': len(self.comments),
- 'flattrbtn': self.get_flattr_btn(),
'created': self.created.isoformat(' '),
'ciso': self.created.isoformat(),
(blog_url, urllib.quote(t), sanitize(t) ))
return ', '.join(l)
- def get_flattr_btn(self):
- v = dict()
- v['tags'] = ','.join([sanitize(tag) for tag in self.tags])
- v['tags'] = v['tags'].replace('"', '-').replace(':', '-')
- v['tags'] = v['tags'].replace(';', '-')
- v['title'] = sanitize(self.title)
- v['qtitle'] = title.replace('"', '')
- v['url'] = full_url + '/post/' + self.uuid
- v['furl'] = 'https://flattr.com/submit/auto?' + urllib.urlencode(
- dict(user_id='llucax', url=v['url'],
- title=self.title,
- description="Blog article titled: " +
- self.title,
- language='en', tags=','.join(self.tags),
- category='text'))
- return '''
-<a class="FlattrButton" style="display:none;"
- rel="flattr;uid:llucax;category:text;tags:%(tags)s;button:compact;"
- title="%(qtitle)s" lang="en"
- href="%(url)s">Blog article titled: %(title)s</a>
-<noscript><a href="%(furl)s" target="_blank">
- <img src="http://api.flattr.com/button/flattr-badge-large.png"
- alt="Flattr this" title="Flattr this" border="0" />
- </a>
-</noscript>
-''' % v
-
class ArticleDB (object):
def __init__(self, dbpath):