updated dockerfile, spacing adjustments

This commit is contained in:
Matthew Scragg 2014-11-17 11:25:26 -06:00
parent b757ceff57
commit 6c7095ec5a
14 changed files with 36 additions and 16 deletions

View file

@ -9,11 +9,11 @@ author "scragg@gmail.com"
chdir /home/deploy/realms-wiki 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 export PATH
env LC_ALL=en_US.UTF-8 LC_ALL=en_US.UTF-8
env GEVENT_RESOLVER=ares GEVENT_RESOLVER=ares
export LC_ALL export LC_ALL
export GEVENT_RESOLVER export GEVENT_RESOLVER

View file

@ -81,6 +81,10 @@ def module_exists(module_name):
default=config.CACHE_TYPE, default=config.CACHE_TYPE,
type=click.Choice([None, 'simple', 'redis', 'memcached']), type=click.Choice([None, 'simple', 'redis', 'memcached']),
prompt='Cache type?') prompt='Cache type?')
@click.option('--search-type',
default=config.CACHE_TYPE,
type=click.Choice(['simple', 'elasticsearch']),
prompt='Search type?')
@click.option('--db-uri', @click.option('--db-uri',
default=config.DB_URI, default=config.DB_URI,
prompt='Database URI? Examples: http://goo.gl/RyW0cl') prompt='Database URI? Examples: http://goo.gl/RyW0cl')
@ -106,6 +110,9 @@ def setup(ctx, **kw):
elif conf['CACHE_TYPE'] == 'memcached': elif conf['CACHE_TYPE'] == 'memcached':
ctx.invoke(setup_memcached) ctx.invoke(setup_memcached)
if conf['SEARCH_TYPE'] == 'elasticsearch':
ctx.invoke(setup_elasticsearch)
green('Config saved to %s' % conf_path) green('Config saved to %s' % conf_path)
if not conf_path.startswith('/etc/realms-wiki'): if not conf_path.startswith('/etc/realms-wiki'):
@ -140,6 +147,19 @@ def setup_redis(**kw):
install_redis() 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(): def get_prefix():
return sys.prefix return sys.prefix
@ -385,4 +405,4 @@ def deploy():
call("sudo docker push realms/realms-wiki", shell=True) call("sudo docker push realms/realms-wiki", shell=True)
if __name__ == '__main__': if __name__ == '__main__':
cli() cli()

View file

@ -292,4 +292,4 @@ class Model(db.Model):
@classmethod @classmethod
def get_by_id(cls, id_): def get_by_id(cls, id_):
return cls.query().filter_by(id=id_).first() return cls.query().filter_by(id=id_).first()

View file

@ -20,4 +20,4 @@ class BaseTest(TestCase):
def tearDown(self): def tearDown(self):
call(['rm', '-rf', self.app.config['WIKI_PATH']]) call(['rm', '-rf', self.app.config['WIKI_PATH']])
call(['rm', '-f', self.app.config['DB_URI'][10:]]) call(['rm', '-f', self.app.config['DB_URI'][10:]])

View file

@ -97,6 +97,7 @@ def to_canonical(s):
s = s.lower() s = s.lower()
return s return s
def cname_to_filename(cname): def cname_to_filename(cname):
""" Convert canonical name to filename """ Convert canonical name to filename
@ -117,6 +118,7 @@ def filename_to_cname(filename):
""" """
return os.path.splitext(filename)[0] return os.path.splitext(filename)[0]
def gravatar_url(email): def gravatar_url(email):
return "//www.gravatar.com/avatar/" + hashlib.md5(email).hexdigest() return "//www.gravatar.com/avatar/" + hashlib.md5(email).hexdigest()

View file

@ -15,5 +15,3 @@ class RegistrationForm(Form):
class LoginForm(Form): class LoginForm(Form):
email = StringField('Email', [validators.DataRequired()]) email = StringField('Email', [validators.DataRequired()])
password = PasswordField('Password', [validators.DataRequired()]) password = PasswordField('Password', [validators.DataRequired()])

View file

@ -109,4 +109,4 @@ class User(Model, UserMixin):
def logout(cls): def logout(cls):
logout_user() logout_user()
login_manager.anonymous_user = AnonUser login_manager.anonymous_user = AnonUser

View file

@ -69,4 +69,4 @@ def settings():
@blueprint.route("/logout") @blueprint.route("/logout")
def logout(): def logout():
User.logout() User.logout()
return redirect("/") return redirect("/")

View file

@ -33,4 +33,4 @@ def rebuild_index():
username=page['info']['author'], username=page['info']['author'],
updated_on=entry['mtime'], updated_on=entry['mtime'],
created_on=entry['ctime']) created_on=entry['ctime'])
search.index_wiki(name, body) search.index_wiki(name, body)

View file

@ -20,4 +20,4 @@ def wiki_write_page(name, content, message=None, username=None, email=None, **kw
@Wiki.after('rename_page') @Wiki.after('rename_page')
def wiki_rename_page(*args, **kwargs): def wiki_rename_page(*args, **kwargs):
pass pass

View file

@ -7,4 +7,4 @@ blueprint = Blueprint('search', __name__)
@blueprint.route('/_search') @blueprint.route('/_search')
def search(): def search():
results = search_engine.wiki(request.args.get('q')) results = search_engine.wiki(request.args.get('q'))
return render_template('search/search.html', results=results) return render_template('search/search.html', results=results)

View file

@ -3,4 +3,4 @@ from .models import Wiki
def before_request(): def before_request():
g.current_wiki = Wiki(current_app.config['WIKI_PATH']) g.current_wiki = Wiki(current_app.config['WIKI_PATH'])

View file

@ -163,4 +163,4 @@ def page(name):
if data: if data:
return render_template('wiki/page.html', name=cname, page=data, partials=data.get('partials')) return render_template('wiki/page.html', name=cname, page=data, partials=data.get('partials'))
else: else:
return redirect(url_for('wiki.create', name=cname)) return redirect(url_for('wiki.create', name=cname))

View file

@ -1 +1 @@
__version__ = '0.5.1' __version__ = '0.5.2'