Skip to content

Commit

Permalink
New project structure to support a simpler installation
Browse files Browse the repository at this point in the history
  • Loading branch information
devilicecream committed Jun 23, 2015
1 parent ab86b88 commit acb6a18
Show file tree
Hide file tree
Showing 252 changed files with 242 additions and 6,545 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Compiled files
*.pyc
*.pyo
build*
dist*
*.egg-info

# OSX sucks
.DS_Store
Expand All @@ -11,7 +15,7 @@

# Sass
.sass-cache
~
~

# fabfile caches
.coffeecache
Expand All @@ -24,6 +28,9 @@ npm-debug.log
# Virtualenv
venv

# IDEA sucks
.idea*

# Bower
static/components/**/.*
static/components/**/bower.json
Expand Down
52 changes: 52 additions & 0 deletions bombolone/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
__author__ = 'walter'
import click
from fabfile import minify, init_database, local_backup


def bake():
"""
Initialize the database from the backup and minify JS files to configure ("cook") the app.
Uses the functions already written in the fabfile.
"""
init_database('bombolone')
minify()

def serve():
"""
Serve the "cooked" app.
"""
import app
app.main()

def refrigerate():
"""
Makes a local backup of the database, using the function already written in the fabfile.
"""
local_backup()


COMMANDS = {
'bake': bake,
'serve': serve,
'refrigerate': refrigerate
}


@click.command()
@click.argument('command')
def main(command):
"""
Bake, serve and refrigerate your Bombolone app!
:param command: [bake|refrigerate|serve]
`bake`: Initialize your Bombolone app, restoring the database from a backup.
`refrigerate`: Put your Bombolone app in the fridge, making a local backup of the database.
`serve`: Serve your Bombolone app!
"""
if command not in COMMANDS.keys():
raise click.BadParameter('%s is not something you can do with Bombolone!' % command)
COMMANDS[command]()

File renamed without changes.
6 changes: 3 additions & 3 deletions api/account.py → bombolone/api/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from werkzeug import secure_filename

# Imports inside Bombolone
import core.users
from core.utils import jsonify
from decorators import authentication, get_hash, check_rank
import bombolone.core.users
from bombolone.core.utils import jsonify
from bombolone.decorators import authentication, get_hash, check_rank

api_account = Blueprint('api_account', __name__)

Expand Down
6 changes: 3 additions & 3 deletions api/hash_table.py → bombolone/api/hash_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from flask import Blueprint, request, g

# Imports inside Bombolone
import core.hash_table
from core.utils import jsonify, set_message
from decorators import get_hash, authentication, check_rank
import bombolone.core.hash_table
from bombolone.core.utils import jsonify, set_message
from bombolone.decorators import get_hash, authentication, check_rank

MODULE_DIR = 'admin/hash_table'
api_hash_table = Blueprint('api_hash_table', __name__)
Expand Down
6 changes: 3 additions & 3 deletions api/languages.py → bombolone/api/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from flask import Blueprint, request, g

# Imports inside Bombolone
import core.languages
from core.utils import jsonify, set_message
from decorators import get_hash, authentication, check_rank
import bombolone.core.languages
from bombolone.core.utils import jsonify, set_message
from bombolone.decorators import get_hash, authentication, check_rank

api_languages = Blueprint('api_languages', __name__)

Expand Down
8 changes: 4 additions & 4 deletions api/pages.py → bombolone/api/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
from flask import Blueprint, request, g

# Imports inside Bombolone
import core.pages
from core.utils import jsonify, set_message
from core.pages import Pages
from decorators import authentication, check_rank, get_hash
import bombolone.core.pages
from bombolone.core.utils import jsonify, set_message
from bombolone.core.pages import Pages
from bombolone.decorators import authentication, check_rank, get_hash

api_pages = Blueprint('api_pages', __name__)

Expand Down
6 changes: 3 additions & 3 deletions api/rank.py → bombolone/api/rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from flask import Blueprint, g, request

# Imports inside Bombolone
import core.rank
from core.utils import jsonify, set_message
from decorators import authentication, check_rank, get_hash
import bombolone.core.rank
from bombolone.core.utils import jsonify, set_message
from bombolone.decorators import authentication, check_rank, get_hash

api_rank = Blueprint('api_rank', __name__)

