From 6c7095ec5a32df19e85eacf3c82258e241bc2e47 Mon Sep 17 00:00:00 2001 From: Matthew Scragg Date: Mon, 17 Nov 2014 11:25:26 -0600 Subject: [PATCH] updated dockerfile, spacing adjustments --- docker/realms-wiki.sh | 6 +++--- realms/commands.py | 22 +++++++++++++++++++++- realms/lib/model.py | 2 +- realms/lib/test.py | 2 +- realms/lib/util.py | 2 ++ realms/modules/auth/forms.py | 2 -- realms/modules/auth/models.py | 2 +- realms/modules/auth/views.py | 2 +- realms/modules/search/commands.py | 2 +- realms/modules/search/hooks.py | 2 +- realms/modules/search/views.py | 2 +- realms/modules/wiki/hooks.py | 2 +- realms/modules/wiki/views.py | 2 +- realms/version.py | 2 +- 14 files changed, 36 insertions(+), 16 deletions(-) diff --git a/docker/realms-wiki.sh b/docker/realms-wiki.sh index 5fc0318..ad58c9d 100644 --- a/docker/realms-wiki.sh +++ b/docker/realms-wiki.sh @@ -9,11 +9,11 @@ author "scragg@gmail.com" chdir /home/deploy/realms-wiki -env PATH=/home/deploy/realms-wiki/.venv/bin:/usr/local/bin:/usr/bin:/bin:$PATH +PATH=/home/deploy/realms-wiki/.venv/bin:/usr/local/bin:/usr/bin:/bin:$PATH export PATH -env LC_ALL=en_US.UTF-8 -env GEVENT_RESOLVER=ares +LC_ALL=en_US.UTF-8 +GEVENT_RESOLVER=ares export LC_ALL export GEVENT_RESOLVER diff --git a/realms/commands.py b/realms/commands.py index a7d2878..9593bd0 100644 --- a/realms/commands.py +++ b/realms/commands.py @@ -81,6 +81,10 @@ def module_exists(module_name): default=config.CACHE_TYPE, type=click.Choice([None, 'simple', 'redis', 'memcached']), prompt='Cache type?') +@click.option('--search-type', + default=config.CACHE_TYPE, + type=click.Choice(['simple', 'elasticsearch']), + prompt='Search type?') @click.option('--db-uri', default=config.DB_URI, prompt='Database URI? Examples: http://goo.gl/RyW0cl') @@ -106,6 +110,9 @@ def setup(ctx, **kw): elif conf['CACHE_TYPE'] == 'memcached': ctx.invoke(setup_memcached) + if conf['SEARCH_TYPE'] == 'elasticsearch': + ctx.invoke(setup_elasticsearch) + green('Config saved to %s' % conf_path) if not conf_path.startswith('/etc/realms-wiki'): @@ -140,6 +147,19 @@ def setup_redis(**kw): install_redis() +@click.command() +@click.option('--elasticsearch-url', + default=getattr(config, 'ELASTICSEARCH_URL', 'http://127.0.0.1:9200'), + prompt='Elasticsearch URL') +def setup_elasticsearch(**kw): + conf = {} + + for k, v in kw.items(): + conf[k.upper()] = v + + config.update(conf) + + def get_prefix(): return sys.prefix @@ -385,4 +405,4 @@ def deploy(): call("sudo docker push realms/realms-wiki", shell=True) if __name__ == '__main__': - cli() \ No newline at end of file + cli() diff --git a/realms/lib/model.py b/realms/lib/model.py index 84da7c9..bd84bbb 100644 --- a/realms/lib/model.py +++ b/realms/lib/model.py @@ -292,4 +292,4 @@ class Model(db.Model): @classmethod def get_by_id(cls, id_): - return cls.query().filter_by(id=id_).first() \ No newline at end of file + return cls.query().filter_by(id=id_).first() diff --git a/realms/lib/test.py b/realms/lib/test.py index 9a0f230..4295ff3 100644 --- a/realms/lib/test.py +++ b/realms/lib/test.py @@ -20,4 +20,4 @@ class BaseTest(TestCase): def tearDown(self): call(['rm', '-rf', self.app.config['WIKI_PATH']]) - call(['rm', '-f', self.app.config['DB_URI'][10:]]) \ No newline at end of file + call(['rm', '-f', self.app.config['DB_URI'][10:]]) diff --git a/realms/lib/util.py b/realms/lib/util.py index a707805..8c05bce 100644 --- a/realms/lib/util.py +++ b/realms/lib/util.py @@ -97,6 +97,7 @@ def to_canonical(s): s = s.lower() return s + def cname_to_filename(cname): """ Convert canonical name to filename @@ -117,6 +118,7 @@ def filename_to_cname(filename): """ return os.path.splitext(filename)[0] + def gravatar_url(email): return "//www.gravatar.com/avatar/" + hashlib.md5(email).hexdigest() diff --git a/realms/modules/auth/forms.py b/realms/modules/auth/forms.py index bca2163..e1cbee5 100644 --- a/realms/modules/auth/forms.py +++ b/realms/modules/auth/forms.py @@ -15,5 +15,3 @@ class RegistrationForm(Form): class LoginForm(Form): email = StringField('Email', [validators.DataRequired()]) password = PasswordField('Password', [validators.DataRequired()]) - - diff --git a/realms/modules/auth/models.py b/realms/modules/auth/models.py index 5b5a3fe..d621069 100644 --- a/realms/modules/auth/models.py +++ b/realms/modules/auth/models.py @@ -109,4 +109,4 @@ class User(Model, UserMixin): def logout(cls): logout_user() -login_manager.anonymous_user = AnonUser \ No newline at end of file +login_manager.anonymous_user = AnonUser diff --git a/realms/modules/auth/views.py b/realms/modules/auth/views.py index 70ba86a..4237cdd 100644 --- a/realms/modules/auth/views.py +++ b/realms/modules/auth/views.py @@ -69,4 +69,4 @@ def settings(): @blueprint.route("/logout") def logout(): User.logout() - return redirect("/") \ No newline at end of file + return redirect("/") diff --git a/realms/modules/search/commands.py b/realms/modules/search/commands.py index 6c981ec..9a143f4 100644 --- a/realms/modules/search/commands.py +++ b/realms/modules/search/commands.py @@ -33,4 +33,4 @@ def rebuild_index(): username=page['info']['author'], updated_on=entry['mtime'], created_on=entry['ctime']) - search.index_wiki(name, body) \ No newline at end of file + search.index_wiki(name, body) diff --git a/realms/modules/search/hooks.py b/realms/modules/search/hooks.py index 847fee9..503beb0 100644 --- a/realms/modules/search/hooks.py +++ b/realms/modules/search/hooks.py @@ -20,4 +20,4 @@ def wiki_write_page(name, content, message=None, username=None, email=None, **kw @Wiki.after('rename_page') def wiki_rename_page(*args, **kwargs): - pass \ No newline at end of file + pass diff --git a/realms/modules/search/views.py b/realms/modules/search/views.py index 5357392..d462348 100644 --- a/realms/modules/search/views.py +++ b/realms/modules/search/views.py @@ -7,4 +7,4 @@ blueprint = Blueprint('search', __name__) @blueprint.route('/_search') def search(): results = search_engine.wiki(request.args.get('q')) - return render_template('search/search.html', results=results) \ No newline at end of file + return render_template('search/search.html', results=results) diff --git a/realms/modules/wiki/hooks.py b/realms/modules/wiki/hooks.py index 1d60723..03c9ae9 100644 --- a/realms/modules/wiki/hooks.py +++ b/realms/modules/wiki/hooks.py @@ -3,4 +3,4 @@ from .models import Wiki def before_request(): - g.current_wiki = Wiki(current_app.config['WIKI_PATH']) \ No newline at end of file + g.current_wiki = Wiki(current_app.config['WIKI_PATH']) diff --git a/realms/modules/wiki/views.py b/realms/modules/wiki/views.py index ef51cac..6ce93b2 100644 --- a/realms/modules/wiki/views.py +++ b/realms/modules/wiki/views.py @@ -163,4 +163,4 @@ def page(name): if data: return render_template('wiki/page.html', name=cname, page=data, partials=data.get('partials')) else: - return redirect(url_for('wiki.create', name=cname)) \ No newline at end of file + return redirect(url_for('wiki.create', name=cname)) diff --git a/realms/version.py b/realms/version.py index 08d79c0..45869b6 100644 --- a/realms/version.py +++ b/realms/version.py @@ -1 +1 @@ -__version__ = '0.5.1' \ No newline at end of file +__version__ = '0.5.2'