Permalink
Browse files

updating deploy doc, and fixing up the display of results, working on…

… improving the mappings for sorting
  • Loading branch information...
1 parent f5a19de commit ec28c7455fa0cb4a280ae9b61c723ef98a1808f0 @markmacgillivray markmacgillivray committed May 3, 2012
View
@@ -1,9 +1,12 @@
-# install nginx and supervisor
-apt-get install nginx supervisord
+# this example is for installing bibserver to run bibsoup.net, but applies to
+# other instances - just change relevant parts e.g. domain name and so on
+# these instructions work on an ubuntu / debian machine, and has some pre-requisites
+# nginx, supervisord, git, python2.7+, virtualenv, pip
# create an nginx site config named e.g. bibsoup.net
# default location is /etc/nginx/sites-available
+# for OKF machines should be in ~/etc/nginx/sites-available then symlinked (see below)
# then symlink from /etc/nginx/sites-enabled
upstream bibsoup_app_server {
# server unix:/tmp/gunicorn.sock fail_timeout=0;
@@ -36,6 +39,7 @@ server {
# create a supervisord config named e.g. bibsoup.net.conf
# default location is /etc/supervisor/conf.d
+# for OKF machines, should be put in ~/etc/supervisor/conf.d then symlinked (see below)
[program:bibsoup.net]
command=/home/okfn/var/srvc/%(program_name)s/bin/gunicorn -w 4 -b 127.0.0.1:5050 bibserver.web:app
user=www-data
@@ -58,15 +62,46 @@ cd bibserver
python setup.py install
+# currently, setup.py install does not result in running system because
+# config.json cannot be found. So, do dev install. This will be fixed on
+# move to Flask config method
+pip install -e .
+
+
+# and install gunicorn into the virtualenv
+pip install gunicorn
+
+
# create a local_config.json with details as necessary
+# for example check the ES index you with to use for this instance (default is bibserver)
{
+ "debug": false,
"ELASTIC_SEARCH_HOST" : "elasticsearch.okserver.org:9200"
}
+# run bibserver directly to check it is working
+# requires elasticsearch to be up and running, as will attempt to create indices
+# if it works, kill it and move on. If not, debug the issues
+python bibserver/web.py
+
+
# in the case of OKF service deployment, make symbolic links from the supervisor
# and nginx files which should be in the ~/etc folder into the /etc/nginx/sites-available
# and /etc/supervisor/conf.d folders, then make symbolic link from /etc/nginx/sites-available
# into /etc/nginx/sites-enabled
+cd /etc/nginx/sites-available
+ln -s ~/etc/nginx/sites-available/bibsoup.net .
+cd /etc/supervisor/conf.d
+ln -s ~/etc/supervisor/conf.d/bibsoup.net.conf .
+
+
+# to enable the new settings
+cd /etc/nginx/sites-enabled
+ln -s ../sites-available/bibsoup.net .
+/etc/init.d/nginx reload
+supervisorctl reread
+supervisorctl update
+# point your domain name at the server, and it should work
@@ -12,7 +12,7 @@ def update(account, collection):
allowed = True
except:
pass
- if account.id == config['super_user']:
+ if account.id in config['super_user']:
allowed = True
return allowed
View
@@ -223,8 +223,8 @@ def account(self):
return resp
else:
admin = True if auth.user.update(self.current_user,acc) else False
- recordcount = bibserver.dao.Record.query(terms={'owner':self.current_user.id})['hits']['total']
- collcount = bibserver.dao.Collection.query(terms={'owner':self.current_user.id})['hits']['total']
+ recordcount = bibserver.dao.Record.query(terms={'owner':acc.id})['hits']['total']
+ collcount = bibserver.dao.Collection.query(terms={'owner':acc.id})['hits']['total']
return render_template('account/view.html',
current_user=self.current_user,
search_options=json.dumps(self.search_options),
@@ -239,8 +239,8 @@ def account(self):
def collection(self):
# show the collection that matches parts[1]
- self.search_options['predefined_filters']['owner'+config['facet_field']] = self.parts[0]
- self.search_options['predefined_filters']['collection'+config['facet_field']] = self.parts[1]
+ self.search_options['predefined_filters']['owner'] = self.parts[0]
+ self.search_options['predefined_filters']['collection'] = self.parts[1]
# remove the collection facet
for count,facet in enumerate(self.search_options['facets']):
@@ -285,7 +285,7 @@ def collection(self):
admin = True if metadata != None and auth.collection.update(self.current_user, metadata) else False
if metadata and '_display_settings' in metadata:
self.search_options.update(metadata['_display_settings'])
- users = bibserver.dao.Account.query(size=1000000)
+ users = bibserver.dao.Account.query(size=1000000) # pass the userlist for autocomplete admin addition (could be ajax'd)
userlist = [i['_source']['_id'] for i in users['hits']['hits']]
return render_template('search/index.html',
current_user=self.current_user,
@@ -27,7 +27,8 @@
"hide":[], // a list of keys that should be hidden from view
"data":undefined, // a JSON object to render for editing
"delete_redirect":"#", // where to redirect to after deleting
- "addable":[], // things that should be provided as addables to the item
+ "addable":{}, // things that should be provided as addables to the item
+ "customadd": true, // whether or not user can specify new item name (entails addition of function to check edited item names)
"tags": []
}
@@ -79,15 +80,11 @@
s += '<ul class="dropdown-menu">'
if (editable) {
isdict ? addname = key : addname = ""
- !partisdict ? s += '<li><a class="jtedit_addanother" href=""><i class="icon-plus"></i> add another ' + addname + '</a></li>' : ""
- if (addname.substr(-1) == "y") {
- addname = addname.substr(0,-1) + "ies"
+ !partisdict ? s += '<li><a class="jtedit_addanother" href=""><i class="icon-plus"></i> Add another ' + addname + '</a></li>' : ""
+ if (addname.length > 0 && !partisdict) {
+ addname = "all " + addname
} else {
- if (addname.length > 0 && !partisdict) {
- addname = addname + "s"
- } else {
- addname = "this"
- }
+ addname = "this"
}
s += '<li><a class="jtedit_remove" href="#"><i class="icon-remove"></i> Remove ' + addname + '</a></li>'
partisdict ? s += '<li><a class="jtedit_tolist" href="#"><i class="icon-edit"></i> Make this a list</a></li>' : ""
@@ -127,7 +124,7 @@
$('.jtedit_showhidedetails').bind('click',jtedit_showhidedetails)
$('.jtedit_tolist').bind('click',jtedit_tolist)
$('.jtedit_optionsgroup').bind('mouseenter',jtedit_optionswarn)
- $('.jtedit_optionsgroup').bind('mouseleave',jtedit_optionswarnout)
+ $('.jtedit_optionsgroup').bind('mouseleave',jtedit_optionswarn)
$('.jtedit_addanother').bind('click',jtedit_addanother)
}
@@ -253,13 +250,13 @@
// highlight an object on options hover
var jtedit_optionswarn = function(event) {
event.preventDefault()
- $(this).css({'color':'red'})
- $(this).parent().addClass('jtedit_optionswarn')
- }
- var jtedit_optionswarnout = function(event) {
- event.preventDefault()
- $(this).css({'color':'#000'})
- $(this).parent().removeClass('jtedit_optionswarn')
+ if ( $(this).parent().hasClass('jtedit_optionswarn') ) {
+ $(this).css({'color':'#000'})
+ $(this).parent().removeClass('jtedit_optionswarn')
+ } else {
+ $(this).css({'color':'red'})
+ $(this).parent().addClass('jtedit_optionswarn')
+ }
}
// add another item to a list
@@ -271,7 +268,26 @@
// add an item to the object
var jtedit_additem = function(event) {
event.preventDefault()
- alert("add a new item to this object")
+ // get current item name
+ var findval = ""
+ // search options for item children
+ var newitems = []
+ if ( findval ) {
+ for ( var thing in options.addable ) {
+ if ( thing == findval ) {
+ for ( var itemname in options.addable[thing] ) {
+ newitems.push(itemname)
+ }
+ }
+ break
+ }
+ } else {
+ for ( var thing in options.addable ) {
+ newitems.push(thing)
+ }
+ }
+ // offer children as option, or create new option enabled
+ alert("add an " + newitems)
}
// convert to a list
@@ -30,10 +30,14 @@
<div class="hero-unit clearfix">
<div class="span5">
- <h2>Hi {{ current_user.id }}</h2>
- <p>{{ current_user.description }}</p>
+ {% if current_user.id != account.id %}
+ <h2>Hi {{ current_user.id }}. As a superuser, you are viewing the page of {{ account.id }}. You can edit this too.</h2>
+ {% else %}
+ <h2>Hi {{ current_user.id }}</h2>
+ <p>{{ current_user.description }}</p>
+ {% endif %}
<p><br />Your api_key is:</p>
- <p><input type="text" value="{{current_user['api_key']}}" class="span4 selectable" /></p>
+ <p><input type="text" value="{{account['api_key']}}" class="span4 selectable" /></p>
<p>You need to append this to your API calls if you want to make changes.</p>
{% if superuser %}
<p>You are the superuser! You can view and edit anything!
@@ -50,11 +54,11 @@
<div class="span3">
<h3>Your collections</h3>
<p>You have {{ recordcount }} records across {{ collcount }} collections. Choose one to view - admin options are available in each collection.</p>
- {% if current_user['collections']|length == 0 %}
+ {% if account['collections']|length == 0 %}
<p>You have no collections yet. <a href="/upload">Create one!</a></p>
{% else %}
- {% for coll in current_user['collections'] %}
- <p><a href="/{{current_user.id}}/{{coll.collection}}">{{coll['label']}}</a> -
+ {% for coll in account['collections'] %}
+ <p><a href="/{{account.id}}/{{coll.collection}}">{{coll['label']}}</a> -
{{coll['description']}} ({{coll|length}} records)</p>
{% endfor %}
{% endif %}
@@ -102,7 +102,7 @@
<div class="row">
<div class="span7">
<p><a href="/faq">FAQ</a> / <a href="https://github.com/okfn/bibserver/issues">Feedback</a><br />
- Powered by open source <a href="https://github.com/okfn/bibserver">BibServer</a> v0.5.0<br />
+ Powered by open source <a href="https://github.com/okfn/bibserver">BibServer</a> v0.5.1<br />
Following the <a href="http://openbiblio.net/principles/">Open Biblio Principles</a> (bibliographic metadata are facts)
and <a href="http://bibjson.org">BibJSON conventions</a></p>
</div>
@@ -208,12 +208,15 @@
{% endif %}
{% if collection._id %}
<h2><a href="/{{collection.owner}}">{{collection['owner']}}</a> / <a href="/{{collection.owner}}/{{collection.collection}}">{{ collection['label'] }}</a>
- <small>{{ collection['description'] }}</small></h2>
+ {% if collection.description %}
+ <small>{{ collection['description'] }}</small>
+ {% endif %}
+ </h2>
{% endif %}
</div>
-{% if collection.id %}
-<!--
+{% if collection._id %}
+
<p>
{% if 'source' in collection %}
The source of this collection is <a href="{{collection.source}}">{{collection.source}}</a><br />
@@ -222,7 +225,7 @@
Last updated {{collection._last_modified}}
{% endif %}
</p>
--->
+
{% endif %}
{% endblock %}
View
@@ -80,7 +80,7 @@ def content():
def home():
data = []
try:
- colldata = bibserver.dao.Collection.query(sort={"_created":{"order":"desc"}},size=20)
+ colldata = bibserver.dao.Collection.query(sort={"_created.exact":{"order":"desc"}},size=20)
if colldata['hits']['total'] != 0:
for coll in colldata['hits']['hits']:
colln = bibserver.dao.Collection.get(coll['_id'])
View
@@ -205,8 +205,13 @@
{
"default" : {
"match" : "*",
+ "match_mapping_type": "string",
"mapping" : {
- "index" : "not_analyzed"
+ "type" : "multi_field",
+ "fields" : {
+ "{name}" : {"type" : "{dynamic_type}", "index" : "analyzed", "store" : "no"},
+ "exact" : {"type" : "{dynamic_type}", "index" : "not_analyzed", "store" : "yes"}
+ }
}
}
}

0 comments on commit ec28c74

Please sign in to comment.