diff --git a/Vagrantfile b/Vagrantfile index 5c12bb8..34b1a37 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -7,6 +7,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| salt.minion_config = "srv/minion" salt.run_highstate = true 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 Vagrant::Config.run do |config| diff --git a/reimagine/__init__.py b/reimagine/__init__.py index e4f6480..394b320 100644 --- a/reimagine/__init__.py +++ b/reimagine/__init__.py @@ -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) diff --git a/reimagine/models.py b/reimagine/models.py index ab3b9b4..020ce98 100644 --- a/reimagine/models.py +++ b/reimagine/models.py @@ -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 diff --git a/reimagine/wiki.py b/reimagine/wiki.py index 33dfc91..869a86f 100644 --- a/reimagine/wiki.py +++ b/reimagine/wiki.py @@ -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) \ No newline at end of file + return self.repo.file_history(self.cname_to_filename(name)) + + def cname_to_filename(self, cname): + return cname.lower() + ".md" \ No newline at end of file diff --git a/srv/salt/gollum/init.sls b/srv/salt/gollum/init.sls deleted file mode 100644 index 8964332..0000000 --- a/srv/salt/gollum/init.sls +++ /dev/null @@ -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 %} diff --git a/srv/salt/reimagine/init.sls b/srv/salt/reimagine/init.sls index c7bcf27..99c1f6d 100644 --- a/srv/salt/reimagine/init.sls +++ b/srv/salt/reimagine/init.sls @@ -5,11 +5,11 @@ python-pkgs: - python-pip - 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: pip: - name: {{ pkg }} - installed - require: - - pkg.installed: python-pkgs + - pkg.installed: common-pkgs {% endfor %} \ No newline at end of file