Expand Down
6 changes: 3 additions & 3 deletions api/users.py → bombolone/api/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from flask import Blueprint, request, g

# Imports inside Bombolone
from core import users
from core.utils import jsonify
from decorators import authentication, check_rank, get_hash
from bombolone.core import users
from bombolone.core.utils import jsonify
from bombolone.decorators import authentication, check_rank, get_hash

api_users = Blueprint('api_users', __name__)

Expand Down
9 changes: 7 additions & 2 deletions app.py → bombolone/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ def enumerate_thing(context, key):
app.jinja_env.globals['len'] = contextfunction(len_thing)
app.jinja_env.globals['enumerate'] = contextfunction(enumerate_thing)
app.jinja_env.filters['msg'] = msg_status

if __name__ == '__main__':


def main():
app.run(host='0.0.0.0', port=config.PORT)


if __name__ == '__main__':
main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions core/hash_table.py → bombolone/core/hash_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from flask import g

# Imports inside Bombolone
from core.languages import Languages
from core.validators import CheckValue
from decorators import check_rank
import model.hash_table
from bombolone.core.languages import Languages
from bombolone.core.validators import CheckValue
from bombolone.decorators import check_rank
import bombolone.model.hash_table

check = CheckValue()
languages_object = Languages()
Expand Down
18 changes: 9 additions & 9 deletions core/languages.py → bombolone/core/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from flask import g, request, session

# Imports inside Bombolone
import model.languages
import bombolone.model.languages

LIST_LANGUAGES = ['ar','cn','de','en','es','fr','gr','it','jp','pt','ru','tr']

Expand All @@ -29,7 +29,7 @@ def available_lang(self):
{u'en': u'English', u'it': u'Italiano'}
"""
return { x['code'] : x['value'][x['code']] for x in model.languages.find(check=True)}
return { x['code'] : x['value'][x['code']] for x in bombolone.model.languages.find(check=True)}

@property
def all_lang(self):
Expand All @@ -38,7 +38,7 @@ def all_lang(self):
Return the entire collection sorted by code.
"""
return model.languages.find(sorted_by='code')
return bombolone.model.languages.find(sorted_by='code')

def get_all_lang_by_code(self, code):
"""
Expand All @@ -65,7 +65,7 @@ def get_all_lang_by_code(self, code):
}
"""
return model.languages.find(code=code, only_one=True)
return bombolone.model.languages.find(code=code, only_one=True)

@property
def available_lang_by_tuple(self):
Expand Down Expand Up @@ -130,8 +130,8 @@ def update(self):
check = True
else:
check = False
language = model.languages.find(code=code, only_one=True)
model.languages.update(language_id=language['_id'], check=check)
language = bombolone.model.languages.find(code=code, only_one=True)
bombolone.model.languages.update(language_id=language['_id'], check=check)
self.message = g.languages_msg('success_update')
self.status = 'msg msg-success'

