Anonymous avatar Anonymous committed 73f7a66

[svn] restoring the QuickWiki trunk from the latest release

Comments (0)

Files changed (38)

QuickWiki.egg-info/dependency_links.txt

+

QuickWiki.egg-info/entry_points.txt

+
+    [paste.app_factory]
+    main=quickwiki:make_app
+    [paste.app_install]
+    main=paste.script.appinstall:Installer
+    

QuickWiki.egg-info/paste_deploy_config.ini_tmpl

+#
+# QuickWiki - Pylons configuration
+#
+# The %(here)s variable will be replaced with the parent directory of this file
+#
+[DEFAULT]
+debug = true
+email_to = you@yourdomain.com
+smtp_server = localhost
+error_email_from = paste@localhost
+
+[server:main]
+use = egg:Paste#http
+host = 0.0.0.0
+port = 5000
+
+[app:main]
+use = egg:QuickWiki
+session_key = quickwiki
+session_secret = ${app_instance_secret}
+app_instance_uuid = ${app_instance_uuid}
+cache_dir = %(here)s/data
+
+# If you'd like to fine-tune the individual locations of the cache data dirs
+# for Myghty, the Cache data, or the Session saves, un-comment the desired
+# settings here:
+#myghty_data_dir = %(here)s/data/templates
+#cache_data_dir = %(here)s/data/cache
+#session_data_dir = %(here)s/data/sessions
+
+# Specify the database for SQLAlchemy to use via
+# pylons.database.session_context.
+# %(here) may include a ':' character on Windows environments; this can
+# invalidate the URI when specifying a SQLite db via path name
+sqlalchemy.dburi = postgres://username:password@localhost/quickwiki_test
+# Uncomment the line below to have SQLAlchemy echo SQL for debugging  
+#sqlalchemy.echo = true
+
+# Specify the database for SQLObject to use via pylons.database.PackageHub.
+#sqlobject.dburi = sqlite://%(here)s/somedb.db
+
+# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
+# Debug mode will enable the interactive debugging tool, allowing ANYONE to
+# execute malicious code after an exception is raised.
+set debug = false

QuickWiki.egg-info/paster_plugins.txt

+Pylons
+WebHelpers
+PasteScript

QuickWiki.egg-info/top_level.txt

+quickwiki
+This file is for you to describe the QuickWiki application. Typically
+you would include information such as the information below:
+
+Installation and Setup
+======================
+
+Install ``QuickWiki`` using easy_install::
+
+    easy_install QuickWiki
+
+Make a config file as follows::
+
+    paster make-config QuickWiki config.ini
+    
+Tweak the config file as appropriate and then setup the application::
+
+    paster setup-app config.ini
+    
+Then you are ready to go.
+#
+# QuickWiki - Pylons development environment configuration
+#
+# The %(here)s variable will be replaced with the parent directory of this file
+#
+[DEFAULT]
+debug = true
+email_to = you@yourdomain.com
+smtp_server = localhost
+error_email_from = paste@localhost
+
+[server:main]
+use = egg:Paste#http
+host = 0.0.0.0
+port = 5000
+
+[app:main]
+use = egg:QuickWiki
+session_key = quickwiki
+session_secret = somesecret
+cache_dir = %(here)s/data/cache
+
+# If you'd like to fine-tune the individual locations of the cache data dirs
+# for Myghty, the Cache data, or the Session saves, un-comment the desired
+# settings here:
+#myghty_data_dir = %(here)s/data/templates
+#cache_data_dir = %(here)s/data/cache
+#session_data_dir = %(here)s/data/sessions
+
+# Specify the database for SQLAlchemy to use via
+# pylons.database.session_context.
+# %(here) may include a ':' character on Windows environments; this can
+# invalidate the URI when specifying a SQLite db via path name
+sqlalchemy.dburi = postgres://@localhost/quickwiki_test
+# Uncomment the line below to have SQLAlchemy echo SQL for debugging  
+#sqlalchemy.echo = true
+
+# Specify the database for SQLObject to use via pylons.database.PackageHub.
+#sqlobject.dburi = sqlite://%(here)s/somedb.db
+
+# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
+# Debug mode will enable the interactive debugging tool, allowing ANYONE to
+# execute malicious code after an exception is raised.
+#set debug = false

