Permalink
Browse files

Merge remote-tracking branch 'upstream/master' into import-cleanup

Conflicts:
	r2/r2/config/templates.py
	r2/r2/controllers/__init__.py
	r2/r2/controllers/api.py
	r2/r2/controllers/errors.py
	r2/r2/controllers/front.py
	r2/r2/controllers/promotecontroller.py
	r2/r2/controllers/validator/validator.py
	r2/r2/lib/app_globals.py
	r2/r2/lib/pages/pages.py
	r2/r2/lib/utils/utils.py
	r2/r2/models/builder.py
	r2/r2/models/listing.py
	r2/r2/models/modaction.py
	r2/r2/models/query_cache.py
	r2/r2/models/subreddit.py
	r2/r2/models/vote.py

merge and update the files in wiki changes to meet new standards
  • Loading branch information...
2 parents 25155c2 + 5c8f678 commit baddb7d0405527f1ba34bfd9050ca306fff8d5e4 @kkress committed Sep 9, 2012
Showing with 2,965 additions and 364 deletions.
  1. +22 −5 r2/example.ini
  2. +17 −2 r2/r2/config/environment.py
  3. +5 −2 r2/r2/config/middleware.py
  4. +97 −0 r2/r2/config/queues.py
  5. +20 −2 r2/r2/config/routing.py
  6. +5 −0 r2/r2/config/templates.py
  7. +3 −12 r2/r2/controllers/__init__.py
  8. +114 −61 r2/r2/controllers/api.py
  9. +4 −2 r2/r2/controllers/error.py
  10. +14 −5 r2/r2/controllers/errors.py
  11. +21 −14 r2/r2/controllers/front.py
  12. +0 −2 r2/r2/controllers/promotecontroller.py
  13. +3 −1 r2/r2/controllers/reddit_base.py
  14. +2 −1 r2/r2/controllers/validator/__init__.py
  15. +4 −2 r2/r2/controllers/validator/validator.py
  16. +313 −0 r2/r2/controllers/validator/wiki.py
  17. +319 −0 r2/r2/controllers/wiki.py
  18. +16 −25 r2/r2/lib/amqp.py
  19. +9 −2 r2/r2/lib/app_globals.py
  20. +12 −8 r2/r2/lib/cssfilter.py
  21. +102 −2 r2/r2/lib/db/tdb_cassandra.py
  22. +0 −5 r2/r2/lib/emailer.py
  23. +43 −5 r2/r2/lib/filters.py
  24. +1 −0 r2/r2/lib/js.py
  25. +32 −1 r2/r2/lib/jsontemplates.py
  26. +3 −2 r2/r2/lib/lock.py
  27. +6 −0 r2/r2/lib/menus.py
  28. +78 −0 r2/r2/lib/merge.py
  29. +1 −0 r2/r2/lib/pages/__init__.py
  30. +68 −7 r2/r2/lib/pages/pages.py
  31. +165 −0 r2/r2/lib/pages/wiki.py
  32. +16 −5 r2/r2/lib/plugin.py
  33. +3 −1 r2/r2/lib/promote.py
  34. +0 −106 r2/r2/lib/queues.py
  35. +23 −7 r2/r2/lib/utils/utils.py
  36. +1 −0 r2/r2/models/__init__.py
  37. +6 −7 r2/r2/models/account.py
  38. +1 −1 r2/r2/models/award.py
  39. +3 −0 r2/r2/models/builder.py
  40. +26 −0 r2/r2/models/builders.py
  41. +4 −0 r2/r2/models/listing.py
  42. +0 −2 r2/r2/models/mail_queue.py
  43. +21 −4 r2/r2/models/modaction.py
  44. +1 −9 r2/r2/models/query_cache.py
  45. +118 −5 r2/r2/models/subreddit.py
  46. +17 −2 r2/r2/models/vote.py
  47. +369 −0 r2/r2/models/wiki.py
  48. +195 −1 r2/r2/public/static/css/reddit.css
  49. BIN r2/r2/public/static/house.png
  50. BIN r2/r2/public/static/icons/report.png
  51. +13 −1 r2/r2/public/static/js/analytics.js
  52. +1 −0 r2/r2/public/static/js/base.js
  53. +4 −4 r2/r2/public/static/js/reddit.js
  54. +110 −0 r2/r2/public/static/js/wiki.js
  55. BIN r2/r2/public/static/page_white_copy.png
  56. BIN r2/r2/public/static/report.png
  57. +0 −22 r2/r2/templates/admin/__init__.py
  58. 0 r2/r2/templates/{admin → }/adminlinkinfo.html
  59. 0 r2/r2/templates/{admin → }/adminsidebar.html
  60. +53 −3 r2/r2/templates/createsubreddit.html
  61. 0 r2/r2/templates/{admin → }/details.html
  62. +11 −11 r2/r2/templates/messagecompose.html
  63. +2 −1 r2/r2/templates/printablebuttons.html
  64. +2 −2 r2/r2/templates/promotelinkform.html
  65. +6 −0 r2/r2/templates/subredditstylesheet.html
  66. +67 −0 r2/r2/templates/wikibasepage.html
  67. +1 −0 r2/r2/templates/{admin/admininfo.html → wikibasepage.xml}
  68. +49 −0 r2/r2/templates/wikieditpage.html
  69. +34 −0 r2/r2/templates/wikipagediscussions.html
  70. +42 −0 r2/r2/templates/wikipagelisting.html
  71. +27 −0 r2/r2/templates/wikipagerevisions.html
  72. +23 −0 r2/r2/templates/wikipagerevisions.xml
  73. +70 −0 r2/r2/templates/wikipagesettings.html
  74. +70 −0 r2/r2/templates/wikirevision.html
  75. +30 −0 r2/r2/templates/wikirevision.xml
  76. +44 −0 r2/r2/templates/wikiview.html
  77. +1 −0 r2/r2/tests/functional/test_imports.py
  78. +2 −2 r2/setup.py
