fixed rename
This commit is contained in:
parent
2233205e0e
commit
613d1c6ca3
6 changed files with 38 additions and 38 deletions
|
@ -1,17 +1,20 @@
|
|||
import config
|
||||
import redis
|
||||
import logging
|
||||
import rethinkdb as rdb
|
||||
import os
|
||||
import time
|
||||
|
||||
import redis
|
||||
import rethinkdb as rdb
|
||||
from flask import Flask, request, render_template, url_for, redirect
|
||||
from flask.ext.bcrypt import Bcrypt
|
||||
from flask.ext.login import LoginManager
|
||||
from flask.ext.assets import Environment
|
||||
from recaptcha.client import captcha
|
||||
|
||||
import config
|
||||
from session import RedisSessionInterface
|
||||
from wiki import Wiki
|
||||
from util import to_canonical, remove_ext
|
||||
from recaptcha.client import captcha
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.update(config.flask)
|
||||
|
@ -160,8 +163,6 @@ def render(name):
|
|||
|
||||
data = w.get_page(cname)
|
||||
if data:
|
||||
#if data.get('data'):
|
||||
# data['data'] = markdown(data['data'])
|
||||
return render_template('page/page.html', name=cname, page=data)
|
||||
else:
|
||||
return redirect('/create/'+cname)
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
import rethinkdb as rdb
|
||||
from reimagine import conn
|
||||
from rethinkORM import RethinkModel
|
||||
|
||||
from reimagine import conn
|
||||
|
||||
|
||||
class BaseModel(RethinkModel):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
if not kwargs.get('conn'):
|
||||
kwargs['conn'] = conn
|
||||
|
||||
super(BaseModel, self).__init__(**kwargs)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import os
|
||||
|
||||
from gittle import Gittle
|
||||
|
||||
from util import to_canonical
|
||||
from lxml.html.clean import clean_html
|
||||
|
||||
|
||||
class MyGittle(Gittle):
|
||||
|
@ -32,6 +34,10 @@ class MyGittle(Gittle):
|
|||
message=commit['message']))
|
||||
return versions
|
||||
|
||||
def mv_fs(self, file_pair):
|
||||
old_name, new_name = file_pair
|
||||
os.rename(self.path + "/" + old_name, self.path + "/" + new_name)
|
||||
|
||||
|
||||
class Wiki():
|
||||
path = None
|
||||
|
@ -52,9 +58,8 @@ class Wiki():
|
|||
self.path = path
|
||||
|
||||
def write_page(self, name, content, message=None, create=False):
|
||||
name = to_canonical(name)
|
||||
#content = clean_html(content)
|
||||
filename = name.lower() + ".md"
|
||||
filename = self.cname_to_filename(to_canonical(name))
|
||||
f = open(self.path + "/" + filename, 'w')
|
||||
f.write(content)
|
||||
f.close()
|
||||
|
@ -68,10 +73,15 @@ class Wiki():
|
|||
files=[filename])
|
||||
|
||||
def rename_page(self, old_name, new_name):
|
||||
self.repo.mv([old_name, new_name])
|
||||
old_name, new_name = map(self.cname_to_filename, [old_name, new_name])
|
||||
self.repo.mv([(old_name, new_name)])
|
||||
self.repo.commit(name=self.default_committer_name,
|
||||
email=self.default_committer_email,
|
||||
message="Moving %s to %s" % (old_name, new_name),
|
||||
files=[old_name])
|
||||
|
||||
def get_page(self, name, sha='HEAD'):
|
||||
name = name.lower() + ".md"
|
||||
name = self.cname_to_filename(name)
|
||||
try:
|
||||
return self.repo.get_commit_files(sha, paths=[name]).get(name)
|
||||
except KeyError:
|
||||
|
@ -79,5 +89,7 @@ class Wiki():
|
|||
return None
|
||||
|
||||
def get_history(self, name):
|
||||
name = name.lower() + ".md"
|
||||
return self.repo.file_history(name)
|
||||
return self.repo.file_history(self.cname_to_filename(name))
|
||||
|
||||
def cname_to_filename(self, cname):
|
||||
return cname.lower() + ".md"
|
Loading…
Add table
Add a link
Reference in a new issue