quickwiki/__init__.py

+"""
+quickwiki
+
+This file loads the finished app from quickwiki.config.middleware.
+
+"""
+
+from quickwiki.config.middleware import make_app

quickwiki/config/__init__.py

+#

quickwiki/config/environment.py

+import os
+
+import pylons.config
+import webhelpers
+
+from quickwiki.config.routing import make_map
+
+def load_environment(global_conf={}, app_conf={}):
+    map = make_map(global_conf, app_conf)
+    # Setup our paths
+    root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+    paths = {'root_path': root_path,
+             'controllers': os.path.join(root_path, 'controllers'),
+             'templates': [os.path.join(root_path, path) for path in \
+                           ('components', 'templates')],
+             'static_files': os.path.join(root_path, 'public')
+             }
+    
+    # The following options are passed directly into Myghty, so all configuration options
+    # available to the Myghty handler are available for your use here
+    myghty = {}
+    myghty['log_errors'] = True
+    myghty['escapes'] = dict(l=webhelpers.auto_link, s=webhelpers.simple_format)
+    
+    # Add your own Myghty config options here, note that all config options will override
+    # any Pylons config options
+    
+    # Return our loaded config object
+    return pylons.config.Config(myghty, map, paths)

quickwiki/config/middleware.py

+from paste import httpexceptions
+from paste.cascade import Cascade
+from paste.urlparser import StaticURLParser
+from paste.registry import RegistryManager
+from paste.deploy.config import ConfigMiddleware, CONFIG
+from paste.deploy.converters import asbool
+
+from pylons.error import error_template
+from pylons.middleware import ErrorHandler, ErrorDocuments, StaticJavascripts, error_mapper
+import pylons.wsgiapp
+
+from quickwiki.config.environment import load_environment
+import quickwiki.lib.helpers
+import quickwiki.lib.app_globals as app_globals
+
+def make_app(global_conf, full_stack=True, **app_conf):
+    """Create a WSGI application and return it
+    
+    global_conf is a dict representing the Paste configuration options, the
+    paste.deploy.converters should be used when parsing Paste config options
+    to ensure they're treated properly.
+    
+    """
+    # Setup the Paste CONFIG object
+    CONFIG.push_process_config({'app_conf': app_conf,
+                                'global_conf': global_conf})
+
+    # Load our Pylons configuration defaults
+    config = load_environment(global_conf, app_conf)
+    config.init_app(global_conf, app_conf, package='quickwiki')
+        
+    # Load our default Pylons WSGI app and make g available
+    app = pylons.wsgiapp.PylonsApp(config, helpers=quickwiki.lib.helpers,
+                                   g=app_globals.Globals)
+    g = app.globals
+    app = ConfigMiddleware(app, {'app_conf':app_conf,
+        'global_conf':global_conf})
+    
+    # YOUR MIDDLEWARE
+    # Put your own middleware here, so that any problems are caught by the error
+    # handling middleware underneath
+    
+    # If errror handling and exception catching will be handled by middleware
+    # for multiple apps, you will want to set full_stack = False in your config
+    # file so that it can catch the problems.
+    if asbool(full_stack):
+        # Change HTTPExceptions to HTTP responses
+        app = httpexceptions.make_middleware(app, global_conf)
+    
+        # Error Handling
+        app = ErrorHandler(app, global_conf, error_template=error_template, **config.errorware)
+    
+        # Display error documents for 401, 403, 404 status codes (if debug is disabled also
+        # intercepts 500)
+        app = ErrorDocuments(app, global_conf, mapper=error_mapper, **app_conf)
+    
+    # Establish the Registry for this application
+    app = RegistryManager(app)
+    
+    static_app = StaticURLParser(config.paths['static_files'])
+    javascripts_app = StaticJavascripts()
+    app = Cascade([static_app, javascripts_app, app])
+    return app

