From 91338e7691161f5e6beb0ec2065f19d5065b11b9 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Thu, 21 Jan 2010 23:40:15 +0200 Subject: [PATCH 1/3] Added tagging, and a nice tag editor component. --- development.ini | 4 +- scribeengine/controllers/post.py | 14 ++- scribeengine/lib/base.py | 8 +- scribeengine/public/images/minus_small.png | Bin 0 -> 560 bytes .../public/scripts/ScribeEngine.Post.js | 8 ++ scribeengine/public/scripts/ScribeEngine.js | 14 +-- scribeengine/public/scripts/jquery.js | 19 +++ .../public/scripts/jquery.tag.editor.js | 114 ++++++++++++++++++ .../public/scripts/jquery.validate.js | 16 +++ scribeengine/public/styles/style.css | 28 +++++ scribeengine/templates/base.mako | 9 ++ scribeengine/templates/blog/view.mako | 5 + scribeengine/templates/post/edit.mako | 4 + scribeengine/templates/post/new.mako | 4 + 14 files changed, 231 insertions(+), 16 deletions(-) create mode 100644 scribeengine/public/images/minus_small.png create mode 100755 scribeengine/public/scripts/jquery.js create mode 100644 scribeengine/public/scripts/jquery.tag.editor.js create mode 100644 scribeengine/public/scripts/jquery.validate.js diff --git a/development.ini b/development.ini index db85be5..4deae95 100644 --- a/development.ini +++ b/development.ini @@ -31,7 +31,7 @@ beaker.session.secret = somesecret #beaker.session.data_dir = %(here)s/data/sessions # SQLAlchemy database URL -sqlalchemy.url = sqlite:///%(here)s/scribeengine.sqlite +sqlalchemy.url = sqlite:///%(here)s/code365.sqlite # Images directory paths.images = %(here)s/images @@ -39,7 +39,7 @@ paths.images = %(here)s/images paths.themes = %(here)s/themes # Security settings -security.salt = secretsalt +security.salt = xgH,{@1pgtU9,nLd mail.on = false mail.manager = immediate diff --git a/scribeengine/controllers/post.py b/scribeengine/controllers/post.py index d187a31..242cd0c 100644 --- a/scribeengine/controllers/post.py +++ b/scribeengine/controllers/post.py @@ -25,13 +25,18 @@ from datetime import datetime from scribeengine.lib.base import * from scribeengine.lib import utils -from scribeengine.model import Post +from scribeengine.model import Post, Tag from scribeengine.model.meta import Session log = logging.getLogger(__name__) class PostController(BaseController): + def __before__(self): + BaseController.__before__(self) + self._add_javascript(u'jquery.tag.editor.js') + self._add_javascript(u'ScribeEngine.Post.js') + def index(self): h.redirect_to('/') @@ -61,6 +66,13 @@ class PostController(BaseController): post.body = c.form_values[u'body'] post.status = u'published' post.url = url + tags = c.form_values[u'tags'] + tag_list = [tag_name.strip() for tag_name in tags.split(u',')] + for tag in post.tags: + if tag.name in tag_list: + del tag_list[tag.name] + for tag in tag_list: + post.tags.append(Tag(name=tag, url=utils.generate_url(tag))) Session.add(post) Session.commit() h.redirect_to(str('/archive/%s/%s' % (post.created.strftime('%Y/%m/%d'), post.url))) diff --git a/scribeengine/lib/base.py b/scribeengine/lib/base.py index 58e1521..d4fe506 100644 --- a/scribeengine/lib/base.py +++ b/scribeengine/lib/base.py @@ -63,8 +63,8 @@ class BaseController(WSGIController): self._add_javascript(u'jquery.js') if c.jsvalidation: self._add_javascript(u'jquery.validate.js') - self._add_javascript(u'scribeengine.js') - self._add_jsinit(u'init.js') + self._add_javascript(u'ScribeEngine.js') + self._add_jsinit(u'ScribeEngine.Init.js') def __call__(self, environ, start_response): """Invoke the Controller""" @@ -178,14 +178,14 @@ class BaseController(WSGIController): return False, {u'values': params, u'errors': error_dict} return True, {u'values': values, u'errors': {}} - def _add_javascript(self, filename, subdir=u'global'): + def _add_javascript(self, filename): """ This method dynamically adds javascript files to the section of the template. """ if not getattr(c, u'scripts', None): c.scripts = [] - c.scripts.append((filename, subdir)) + c.scripts.append(filename) def _add_jsinit(self, filename): """ diff --git a/scribeengine/public/images/minus_small.png b/scribeengine/public/images/minus_small.png new file mode 100644 index 0000000000000000000000000000000000000000..bdb868c51e9e301a831d6436a676e06b9328b27e GIT binary patch literal 560 zcmV-00?+-4P)Px#1ZP1_K>z@;j|==^1poj5AY({UO#lFTCIA3{ga82g0001h=l}q9FaQARU;qF* zm;eA5aGbhPJOBUy7<5HgbW?9;ba!ELWdKlNX>N2bPDNB8b~7$BHmT?0B>(^cib+I4 zR47w*kxwXtVI0SwR};IK{Hbx+%%4#*wTnVlL^5rLZPvWAsLcpTn!`#cmX+8L2j!+5 zX!kj}x;V&14wO=)NPB17^Y!et!`|?#Pd&fy^Zovwo_-w3DMTi;to0F&(-Ds35sF*Z zA96EC*SS9NjNr%&w%keV`+(g^V2^Py4TL8sf{rywfCfxDmH5Qv>f$!Pw5V7?n4<1IGw zI<6l}dfI?l7W%K)KsseW+||55?!CGJ!Knj$t-$#Xn|>_iY#Y?u3W3+-#na>=;m%6s z7hfMwICMxmoBu?-8*NBO&FV(+<9EZ#NP46epO!iZLs}%V2!mQtOWA7hU{#(nD<=l@ zB{IdMS#gnesvrz%@NQIz2$m|OoN7E&ua-0b0000