Commits

ben...@localhost.metavers.net  committed b088b76

add doc about friendpaste services.

  • Participants
  • Parent commits 75f32fd

Comments (0)

Files changed (5)

File friendpaste/generic.py

 
 def about(request):
     return render_response("about.html")
+
+def services(request, page=None):
+    if page is None:
+        return render_response("services.html")
+
+    return render_response("services/%s.html" % page)

File friendpaste/paste/views.py

 from werkzeug.utils import url_quote
 from werkzeug.routing import NotFound
 
-
 import simplejson as json
 
-
 from friendpaste.settings import SHARED_DATA, SITE_URI
 from friendpaste.utils import local, datetimestr_topython, strptime
 from friendpaste.http import Response
     ret.sort()
     return ret
 
+
 LEXERS_CHOICE = [('text', 'Default')] + _get_lexers()
 ALL_LEXERS=get_all_lexers()
 
             s.title=d.get('title')
             s.snippet = d.get('snippet')
             s.language = d.get('language')
-            print "we are here"
             s.store(local.application.db)
-            print "so we go?"
         except:
             return send_json({'ok': 'false', 'reason': 'you should provide snippet code'})
-        print "yeah"
         if s.revid == old_revid:
             return send_json({'ok': 'false', 'reason': 'no changes detected'})
         return send_json({
     data['_id'] = res[0].id
     s = Snippet.wrap(data)
 
-
     return render_response('paste/revisions.html', snippet=s, revisions=revisions)
 
 def view_rawsnippet(request, id, rev):
 
     theme = _get_theme(request)
     return render_response('paste/diff.html', unidiff=unidiff, theme=theme,
-            snippet=snippet, rev=rev, old_rev=old_rev) 
+            snippet=snippet, rev=rev, old_rev=old_rev)
+
+def get_all_languages(request):
+    lexers = get_all_lexers()
+    languages = [] 
+    for l in lexers:
+        languages.append(l[1][0])
+    languages.sort()
+
+    return send_json(languages)

File friendpaste/urls.py

 from werkzeug.routing import Map, Rule, RequestRedirect,Submount
 
 from friendpaste.paste import views as paste
-from friendpaste.generic import about
+from friendpaste.generic import about, services
 
 all_views = {
         'paste/create': paste.create_snippet,
         'paste/changeset': paste.view_changeset,
         'paste/revisions': paste.view_revisions,
         'paste/rss': paste.view_rss,
-        'generic/about': about
+        'paste/all_languages': paste.get_all_languages,
+        'generic/about': about,
+        'generic/services': services
 }
 
 
 map = Map([ 
     Rule('/', endpoint='paste/create'),
     Rule('/about', endpoint='generic/about'),
+    Rule('/services/<page>', endpoint='generic/services'),
+    Rule('/services', endpoint='generic/services'),
+    Rule('/_all_languages', endpoint='paste/all_languages'),
     Rule('/<id>_<rev>/raw', endpoint='paste/raw'),
     Rule('/<id>_<rev>.html', endpoint='paste/raw'),
     Rule('/<id>/rss', endpoint='paste/rss'),
     Rule('/<id>/edit', endpoint='paste/edit'),
     Rule('/<id>/changeset', endpoint='paste/changeset'),
     Rule('/<id>/revisions', endpoint='paste/revisions'),
-    Rule('/<id>', endpoint='paste/view')
-    
+    Rule('/<id>', endpoint='paste/view') 
 
 ])

File static/css/base.css

 
 h2 a.root { text-decoration: none; font-size: 85%; }
 
-td.wrap {
+td.wrap, pre.wrap {
     width: 800px;
     white-space: pre-wrap; /* css-3 */
     white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
 #revisions h3, div.txt h2 { background: #303030; color: #fff; margin: 15px 0 15px 0; padding: 0.1em; }
 
 div.txt { width: 90%; padding: 15px 0; margin: 0pt auto; }
+div.txt h3 { margin: 15px 0 10px 0; padding: 0.1em; font-weight: bold;background: #2e8696; }
+div.txt pre { border: 1px solid #2e8696;  padding: 0.3em; }
+div.txt pre.wrap { width: 99%; }
+
 
 li.errors { background: #ff9898; padding: 0.3em; border: 1px solid #ff0000; }
 ul.errors { padding: 0.3em; border: 1px solid #ff0000; margin-bottom: 15px; }

File templates/base.html

                     <div id="nav">
                         <ul>
                             <li><div class="rounded-lr"><div class="rounded-ll"><a href="/"><span>New paste</span></a></div></div></li>
+                            <li><div class="rounded-lr"><div class="rounded-ll"><a href="/services">Services</a></div></div></li>
                             <li><div class="rounded-lr"><div class="rounded-ll"><a href="/about">About</a></div></div></li>
                         </ul>
                     </div>