Skip to content

Commit

Permalink
Preload and render list of project names
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Feb 13, 2016
1 parent aa9ca63 commit d82d40b
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 8 deletions.
3 changes: 3 additions & 0 deletions alternative_internet/alternative_internet/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from flask import Flask
app = Flask(__name__)

from alternative_internet.data import preload_datafiles
preload_datafiles()

import alternative_internet.views
4 changes: 4 additions & 0 deletions alternative_internet/alternative_internet/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os


PROJECT_ROOT = os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, os.pardir))
20 changes: 20 additions & 0 deletions alternative_internet/alternative_internet/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os
import glob
import json

from slugify import slugify

import alternative_internet.config as config

DATABASE = {}
SORTED_NAMES = []

def preload_datafiles():
for filename in glob.glob(os.path.join(config.PROJECT_ROOT, 'projects/*.json')):
blob = json.loads(open(filename, 'r').read())
DATABASE[slugify(blob['name'])] = blob
SORTED_NAMES.append(blob['name'])
SORTED_NAMES.sort()

def get_names():
return SORTED_NAMES
Empty file.
Empty file.
Empty file.
4 changes: 3 additions & 1 deletion alternative_internet/alternative_internet/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from alternative_internet import app
from alternative_internet import data as db

@app.route('/')
def index():
return 'Hello World!'
s = '<br/>'.join(db.get_names())
return s
2 changes: 1 addition & 1 deletion projects/Alexandria.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "The Decentralized Library of Alexandria",
"description": "The [Decentralized Library of Alexandria](http://dloa.net/) is an open-source standard in active development to allow users to publish and distribute original content themselves, from music to videos to feature films, 3d printable inventions, recipes, books and just about anything else.",
"description": "The [Decentralized Library of Alexandria](http://dloa.net/) is an open-source standard in active development to allow users to publish and distribute original content themselves, from music to videos to feature films, 3d printable inventions, recipes, books and just about anything else."
}
6 changes: 1 addition & 5 deletions projects/MORPHiS.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"name": "MORPHiS",
"description": "[MORPHiS](https://morph.is/) is a global encrypted distributed datastore intended to replace the cloud for storage and far more. Free open source peer-to-peer
high-performance distributed datastore."
"ohloh": {
"skip": true
}
"description": "[MORPHiS](https://morph.is/) is a global encrypted distributed datastore intended to replace the cloud for storage and far more. Free open source peer-to-peer high-performance distributed datastore."
}
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Flask==0.10.1
Flask==0.10.1
python-slugify==1.2.0

0 comments on commit d82d40b

Please sign in to comment.