[rig3] r436 committed - Settings to enable sharing on FB, twitter. Disabled by default.

2 views
Skip to first unread message

ri...@googlecode.com

unread,
Feb 14, 2010, 2:15:17 AM2/14/10
to rig3-d...@googlegroups.com
Revision: 436
Author: ralfoide
Date: Sat Feb 13 23:14:18 2010
Log: Settings to enable sharing on FB, twitter. Disabled by default.
http://code.google.com/p/rig3/source/detail?r=436

Modified:
/trunk/rig3serv/src/rig/sites_settings.py
/trunk/rig3serv/src/rig/version.py
/trunk/rig3serv/src/tests/z_last/test_rig3_live.py
/trunk/rig3serv/templates/default/html_entry.html
/trunk/rig3serv/testdata/z_last_rig3_live.rc

=======================================
--- /trunk/rig3serv/src/rig/sites_settings.py Sat Feb 13 22:51:03 2010
+++ /trunk/rig3serv/src/rig/sites_settings.py Sat Feb 13 23:14:18 2010
@@ -220,6 +220,7 @@
syntax (especially the named regex groups).
- dup_on_realpath(bool): When true, use real path of source entries to
de-dup
*regardless* of the various source settings.
+ - enable_sharing(bool): When true, add links to share posts to
Facebook, twitter, etc.
"""
def __init__(self,
public_name="",
@@ -259,20 +260,18 @@
</object>""",
youtube_sx="640",
youtube_sy="385",
+ enable_sharing=False
):
+ # Note: this is *always* called using the default values defined
in the
+ # constructor. If you need to change a setting loaded from an RC
file,
+ # use SetFinished() instead.
self.public_name = public_name
self.source_list = source_list or []
self.dest_dir = dest_dir
self.cache_dir = cache_dir
self.theme = theme
self.template_dir = template_dir
-
- # We automatically add a / to the base_url if it needs to.
- # A rare case where this might be unwanted is in case the URL has
cgi params.
- if base_url and not base_url.endswith("/") and not "?" in base_url:
- base_url += "/"
self.base_url = base_url
-
self.rig_album_url = rig_album_url
self.rig_img_url = rig_img_url
self.rig_thumb_url = rig_thumb_url
@@ -302,6 +301,7 @@
self.youtube_html = youtube_html
self.youtube_sx = youtube_sx
self.youtube_sy = youtube_sy
+ self.enable_sharing = self.ParseBool(enable_sharing)

def AsDict(self):
"""
@@ -343,6 +343,18 @@
(key, type(value), type(new_value) ))
self.__dict__[key] = value

+ def SetFinished(self):
+ """
+ Called once all settings have been set using Set(). This gives us
+ a last chance to edit/correct/check some settings.
+ """
+ # We automatically add a / to the base_url if it needs to.
+ # A rare case where this might be unwanted is in case the URL has
cgi params.
+ if self.base_url and \
+ not self.base_url.endswith("/") and \
+ not "?" in self.base_url:
+ self.base_url += "/"
+
def ParseBool(self, value):
"""
Parses a value and interprets it as a boolean.
@@ -417,6 +429,7 @@
for k in settings.__dict__.iterkeys():
if k in vars:
settings.Set(k, vars[k])
+ settings.SetFinished()

def _ProcessSources(self, settings, vars):
"""
=======================================
--- /trunk/rig3serv/src/rig/version.py Fri Feb 12 09:06:49 2010
+++ /trunk/rig3serv/src/rig/version.py Sat Feb 13 23:14:18 2010
@@ -13,7 +13,7 @@
To enable substitutions, do something like this:
$ svn propset svn:keywords "Date Author Revision HeadURL Id" version.py

-----
+-----

Part of Rig3.
Copyright (C) 2007-2009 ralfoide gmail com
=======================================
--- /trunk/rig3serv/src/tests/z_last/test_rig3_live.py Sat Feb 13 22:51:03
2010
+++ /trunk/rig3serv/src/tests/z_last/test_rig3_live.py Sat Feb 13 23:14:18
2010
@@ -96,6 +96,9 @@
# empty posts are accepted
self.assertHtmlSearch('<td class="title">\s*<a name="Empty-Post"
title="Permalink to \'Empty Post\'"><a
href="post_2007-10-01_Empty-Post.html" title="Permalink to \'Empty
Post\'"><span class="date">2007/10/01</span>Empty Post</a></a></td></tr>',
index_izu)
+ # the live test site has sharing enabled (default is off)
+
self.assertHtmlSearch('href="http://www.facebook.com/sharer.php\?u=http://www.example.alfray.com/cat/videos/post_',
+ index_izu)

=======================================
--- /trunk/rig3serv/templates/default/html_entry.html Sat Feb 13 22:51:03
2010
+++ /trunk/rig3serv/templates/default/html_entry.html Sat Feb 13 23:14:18
2010
@@ -37,6 +37,7 @@
[[if "author" in tags]]by [[html tags["author"].capitalize() ]][[end]]
[[if categories]]in [[html ", ".join([c.capitalize() for c in
categories])]][[end]]

+[[if enable_sharing]]
<span style="float:right">
<!-- Reader & Buzz -->
<a href="http://www.google.com/reader/link?title=[[url title]]&url=[[url
abs_permalink_url]]"
@@ -57,8 +58,8 @@
title="Share on Twitter: [[html title]]"
target="_blank" rel="nofollow external"
><img src="[[url rel_base_url]]media/fav_twitter.gif" title="Share on
Twitter: [[html title]]" border="0" /></a>
-
</span>
+[[end]]
</div>

[[if "en" in sections]]
=======================================
--- /trunk/rig3serv/testdata/z_last_rig3_live.rc Sat Feb 13 22:51:03 2010
+++ /trunk/rig3serv/testdata/z_last_rig3_live.rc Sat Feb 13 23:14:18 2010
@@ -36,3 +36,4 @@
tracking_code = <i>tracking code here</i>
toc_categories = !foo
reverse_categories = bar
+enable_sharing = true

Reply all
Reply to author
Forward
0 new messages