Expand Down Expand Up @@ -191,9 +191,9 @@ def change(lang=None, my_id=None):
# With the user logged set the language in his profile,
# but the user isn't logged set the language inside the session.
if my_id:
model.users.update(item_id=my_id,
lan=lang,
language=g.available_languages[lang])
bombolone.model.users.update(item_id=my_id,
lan=lang,
language=g.available_languages[lang])
else:
session['language'] = lang
data = {
Expand Down
6 changes: 3 additions & 3 deletions core/login.py → bombolone/core/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
:license: BSD (See LICENSE for details)
"""
# Imports inside Bombolone
import model.users
from config import NOTACTIVATED
from core.utils import create_password
import bombolone.model.users
from bombolone.config import NOTACTIVATED
from bombolone.core.utils import create_password

def sign_in(username_or_email=None,
password=None,
Expand Down
10 changes: 5 additions & 5 deletions core/pages.py → bombolone/core/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
from bson import ObjectId

# Imports inside bombolone
import model.pages
from core.utils import ensure_objectid
from decorators import check_rank, get_hash
from core.languages import Languages
from core.validators import CheckValue
import bombolone.model.pages
from bombolone.core.utils import ensure_objectid
from bombolone.decorators import check_rank, get_hash
from bombolone.core.languages import Languages
from bombolone.core.validators import CheckValue

MODULE_DIR = 'modules/pages'
pages = Blueprint('pages', __name__)
Expand Down
8 changes: 4 additions & 4 deletions core/rank.py → bombolone/core/rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
:license: BSD (See LICENSE for details)
"""
# Imports inside Bombolone
from core.utils import ensure_objectid
from core.validators import CheckValue
import model.ranks
import model.users
from bombolone.core.utils import ensure_objectid
from bombolone.core.validators import CheckValue
import bombolone.model.ranks
import bombolone.model.users

check = CheckValue()

Expand Down
4 changes: 2 additions & 2 deletions core/upload.py → bombolone/core/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
from PIL import Image

# Imports inside Bombolone
from config import (EXTENSIONS, ALLOWED_EXTENSIONS, ALLOWED_ALL_EXTENSIONS,
from bombolone.config import (EXTENSIONS, ALLOWED_EXTENSIONS, ALLOWED_ALL_EXTENSIONS,
UP_AVATARS_FOLDER)
from core.utils import get_extension, linkify
from bombolone.core.utils import get_extension, linkify

AVATAR_IMAGE_SIZE = {
"xsmall": (40, 40),
Expand Down
14 changes: 7 additions & 7 deletions core/users.py → bombolone/core/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
from flask import request, g

# Imports inside Bombolone
import model.users
from config import UP_AVATARS_TMP_FOLDER, ACTIVATED
from decorators import check_rank, get_hash
from core.languages import LIST_LANGUAGES
from core.utils import create_password, ensure_objectid, get_extension
from core.upload import UploadAvatar, AVATAR_IMAGE_SIZE
from core.validators import CheckValue
import bombolone.model.users
from bombolone.config import UP_AVATARS_TMP_FOLDER, ACTIVATED
from bombolone.decorators import check_rank, get_hash
from bombolone.core.languages import LIST_LANGUAGES
from bombolone.core.utils import create_password, ensure_objectid, get_extension
from bombolone.core.upload import UploadAvatar, AVATAR_IMAGE_SIZE
from bombolone.core.validators import CheckValue

check = CheckValue()

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from flask import current_app

# Imports inside Bombolone
import model.hash_table
import bombolone.model.hash_table

def get_hash_map(module, lan):
""" """
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added bombolone/dump/bombolone/js.bson
Binary file not shown.
1 change: 1 addition & 0 deletions bombolone/dump/bombolone/js.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"bombolone.js"}]}
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions model/__init__.py → bombolone/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
from pymongo.errors import PyMongoError

# Imports inside Bombolone
from config import PORT_DATABASE, DATABASE
from bombolone import config

# Create db - The first step when working with PyMongo is to create
# a Connection to the running mongod instance.
try:
if PORT_DATABASE:
connection = Connection(port=PORT_DATABASE)
if config.PORT_DATABASE:
connection = Connection(port=config.PORT_DATABASE)
else:
connection = Connection()
db = connection[DATABASE]
db = connection[config.DATABASE]
except PyMongoError, e:
db = None
print 'Error Database connection at PORT : {}'.format(PORT_DATABASE)
print 'Error Database connection at PORT : {}'.format(config.PORT_DATABASE)
4 changes: 2 additions & 2 deletions model/hash_table.py → bombolone/model/hash_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
:license: BSD (See LICENSE for details)
"""
# Imports inside Bombolone
from model import db
from bombolone.model import db
from model_engine import db_engine
from core.utils import ensure_objectid
from bombolone.core.utils import ensure_objectid

def find(hash_table_id=None,
name=None,
Expand Down
2 changes: 1 addition & 1 deletion model/js.py → bombolone/model/js.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
:license: BSD (See LICENSE for details)
"""
# Imports inside Bombolone
from model import db
from bombolone.model import db
from model_engine import db_engine

def find(file_name=None,
Expand Down
4 changes: 2 additions & 2 deletions model/languages.py → bombolone/model/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
:license: BSD (See LICENSE for details)
"""
# Imports inside Bombolone
from model import db
from bombolone.model import db
from model_engine import db_engine
from core.utils import ensure_objectid
from bombolone.core.utils import ensure_objectid

def find(name=None,
code=None,
Expand Down
Loading

0 comments on commit acb6a18

Please sign in to comment.