View
@@ -35,8 +35,6 @@ log_start = true
amqp_logging = false
# emergency measures: makes the site read only
read_only_mode = false
-# global switch for wiki write permissions
-allow_wiki_editing = true
# a modified read only mode used for cache shown during heavy load 503s
heavy_load_mode = false
# directory to write cProfile stats dumps to (disabled if not set)
@@ -424,9 +422,6 @@ ADMIN_COOKIE_MAX_IDLE = 900
# the maximum life of an otp cookie
OTP_COOKIE_TTL = 604800
-# min amount of karma to edit
-WIKI_KARMA = 100
-
# time in days
MODWINDOW = 2
HOT_PAGE_AGE = 1000
@@ -460,6 +455,8 @@ agents =
sr_banned_quota = 10000
sr_moderator_quota = 10000
sr_contributor_quota = 10000
+sr_wikibanned_quota = 10000
+sr_wikicontributor_quota = 10000
sr_quota_time = 7200
# -- email --
@@ -477,6 +474,26 @@ feedback_email = reddit@gmail.com
# Special case sensitive domains
case_sensitive_domains = i.imgur.com, youtube.com
+# Number of days to keep recent wiki revisions for
+wiki_keep_recent_days = 7
+
+# Max number of bytes for wiki pages
+wiki_max_page_length_bytes = 262144
+
+# Max wiki page name length
+wiki_max_page_name_length = 128
+
+# Max number of separators in a wiki page name
+wiki_max_page_separators = 3
+
+# Disable wiki editing and viewing for everyone except admins
+wiki_disabled = false
+
+# Location (directory) for temp files for diff3 merging
+# Empty will use python default for temp files
+# Pro tip: Use /dev/shm for in-memory diff3
+diff3_temp_location =
+
[server:main]
use = egg:Paste#http
host = 0.0.0.0
@@ -20,8 +20,8 @@
# Inc. All Rights Reserved.
###############################################################################
-import os
import mimetypes
+import os
from pylons import config
@@ -58,6 +58,7 @@ def load_environment(global_conf={}, app_conf={}, setup_globals=True):
template_engine='mako', paths=paths)
g = config['pylons.g'] = Globals(global_conf, app_conf, paths)
+ g.plugins.declare_queues(g.queues)
if setup_globals:
g.setup()
r2.config.cache = g.cache
@@ -82,7 +83,21 @@ def load_environment(global_conf={}, app_conf={}, setup_globals=True):
["from r2.lib.filters import websafe, unsafe, mako_websafe",
"from pylons import c, g, request",
"from pylons.i18n import _, ungettext"]
-
+
+ # when mako loads a previously compiled template file from its cache, it
+ # doesn't check that the original template path matches the current path.
+ # in the event that a new plugin defines a template overriding a reddit
+ # template, unless the mtime newer, mako doesn't update the compiled
+ # template. as a workaround, this makes mako store compiled templates with
+ # the original path in the filename, forcing it to update with the path.
+ def mako_module_path(filename, uri):
+ module_directory = tmpl_options['mako.module_directory']
+ filename = filename.lstrip('/').replace('/', '-')
+ path = os.path.join(module_directory, filename + ".py")
+ return os.path.abspath(path)
+
+ tmpl_options['mako.modulename_callable'] = mako_module_path
+
# Add your own template options config options here,
# note that all config options will override
# any Pylons config options
@@ -67,7 +67,7 @@ def error_mapper(code, message, environ, global_conf=None, **kw):
if global_conf is None:
global_conf = {}
- codes = [304, 401, 403, 404, 429, 503]
+ codes = [304, 400, 401, 403, 404, 415, 429, 503]
if not asbool(global_conf.get('debug')):
codes.append(500)
if code in codes:
@@ -77,7 +77,10 @@ def error_mapper(code, message, environ, global_conf=None, **kw):
exception = environ.get('r2.controller.exception')
if exception:
d['explanation'] = exception.explanation
-
+ error_data = getattr(exception, 'error_data', None)
+ if error_data:
+ environ['extra_error_data'] = error_data
+
if environ.get('REDDIT_CNAME'):
d['cnameframe'] = 1
if environ.get('REDDIT_NAME'):
View
@@ -0,0 +1,97 @@
+# The contents of this file are subject to the Common Public Attribution
+# License Version 1.0. (the "License"); you may not use this file except in
+# compliance with the License. You may obtain a copy of the License at
+# http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
+# License Version 1.1, but Sections 14 and 15 have been added to cover use of
+# software over a computer network and provide for limited attribution for the
+# Original Developer. In addition, Exhibit A has been modified to be consistent
+# with Exhibit B.
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
+# the specific language governing rights and limitations under the License.
+#
+# The Original Code is reddit.
+#
+# The Original Developer is the Initial Developer. The Initial Developer of
+# the Original Code is reddit Inc.
+#
+# All portions of the code written by reddit are Copyright (c) 2006-2012 reddit
+# Inc. All Rights Reserved.
+###############################################################################
+
+from r2.lib.export import export
+from r2.lib.utils import tup
+
+__all__ = [
+ #Constants Only, use @export for functions/classes
+ ]
+
+
+class Queues(dict):
+ """A container for queue declarations."""
+ def __init__(self, queues):
+ dict.__init__(self)
+ self.__dict__ = self
+ self.bindings = set()
+ self.declare(queues)
+
+ def __iter__(self):
+ for name, queue in self.iteritems():
+ if name != "bindings":
+ yield queue
+
+ def declare(self, queues):
+ for name, queue in queues.iteritems():
+ queue.name = name
+ queue.bindings = self.bindings
+ if queue.bind_to_self:
+ queue._bind(name)
+ self.update(queues)
+
+
+@export
+class MessageQueue(object):
+ """A representation of an AMQP message queue.
+
+ This class is solely intended for use with the Queues class above.
+
+ """
+ def __init__(self, durable=True, exclusive=False,
+ auto_delete=False, bind_to_self=False):
+ self.durable = durable
+ self.exclusive = exclusive
+ self.auto_delete = auto_delete
+ self.bind_to_self = bind_to_self
+
+ def _bind(self, routing_key):
+ self.bindings.add((self.name, routing_key))
+
+ def __lshift__(self, routing_keys):
+ """Register bindings from routing keys to this queue."""
+ routing_keys = tup(routing_keys)
+ for routing_key in routing_keys:
+ self._bind(routing_key)
+
+
+@export
+def declare_queues():
+ queues = Queues({
+ "scraper_q": MessageQueue(),
+ "newcomments_q": MessageQueue(),
+ "commentstree_q": MessageQueue(),
+ "commentstree_fastlane_q": MessageQueue(),
+ "vote_link_q": MessageQueue(bind_to_self=True),
+ "vote_comment_q": MessageQueue(bind_to_self=True),
+ "vote_fastlane_q": MessageQueue(bind_to_self=True),
+ "log_q": MessageQueue(bind_to_self=True),
+ "usage_q": MessageQueue(bind_to_self=True, durable=False),
+ "cloudsearch_changes": MessageQueue(bind_to_self=True),
+ })
+
+ queues.cloudsearch_changes << "search_changes"
+ queues.scraper_q << "new_link"
+ queues.newcomments_q << "new_comment"
+ queues.commentstree_q << "new_comment"
+ queues.commentstree_fastlane_q << "new_fastlane_comment"
+ return queues
View
@@ -30,7 +30,7 @@ def make_map():
map = Mapper()
mc = map.connect
- for plugin in config['r2.plugins']:
+ for plugin in reversed(config['r2.plugins']):
plugin.add_routes(mc)
mc('/admin/', controller='awards')
@@ -184,7 +184,25 @@ def make_map():
mc('/:action', controller='embed',
requirements=dict(action="help|blog|faq"))
mc('/help/*anything', controller='embed', action='help')
-
+
+ mc('/wiki/create/*page', controller='wiki', action='wiki_create')
+ mc('/wiki/edit/*page', controller='wiki', action='wiki_revise')
+ mc('/wiki/revisions/*page', controller='wiki', action='wiki_revisions')
+ mc('/wiki/settings/*page', controller='wiki', action='wiki_settings')
+ mc('/wiki/discussions/*page', controller='wiki', action='wiki_discussions')
+ mc('/wiki/revisions', controller='wiki', action='wiki_recent')
+ mc('/wiki/pages', controller='wiki', action='wiki_listing')
+
+ mc('/wiki/api/edit/*page', controller='wikiapi', action='wiki_edit')
+ mc('/wiki/api/hide/:revision/*page', controller='wikiapi', action='wiki_revision_hide')
+ mc('/wiki/api/revert/:revision/*page', controller='wikiapi', action='wiki_revision_revert')
+ mc('/wiki/api/alloweditor/:act/:username/*page', controller='wikiapi', action='wiki_allow_editor')
+
+ mc('/wiki/*page', controller='wiki', action='wiki_page')
+ mc('/wiki/', controller='wiki', action='wiki_page')
+
+ mc('/w/*page', controller='wiki', action='wiki_redirect')
+
mc('/goto', controller='toolbar', action='goto')
mc('/tb/:id', controller='toolbar', action='tb')
mc('/toolbar/:action', controller='toolbar',
@@ -56,6 +56,11 @@ def api(type, cls):
api('subreddittraffic', jtmpl.TrafficJsonTemplate)
api('takedownpane', jtmpl.TakedownJsonTemplate)
+api('wikibasepage', jtmpl.WikiJsonTemplate)
+api('wikipagerevisions', jtmpl.WikiJsonTemplate)
+api('wikiview', jtmpl.WikiViewJsonTemplate)
+api('wikirevision', jtmpl.WikiRevisionJsonTemplate)
+
api('flairlist', jtmpl.FlairListJsonTemplate)
api('flaircsv', jtmpl.FlairCsvJsonTemplate)
@@ -70,18 +70,9 @@ def load_controllers():
from r2.controllers.front import FrontController
from r2.controllers.health import HealthController
from r2.controllers.buttons import ButtonsController
- from r2.controllers.captcha import CaptchaController
- from r2.controllers.embed import EmbedController
- from r2.controllers.error import ErrorController
- from r2.controllers.post import PostController
- from r2.controllers.toolbar import ToolbarController
- from r2.controllers.awards import AwardsController
- from r2.controllers.ads import AdsController
- from r2.controllers.usage import UsageController
- from r2.controllers.errorlog import ErrorlogController
- from r2.controllers.promotecontroller import PromoteController
- from r2.controllers.mediaembed import MediaembedController
- from r2.controllers.mediaembed import AdController
+
+ from r2.controllers.wiki import WikiController
+ from r2.controllers.wiki import WikiApiController
from r2.controllers.querycontroller import QueryController
Oops, something went wrong.

0 comments on commit baddb7d

Please sign in to comment.