diff --git a/media/js/markitup/sets/default/images/code.png b/media/js/markitup/sets/default/images/code.png new file mode 100644 index 0000000..63fe6ce Binary files /dev/null and b/media/js/markitup/sets/default/images/code.png differ diff --git a/media/js/markitup/sets/default/images/list-bullet.png b/media/js/markitup/sets/default/images/list-bullet.png new file mode 100644 index 0000000..4a8672b Binary files /dev/null and b/media/js/markitup/sets/default/images/list-bullet.png differ diff --git a/media/js/markitup/sets/default/images/list-numeric.png b/media/js/markitup/sets/default/images/list-numeric.png new file mode 100644 index 0000000..33b0b8d Binary files /dev/null and b/media/js/markitup/sets/default/images/list-numeric.png differ diff --git a/media/js/markitup/sets/default/images/quotes.png b/media/js/markitup/sets/default/images/quotes.png new file mode 100644 index 0000000..e54ebeb Binary files /dev/null and b/media/js/markitup/sets/default/images/quotes.png differ diff --git a/media/js/markitup/sets/markdown/images b/media/js/markitup/sets/markdown/images new file mode 120000 index 0000000..670e2a1 --- /dev/null +++ b/media/js/markitup/sets/markdown/images @@ -0,0 +1 @@ +../default/images \ No newline at end of file diff --git a/media/js/markitup/sets/markdown/set.js b/media/js/markitup/sets/markdown/set.js new file mode 100644 index 0000000..5980a37 --- /dev/null +++ b/media/js/markitup/sets/markdown/set.js @@ -0,0 +1,41 @@ +// ---------------------------------------------------------------------------- +// markItUp! +// ---------------------------------------------------------------------------- +// Copyright (C) 2008 Jay Salvat +// http://markitup.jaysalvat.com/ +// ---------------------------------------------------------------------------- +mySettings = { + nameSpace: 'markdown', // Useful to prevent multi-instances CSS conflict + previewParserPath: '~/sets/markdown/preview.php', + onShiftEnter: {keepDefault:false, openWith:'\n\n'}, + markupSet: [ + {name:'Bold', key:"B", openWith:'**', closeWith:'**'}, + {name:'Italic', key:"I", openWith:'_', closeWith:'_'}, + {separator:'---------------' }, + {name:'Bulleted List', openWith:'- ' }, + {name:'Numeric List', openWith:function(markItUp) { + return markItUp.line+'. '; + }}, + {separator:'---------------' }, + {name:'Picture', key:"P", replaceWith:'![[![Alternative text]!]]([![Url:!:http://]!] "[![Title]!]")'}, + {name:'Link', key:"L", openWith:'[', closeWith:']([![Url:!:http://]!] "[![Title]!]")', placeHolder:'Your text to link here...' }, + {separator:'---------------'}, + {name:'Quotes', openWith:'> '}, + {name:'Code Block / Code', openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)'}, + {separator:'---------------'}, + {name:'Preview', call:'preview', className:"preview"} + ] +} + +// mIu nameSpace to avoid conflict. +miu = { + markdownTitle: function(markItUp, char) { + heading = ''; + n = $.trim(markItUp.selection||markItUp.placeHolder).length; + for(i = 0; i < n; i++) { + heading += char; + } + return '\n'+heading+'\n'; + } +} + diff --git a/media/js/markitup/sets/markdown/style.css b/media/js/markitup/sets/markdown/style.css new file mode 100644 index 0000000..257bf29 --- /dev/null +++ b/media/js/markitup/sets/markdown/style.css @@ -0,0 +1,55 @@ +/* ------------------------------------------------------------------- +// markItUp! +// By Jay Salvat - http://markitup.jaysalvat.com/ +// ------------------------------------------------------------------*/ +.markdown .markItUpButton1 a { + background-image:url(images/h1.png); +} +.markdown .markItUpButton2 a { + background-image:url(images/h2.png); +} +.markdown .markItUpButton3 a { + background-image:url(images/h3.png); +} +.markdown .markItUpButton4 a { + background-image:url(images/h4.png); +} +.markdown .markItUpButton5 a { + background-image:url(images/h5.png); +} +.markdown .markItUpButton6 a { + background-image:url(images/h6.png); +} + +.markdown .markItUpButton1 a { + background-image:url(images/bold.png); +} +.markdown .markItUpButton2 a { + background-image:url(images/italic.png); +} + +.markdown .markItUpButton3 a { + background-image:url(images/list-bullet.png); +} +.markdown .markItUpButton4 a { + background-image:url(images/list-numeric.png); +} + +.markdown .markItUpButton5 a { + background-image:url(images/picture.png); +} +.markdown .markItUpButton6 a { + background-image:url(images/link.png); +} + +.markdown .markItUpButton7 a { + background-image:url(images/quotes.png); +} +.markdown .markItUpButton8 a { + background-image:url(images/code.png); +} + +.markdown .preview a { + background-image:url(images/preview.png); +} + diff --git a/pygit/pygit.py b/pygit/pygit.py index 561da65..3934fb5 100644 --- a/pygit/pygit.py +++ b/pygit/pygit.py @@ -5,6 +5,7 @@ import gzip from git import * from django.conf import settings +from django.core.cache import cache rp = None curr_path = None @@ -79,6 +80,16 @@ def blame(rid,file,branch='master'): bl = Blob.blame(r,branch,file) return [(ci.id_abbrev,ci.author.name,date(ci.authored_date),ci.message[:40],''.join(l[:40])) for ci,l in bl] +def cached_diff(repo,c1,c2): + key = 'git-diff-%s' % (hash(repo.path) + hash(c1) + hash(c2)) + r = cache.get(key) + if r: + return r + else: + r = Commit.diff(repo,c1,c2) + cache.set(key,r,3*60*60) + return r + def diff_all(rid,cid1,cid2=None): r = open_repo(rid) c1 = r.commits(cid1)[0] @@ -89,7 +100,7 @@ def diff_all(rid,cid1,cid2=None): c2 = c1.parents[0] else: return [("Initial commit","Nothing to diff.")] - ds = Commit.diff(r,c2,c1) + ds = cached_diff(r,c2,c1) return [(d.a_path,d.diff) for d in ds] def diff_path(rid,path,cid1,cid2=None): @@ -102,7 +113,7 @@ def diff_path(rid,path,cid1,cid2=None): c2 = c1.parents[0] else: return [("Initial commit","Nothing to diff.")] - ds = Commit.diff(r,c2,c1) + ds = cached_diff(r,c2,c1) return [(d.a_path,d.diff) for d in ds if d.a_path==path] def group_by_date(lst): diff --git a/run-fastcgi b/run-fastcgi index 60b9c50..885bce2 100755 --- a/run-fastcgi +++ b/run-fastcgi @@ -13,5 +13,5 @@ fi exec /usr/bin/env - \ PYTHONPATH="../python:.." \ - ./manage.py runfcgi maxrequests=1 outlog="$PROJDIR/fcgi-out.log" errlog="$PROJDIR/fcgi-err.log" method=prefork socket=$SOCKET pidfile=$PIDFILE + ./manage.py runfcgi outlog="$PROJDIR/fcgi-out.log" errlog="$PROJDIR/fcgi-err.log" method=prefork socket=$SOCKET pidfile=$PIDFILE diff --git a/settings.py b/settings.py index 2b6f8bd..e2891ed 100644 --- a/settings.py +++ b/settings.py @@ -18,6 +18,8 @@ DATABASE_PASSWORD = 'dJang0' # Not used with sqlite3. DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3. +# CACHE_BACKEND='file:///tmp/django' + # Local time zone for this installation. All choices can be found here: # http://www.postgresql.org/docs/current/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE TIME_ZONE = 'Asia/Yekaterinburg' diff --git a/templates/base.html b/templates/base.html index 119fef1..2acdd77 100644 --- a/templates/base.html +++ b/templates/base.html @@ -9,19 +9,18 @@ {% block head %} <link rel='stylesheet' type='text/css' href='/media/css/main.css'/> <link rel="stylesheet" type="text/css" href="/media/js/markitup/skins/markitup/style.css" /> - <link rel="stylesheet" type="text/css" href="/media/js/markitup/sets/default/style.css" /> - <script type="text/javascript" src="/medja/js/jquery.js"></script> + <link rel="stylesheet" type="text/css" href="/media/js/markitup/sets/markdown/style.css" /> + <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="/medja/js/markitup/jquery.markitup.js"></script> - <script type="text/javascript" src="/media/js/markitup/sets/default/set.js"></script> - {% endblock %} - </head> - <body> - - <script type="text/javascript" event='window.onload'> + <script type="text/javascript" src="/media/js/markitup/sets/markdown/set.js"></script> + <script type="text/javascript"> $(document).ready(function() { $("textarea").markItUp(mySettings); }); </script> + {% endblock %} + </head> + <body> <div id='body'> <div id='header'>