quickwiki/config/routing.py

+"""
+Setup your Routes options here
+"""
+import os
+from routes import Mapper
+
+def make_map(global_conf={}, app_conf={}):
+    root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+    map = Mapper(directory=os.path.join(root_path, 'controllers'))
+    
+    # This route handles displaying the error page and graphics used in the 404/500
+    # error pages. It should likely stay at the top to ensure that the error page is
+    # displayed properly.
+    map.connect('error/:action/:id', controller='error')
+    
+    # Define your routes. The more specific and detailed routes should be defined first,
+    # so they may take precedent over the more generic routes. For more information, refer
+    # to the routes manual @ http://routes.groovie.org/docs/
+    map.connect(':controller/:action/:title', controller='page', action='index', title='FrontPage')
+    map.connect(':title', controller='page', action='index', title='FrontPage')
+    map.connect('*url', controller='template', action='view')
+
+    return map
Add a comment to this file

quickwiki/controllers/__init__.py

Empty file added.

quickwiki/controllers/error.py

+import os.path
+from paste import fileapp
+from pylons.middleware import media_path, error_document_template
+from pylons.util import get_prefix
+from quickwiki.lib.base import *
+
+class ErrorController(BaseController):
+    """
+    Class to generate error documents as and when they are required. This behaviour of this
+    class can be altered by changing the parameters to the ErrorDocuments middleware in 
+    your config/middleware.py file.
+    """
+
+    def document(self):
+        """
+        Change this method to change how error documents are displayed
+        """
+        page = error_document_template % {
+            'prefix': get_prefix(request.environ),
+            'code': request.params.get('code', ''),
+            'message': request.params.get('message', ''),
+        }
+        return Response(page)
+
+    def img(self, id):
+        return self._serve_file(os.path.join(media_path, 'img', id))
+        
+    def style(self, id):
+        return self._serve_file(os.path.join(media_path, 'style', id))
+
+    def _serve_file(self, path):
+        fapp = fileapp.FileApp(path)
+        return fapp(request.environ, self.start_response)

quickwiki/controllers/page.py

+from quickwiki.lib.base import *
+    
+class PageController(BaseController):
+
+    def __before__(self):
+        model.session_context.current.clear()
+
+    def index(self, title):
+        page = model.Page.get_by(title=title)
+        if page: 
+            c.content = page.get_wiki_content()
+            return render_response('/page.myt')
+        elif model.wikiwords.match(title):
+            return render_response('/new_page.myt')
+        abort(404)
+
+    def edit(self, title):
+        page = model.Page.get_by(title=title)
+        if page:
+            c.content = page.content
+        return render_response('/edit.myt')
+    
+    def save(self, title):
+        page = model.Page.get_by(title=title)
+        if not page:
+            page = model.Page()
+            page.title = title
+        page.content = request.params['content']
+        c.title = page.title
+        c.content = page.get_wiki_content()
+        c.message = 'Successfully saved'
+        page.flush()
+        return render_response('/page.myt')
+
+    def list(self):
+        c.titles = [page.title for page in model.Page.select()]
+        return render_response('/titles.myt')
+
+    def delete(self):
+        title = request.params['id'][5:]
+        page = model.Page.get_by(title=title)
+        page.delete()
+        page.flush()
+        c.titles = model.Page.select()
+        return render_response('/list.myt', fragment=True)

quickwiki/controllers/template.py

