fixed rename
This commit is contained in:
parent
2233205e0e
commit
613d1c6ca3
8
Vagrantfile
vendored
8
Vagrantfile
vendored
|
@ -7,6 +7,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||||
salt.minion_config = "srv/minion"
|
salt.minion_config = "srv/minion"
|
||||||
salt.run_highstate = true
|
salt.run_highstate = true
|
||||||
end
|
end
|
||||||
|
config.vm.provider :digital_ocean do |provider, override|
|
||||||
|
override.ssh.private_key_path = '~/.ssh/id_dsa'
|
||||||
|
override.vm.box = 'digital_ocean'
|
||||||
|
override.vm.box_url = "https://github.com/smdahlen/vagrant-digitalocean/raw/master/box/digital_ocean.box"
|
||||||
|
|
||||||
|
provider.client_id = ''
|
||||||
|
provider.api_key = ''
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Vagrant::Config.run do |config|
|
Vagrant::Config.run do |config|
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
import config
|
|
||||||
import redis
|
|
||||||
import logging
|
import logging
|
||||||
import rethinkdb as rdb
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import redis
|
||||||
|
import rethinkdb as rdb
|
||||||
from flask import Flask, request, render_template, url_for, redirect
|
from flask import Flask, request, render_template, url_for, redirect
|
||||||
from flask.ext.bcrypt import Bcrypt
|
from flask.ext.bcrypt import Bcrypt
|
||||||
from flask.ext.login import LoginManager
|
from flask.ext.login import LoginManager
|
||||||
from flask.ext.assets import Environment
|
from flask.ext.assets import Environment
|
||||||
|
from recaptcha.client import captcha
|
||||||
|
|
||||||
|
import config
|
||||||
from session import RedisSessionInterface
|
from session import RedisSessionInterface
|
||||||
from wiki import Wiki
|
from wiki import Wiki
|
||||||
from util import to_canonical, remove_ext
|
from util import to_canonical, remove_ext
|
||||||
from recaptcha.client import captcha
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.update(config.flask)
|
app.config.update(config.flask)
|
||||||
|
@ -160,8 +163,6 @@ def render(name):
|
||||||
|
|
||||||
data = w.get_page(cname)
|
data = w.get_page(cname)
|
||||||
if data:
|
if data:
|
||||||
#if data.get('data'):
|
|
||||||
# data['data'] = markdown(data['data'])
|
|
||||||
return render_template('page/page.html', name=cname, page=data)
|
return render_template('page/page.html', name=cname, page=data)
|
||||||
else:
|
else:
|
||||||
return redirect('/create/'+cname)
|
return redirect('/create/'+cname)
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import rethinkdb as rdb
|
|
||||||
from reimagine import conn
|
|
||||||
from rethinkORM import RethinkModel
|
from rethinkORM import RethinkModel
|
||||||
|
|
||||||
|
from reimagine import conn
|
||||||
|
|
||||||
|
|
||||||
class BaseModel(RethinkModel):
|
class BaseModel(RethinkModel):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if not kwargs.get('conn'):
|
if not kwargs.get('conn'):
|
||||||
kwargs['conn'] = conn
|
kwargs['conn'] = conn
|
||||||
|
|
||||||
super(BaseModel, self).__init__(**kwargs)
|
super(BaseModel, self).__init__(**kwargs)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
import os
|
||||||
|
|
||||||
from gittle import Gittle
|
from gittle import Gittle
|
||||||
|
|
||||||
from util import to_canonical
|
from util import to_canonical
|
||||||
from lxml.html.clean import clean_html
|
|
||||||
|
|
||||||
|
|
||||||
class MyGittle(Gittle):
|
class MyGittle(Gittle):
|
||||||
|
@ -32,6 +34,10 @@ class MyGittle(Gittle):
|
||||||
message=commit['message']))
|
message=commit['message']))
|
||||||
return versions
|
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():
|
class Wiki():
|
||||||
path = None
|
path = None
|
||||||
|
@ -52,9 +58,8 @@ class Wiki():
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
def write_page(self, name, content, message=None, create=False):
|
def write_page(self, name, content, message=None, create=False):
|
||||||
name = to_canonical(name)
|
|
||||||
#content = clean_html(content)
|
#content = clean_html(content)
|
||||||
filename = name.lower() + ".md"
|
filename = self.cname_to_filename(to_canonical(name))
|
||||||
f = open(self.path + "/" + filename, 'w')
|
f = open(self.path + "/" + filename, 'w')
|
||||||
f.write(content)
|
f.write(content)
|
||||||
f.close()
|
f.close()
|
||||||
|
@ -68,10 +73,15 @@ class Wiki():
|
||||||
files=[filename])
|
files=[filename])
|
||||||
|
|
||||||
def rename_page(self, old_name, new_name):
|
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'):
|
def get_page(self, name, sha='HEAD'):
|
||||||
name = name.lower() + ".md"
|
name = self.cname_to_filename(name)
|
||||||
try:
|
try:
|
||||||
return self.repo.get_commit_files(sha, paths=[name]).get(name)
|
return self.repo.get_commit_files(sha, paths=[name]).get(name)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -79,5 +89,7 @@ class Wiki():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_history(self, name):
|
def get_history(self, name):
|
||||||
name = name.lower() + ".md"
|
return self.repo.file_history(self.cname_to_filename(name))
|
||||||
return self.repo.file_history(name)
|
|
||||||
|
def cname_to_filename(self, cname):
|
||||||
|
return cname.lower() + ".md"
|
|
@ -1,20 +0,0 @@
|
||||||
ruby-repos:
|
|
||||||
pkgrepo.managed:
|
|
||||||
- ppa: brightbox/ruby-ng-experimental
|
|
||||||
|
|
||||||
ruby1.9.3:
|
|
||||||
pkg.installed:
|
|
||||||
- require:
|
|
||||||
- pkgrepo.managed: ruby-repos
|
|
||||||
|
|
||||||
asciidoc:
|
|
||||||
pkg.installed
|
|
||||||
|
|
||||||
{% for gem in ['gollum', 'creole', 'redcarpet', 'github-markdown', 'org-ruby', 'RedCloth', 'wikicloth'] %}
|
|
||||||
{{ gem }}-gem:
|
|
||||||
gem:
|
|
||||||
- installed
|
|
||||||
- name: {{ gem }}
|
|
||||||
- require:
|
|
||||||
- pkg.installed: ruby1.9.3
|
|
||||||
{% endfor %}
|
|
|
@ -5,11 +5,11 @@ python-pkgs:
|
||||||
- python-pip
|
- python-pip
|
||||||
- build-essential
|
- build-essential
|
||||||
|
|
||||||
{% for pkg in ['tornado', 'pyzmq', 'itsdangerous', 'boto', 'redis', 'simplejson', 'sockjs-tornado', 'flask', 'flask-bcrypt', 'flask-login', 'flask-assets', 'gittle', 'gevent', 'lxml', 'markdown2', 'recaptcha', 'pyRethinkORM' ] %}
|
{% for pkg in ['tornado', 'pyzmq', 'itsdangerous', 'boto', 'redis', 'simplejson', 'sockjs-tornado', 'flask', 'flask-bcrypt', 'flask-login', 'flask-assets', 'gittle', 'gevent', 'lxml', 'markdown2', 'recaptcha-client', 'RethinkORM' ] %}
|
||||||
{{ pkg }}-pip:
|
{{ pkg }}-pip:
|
||||||
pip:
|
pip:
|
||||||
- name: {{ pkg }}
|
- name: {{ pkg }}
|
||||||
- installed
|
- installed
|
||||||
- require:
|
- require:
|
||||||
- pkg.installed: python-pkgs
|
- pkg.installed: common-pkgs
|
||||||
{% endfor %}
|
{% endfor %}
|
Loading…
Reference in a new issue