Skip to content

Commit

Permalink
Fix nginx configuration; add Web fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Speer committed Oct 13, 2016
1 parent 5fa5153 commit 54f4958
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 4 deletions.
4 changes: 3 additions & 1 deletion TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Web interface:
- [ ] Link to the JSON-LD version of the current page
- [ ] Add a page listing languages
- [ ] Add a page per language
- [ ] Serve some Noto web fonts (not CJK ones though)
- [x] API root should link to docs
- [x] Serve some Noto web fonts (not CJK ones though)
- [x] Handle MemoryErrors

ConceptNet 5.6 perhaps:

Expand Down
1 change: 1 addition & 0 deletions web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ COPY server/nginx.conf /etc/nginx/conf.d/
COPY server/uwsgi.ini /etc/uwsgi/

COPY server/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
RUN rm /etc/nginx/sites-enabled/default

## End of tiangolo/uwsgi-nginx-docker

Expand Down
4 changes: 3 additions & 1 deletion web/conceptnet_web/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def see_documentation():
This function redirects to the api documentation
"""
return jsonify({
'@context': responses.CONTEXT
'@context': responses.CONTEXT,
'rdfs:comment': 'See http://www.conceptnet.io for more information about ConceptNet, and http://api.conceptnet.io/docs for the API documentation.'
})


Expand All @@ -107,6 +108,7 @@ def query_top_related(uri):


@app.errorhandler(IOError)
@app.errorhandler(MemoryError)
def error_data_unavailable(e):
return render_error(503, str(e))

Expand Down
2 changes: 1 addition & 1 deletion web/conceptnet_web/json_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def request_wants_json():
"""
best = flask.request.accept_mimetypes \
.best_match(['application/ld+json', 'application/json', 'text/html'])
return 'json' in best
return (best is not None) and ('json' in best)


def regex_replacement_stack(replacements):
Expand Down
1 change: 1 addition & 0 deletions web/conceptnet_web/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def edge_list_query(criteria, offset=0, limit=50):


@app.errorhandler(IOError)
@app.errorhandler(MemoryError)
def error_data_unavailable(e):
return render_error(503, str(e))

Expand Down
4 changes: 3 additions & 1 deletion web/server/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ uwsgi_cache_path /data/nginx/cache levels=1:2 keys_zone=STATIC:1024m max_size=10
uwsgi_temp_path /data/nginx/tmp;

server {
server_name conceptnet.io www.conceptnet.io localhost;
listen 80 default_server;
server_name conceptnet.io www.conceptnet.io;
gzip on;
index index.html;
charset utf-8;
Expand All @@ -19,6 +20,7 @@ server {
root /var/www;
}
rewrite ^/docs https://github.com/commonsense/conceptnet5/wiki last;
rewrite ^/data/5../(.*)$ http://api.conceptnet.io/$1;
}

server {
Expand Down
10 changes: 10 additions & 0 deletions web/static/css/conceptnet.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/* Web fonts */
@import url('https://fonts.googleapis.com/css?family=Noto+Sans:400,700');
@import url(http://fonts.googleapis.com/earlyaccess/notonastaliqurdu.css);
@import url(http://fonts.googleapis.com/earlyaccess/notonaskharabic.css);
@import url(http://fonts.googleapis.com/earlyaccess/notosanstelugu.css);
@import url(http://fonts.googleapis.com/earlyaccess/notosanshebrew.css);
@import url(http://fonts.googleapis.com/earlyaccess/notosansdevanagari.css);
@import url(http://fonts.googleapis.com/earlyaccess/notosansthai.css);


/* Element styles, from purecss.io/css/main.css */

body {
Expand Down

0 comments on commit 54f4958

Please sign in to comment.