+from quickwiki.lib.base import *
+
+class TemplateController(BaseController):
+    def view(self, url):
+        """
+        This is the last place which is tried during a request to try to find a 
+        file to serve. It could be used for example to display a template::
+        
+            def view(self, url):
+                return render_response(url)
+        
+        Or, if you're using Myghty and would like to catch the component not
+        found error which will occur when the template doesn't exist; you
+        can use the following version which will provide a 404 if the template
+        doesn't exist::
+        
+            import myghty.exception
+            
+            def view(self, url):
+                try:
+                    return render_response('/'+url)
+                except myghty.exception.ComponentNotFound:
+                    return Response(code=404)
+        
+        The default is just to abort the request with a 404 File not found
+        status message.
+        """
+        abort(404)

quickwiki/docs/index.txt

+quickwiki
++++++++++
+
+This is the main index page of your documentation. It should be written in reStructuredText format.
+
+You can generate your documentation in HTML format by running this command::
+
+    setup.py pudge
+    
+For this to work you will need to download and install ``buildutils`` and ``pudge``.
+
Add a comment to this file

quickwiki/i18n/__init__.py

Empty file added.

Add a comment to this file

quickwiki/lib/__init__.py

Empty file added.

quickwiki/lib/app_globals.py

+class Globals(object):
+
+    def __init__(self, global_conf, app_conf, **extra):
+        """
+        Globals acts as a container for objects available throughout
+        the life of the application.
+
+        One instance of Globals is created by Pylons during
+        application initialization and is available during requests
+        via the 'g' variable.
+        
+        ``global_conf``
+            The same variable used throughout ``config/middleware.py``
+            namely, the variables from the ``[DEFAULT]`` section of the
+            configuration file.
+            
+        ``app_conf``
+            The same ``kw`` dictionary used throughout
+            ``config/middleware.py`` namely, the variables from the
+            section in the config file for your application.
+            
+        ``extra``
+            The configuration returned from ``load_config`` in 
+            ``config/middleware.py`` which may be of use in the setup of
+            your global variables.
+            
+        """
+        pass
+        
+    def __del__(self):
+        """
+        Put any cleanup code to be run when the application finally exits 
+        here.
+        """
+        pass

quickwiki/lib/base.py

+from pylons import Response, c, g, cache, request, session
+from pylons.controllers import WSGIController
+from pylons.decorators import jsonify, validate
+from pylons.templating import render, render_response
+from pylons.helpers import abort, redirect_to, etag_cache
+from pylons.i18n import N_, _, ungettext
+import quickwiki.models as model
+import quickwiki.lib.helpers as h
+
+class BaseController(WSGIController):
+    def __call__(self, environ, start_response):
+        # Insert any code to be run per request here. The Routes match
+        # is under environ['pylons.routes_dict'] should you want to check
+        # the action or route vars here
+        return WSGIController.__call__(self, environ, start_response)
+
+# Include the '_' function in the public names
+__all__ = [__name for __name in locals().keys() if not __name.startswith('_') \
+           or __name == '_']

quickwiki/lib/helpers.py

+"""
+Helper functions
+
+All names available in this module will be available under the Pylons h object.
+"""
+from webhelpers import *
+from pylons.helpers import log
+from pylons.i18n import get_lang, set_lang

quickwiki/models/__init__.py

+import re
+import sets
+from docutils.core import publish_parts
+from sqlalchemy import *
+from sqlalchemy.ext.assignmapper import assign_mapper
+from pylons.database import session_context
+import quickwiki.lib.helpers as h
+
+wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)")
+
+meta = DynamicMetaData()
+
+pages_table = Table('pages', meta,
+    Column('title', String(40), primary_key=True),
+    Column('content', String(), default='')
+)
+
+class Page(object):
+    content = None
+    
+    def __str__(self):
+        return self.title
+        
+    def get_wiki_content(self):
+        content = publish_parts(self.content, writer_name="html")["html_body"]
+        titles = sets.Set(wikiwords.findall(content))
+        for title in titles:
+            title_url = h.url_for(controller='page', action='index', 
+                                  title=title)
+            content = content.replace(title, h.link_to(title, title_url))
+        return content
+        
+page_mapper = assign_mapper(session_context, Page, pages_table)

quickwiki/public/quick.css

+body {
+	background-color: #888;
+	margin: 25px;
+}
+div.content{
+	margin: 0;
+	margin-bottom: 10px;
+	background-color: #d3e0ea;
+	border: 5px solid #333;
+	padding: 5px 25px 25px 25px;
+}
+h1.main{
+	width: 100%;
+	border-bottom: 1px solid #000;
+}
+p.footer{
+	width: 100%;
+	padding-top: 3px;
+	border-top: 1px solid #000;
+}
+div#message{
+	color: orangered;
+}
+div#trash{
+	float: right;
+	margin: 0px 20px 20px 20px;
+	background: #eee;
+	border: 1px solid #000;
+	padding: 15px;
+}

quickwiki/templates/autohandler

+<html>
+<head>
+<title>QuickWiki</title>
+<% h.stylesheet_link_tag('/quick.css') %>
+<% h.javascript_include_tag('/javascripts/effects.js', builtins=True)  %>
+</head>
+<body>
+<div class="content">
+% m.call_next()
+<p class="footer">
+    Return to the <% h.link_to('FrontPage', h.url_for(action="index", title="FrontPage")) %>
+% if h.url_for() != '/page/list':
+    | <% h.link_to('Edit '+c.title, h.url_for(title=c.title, action='edit')) %>
+    | <% h.link_to('Title List', h.url_for(action='list', title=None)) %>
+% # end if
+</p>
+</div>
+</body>
+</html>

quickwiki/templates/edit.myt

+<h1 class="main">Editing <% c.title %></h1>
+
+<% h.start_form(h.url_for(action='save', title=c.title),method="post") %>
+    <% h.text_area(name='content', rows=7, cols=40, content=c.content)%> <br /> 
+    <% h.submit(value="Save changes", name='commit') %>
+<% h.end_form() %>

quickwiki/templates/list.myt

+% for title in c.titles:
+<li>
+    <span id="page-<% title %>"><% title %></span>&nbsp;[<% h.link_to('visit', h.url_for(title=title, action="index")) %>]
+    <% h.draggable_element("page-"+ str(title), revert=True) %>
+</li>
+% #end for

quickwiki/templates/new_page.myt

+<h1 class="main"><% c.title %></h1>
+<p>This page doesn't exist yet. 
+   <a href="<% h.url_for(action='edit', title=c.title) %>">Create the page</a>.</p>

quickwiki/templates/page.myt

+<h1 class="main"><% c.title %></h1>
+% if c.message:
+<p><div id="message"><% c.message %></div></p>
+% #end if
+<% c.content %>

quickwiki/templates/titles.myt

+<h1 class="main">Title List</h1>
+<div id="trash">
+    Delete a page by dragging its title here
+</div>
+<% h.drop_receiving_element("trash", update="titles", url=h.url_for(action="delete")) %>
+<ul id="titles">
+<% render('/list.myt', fragment=True) %>
+</ul>

quickwiki/tests/__init__.py

+import os
+import sys
+from unittest import TestCase
+
+here_dir = os.path.dirname(os.path.abspath(__file__))
+conf_dir = os.path.dirname(os.path.dirname(here_dir))
+
+sys.path.insert(0, conf_dir)
+
+import pkg_resources
+
+pkg_resources.working_set.add_entry(conf_dir)
+
+pkg_resources.require('Paste')
+pkg_resources.require('PasteScript')
+
+from paste.deploy import loadapp, CONFIG
+import paste.deploy
+import paste.fixture
+import paste.script.appinstall
+
+from quickwiki.config.routing import *
+from routes import request_config, url_for
+
+test_file = os.path.join(conf_dir, 'test.ini')
+conf = paste.deploy.appconfig('config:' + test_file)
+CONFIG.push_process_config({'app_conf': conf.local_conf,
+                            'global_conf': conf.global_conf}) 
+
+cmd = paste.script.appinstall.SetupCommand('setup-app')
+cmd.run([test_file])
+
+class TestController(TestCase):
+    def __init__(self, *args):
+        wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
+        self.app = paste.fixture.TestApp(wsgiapp)
+        TestCase.__init__(self, *args)
+
+__all__ = ['url_for', 'TestController']
Add a comment to this file

quickwiki/tests/functional/__init__.py

Empty file added.

quickwiki/tests/functional/test_page.py

+from quickwiki.tests import *
+
+class TestPageController(TestController):
+    def test_index(self):
+        response = self.app.get(url_for(controller='page'))
+        # Test response...
Add a comment to this file

quickwiki/tests/test_models.py

Empty file added.

quickwiki/websetup.py

+import paste.deploy
+from pylons.database import create_engine
+import quickwiki.models as model
+
+def setup_config(command, filename, section, vars):
+    """
+    Place any commands to setup quickwiki here.
+    """
+    conf = paste.deploy.appconfig('config:' + filename)
+    paste.deploy.CONFIG.push_process_config({'app_conf':conf.local_conf,
+                                             'global_conf':conf.global_conf})
+
+    uri = conf['sqlalchemy.dburi']
+    engine = create_engine(uri)
+    print "Connecting to database %s" % uri
+    model.meta.connect(engine)
+    print "Creating tables"
+    model.meta.create_all()
+
+    print "Adding front page data"
+    page = model.Page()
+    page.title = 'FrontPage'
+    page.content = 'Welcome to the QuickWiki front page.'
+    page.flush()
+    print "Successfully setup."
+[easy_install]
+find_links = http://www.pylonshq.com/download/
+
+[pudge]
+theme = pythonpaste.org
+
+# Add extra doc files here with spaces between them
+docs = quickwiki/docs/index.txt 
+
+# Doc Settings
+doc_base = quickwiki/docs/
+dest = quickwiki/docs/html
+
+# Add extra modules here separated with commas
+modules = quickwiki
+title = Quickwiki
+organization = Pylons
+
+# Optionally add extra links
+#organization_url = http://pylons.groovie.org/
+#trac_url=http://pylons.groovie.org/
+settings = no_about=true
+
+# Optionally add extra settings 
+#           link1=/community/ Community
+#           link2=/download/ Download
+ 
+[publish]
+doc-dir=quickwiki/docs/html
+make-dirs=1
+from setuptools import setup, find_packages
+
+setup(
+    name='QuickWiki',
+    version="0.1.3",
+    description="Result of following the Pylons 0.9.4.1 Tutorial",
+    url="http://www.pylonshq.com/docs/quick_wiki.html",
+    author="James Gardner",
+    #author_email="",
+    install_requires=["Pylons>=0.9.4.1", "docutils==0.4", "SQLAlchemy>=0.2.6"],
+    packages=find_packages(),
+    include_package_data=True,
+    test_suite = 'nose.collector',
+    package_data={'quickwiki': ['i18n/*/LC_MESSAGES/*.mo']},
+    entry_points="""
+    [paste.app_factory]
+    main=quickwiki:make_app
+    [paste.app_install]
+    main=paste.script.appinstall:Installer
+    """,
+)
+#
+# QuickWiki - Pylons testing environment configuration
+#
+# The %(here)s variable will be replaced with the parent directory of this file
+#
+[DEFAULT]
+debug = true
+email_to = you@yourdomain.com
+smtp_server = localhost
+error_email_from = paste@localhost
+
+[server:main]
+use = egg:Paste#http
+host = 0.0.0.0
+port = 5000
+
+[app:main]
+use = config:development.ini
+
+# Add additional test specific configuration options as necessary.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.