├── tests ├── __init__.py ├── sample_tests.py ├── error_tests.py └── compress_tests.py ├── bookshelf ├── admin │ ├── __init__.py │ ├── forms │ │ ├── __init__.py │ │ └── author_forms.py │ ├── templates │ │ ├── admin_index.htm │ │ └── create_author.htm │ └── controllers.py ├── data │ ├── __init__.py │ └── models.py ├── main │ ├── __init__.py │ ├── templates │ │ ├── authors.htm │ │ └── books.htm │ └── controllers.py ├── cache.py ├── instance │ └── config1.cfg ├── static │ ├── favicon.ico │ ├── images │ │ └── books │ │ │ ├── 15705091.jpg │ │ │ ├── 20911420.jpg │ │ │ ├── 702ec908-9d87-49fe-80a6-ef0bc6a95ee7.jpg │ │ │ ├── e9bf34c2-d1f7-4aef-99d8-846f6ca2404d.jpg │ │ │ └── ef0ceaab-32a8-47fb-ba13-c0b362d970da.jpg │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ ├── glyphicons-halflings-regular.woff2 │ │ └── glyphicons-halflings-regular.svg │ ├── css │ │ ├── main.css │ │ └── bootstrap-theme.min.css │ └── js │ │ └── bootstrap.min.js ├── babel.cfg ├── templates │ ├── 404.htm │ ├── 500.htm │ ├── index.htm │ ├── security │ │ ├── login_user.html │ │ └── register_user.html │ └── layout.htm ├── utils.py ├── translations │ ├── bg │ │ └── LC_MESSAGES │ │ │ └── messages.po │ └── fr │ │ └── LC_MESSAGES │ │ └── messages.po ├── config.py └── __init__.py ├── bin └── README ├── docs └── README ├── run.py ├── .travis.yml ├── pylintrc ├── requirements.txt ├── Makefile ├── .gitignore ├── check.py ├── seed.py └── README.md /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bookshelf/admin/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bookshelf/data/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bookshelf/main/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bookshelf/admin/forms/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bin/README: -------------------------------------------------------------------------------- 1 | Place your scripts here. -------------------------------------------------------------------------------- /docs/README: -------------------------------------------------------------------------------- 1 | Place your project documentation here. -------------------------------------------------------------------------------- /bookshelf/cache.py: -------------------------------------------------------------------------------- 1 | from flask_caching import Cache 2 | 3 | 4 | cache = Cache() 5 | -------------------------------------------------------------------------------- /run.py: -------------------------------------------------------------------------------- 1 | from bookshelf import app 2 | 3 | 4 | if __name__ == "__main__": 5 | app.run() 6 | -------------------------------------------------------------------------------- /bookshelf/instance/config1.cfg: -------------------------------------------------------------------------------- 1 | TESTING=False 2 | DEBUG=False 3 | SQLALCHEMY_DATABASE_URI = '' 4 | SECRET_KEY = '' -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "3.6" 4 | install: 5 | - make restore 6 | script: 7 | - make check 8 | -------------------------------------------------------------------------------- /bookshelf/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damyanbogoev/flask-bookshelf/HEAD/bookshelf/static/favicon.ico -------------------------------------------------------------------------------- /bookshelf/babel.cfg: -------------------------------------------------------------------------------- 1 | [python: **.py] 2 | [jinja2: **/templates/**.htm] 3 | extensions=jinja2.ext.autoescape,jinja2.ext.with_ 4 | -------------------------------------------------------------------------------- /bookshelf/templates/404.htm: -------------------------------------------------------------------------------- 1 | {% extends 'layout.htm' %} 2 | {% block container %} 3 |

Page Not Found

4 | {% endblock %} -------------------------------------------------------------------------------- /bookshelf/templates/500.htm: -------------------------------------------------------------------------------- 1 | {% extends 'layout.htm' %} 2 | {% block container %} 3 |

Something Went Wrong

4 | {% endblock %} -------------------------------------------------------------------------------- /bookshelf/static/images/books/15705091.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damyanbogoev/flask-bookshelf/HEAD/bookshelf/static/images/books/15705091.jpg -------------------------------------------------------------------------------- /bookshelf/static/images/books/20911420.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damyanbogoev/flask-bookshelf/HEAD/bookshelf/static/images/books/20911420.jpg -------------------------------------------------------------------------------- /tests/sample_tests.py: -------------------------------------------------------------------------------- 1 | def test_numbers_3_4(): 2 | assert 3 * 4 == 12 3 | 4 | 5 | def test_strings_a_3(): 6 | assert "a" * 3 == "aaa" 7 | -------------------------------------------------------------------------------- /bookshelf/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damyanbogoev/flask-bookshelf/HEAD/bookshelf/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /bookshelf/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damyanbogoev/flask-bookshelf/HEAD/bookshelf/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /bookshelf/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damyanbogoev/flask-bookshelf/HEAD/bookshelf/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /bookshelf/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damyanbogoev/flask-bookshelf/HEAD/bookshelf/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /bookshelf/templates/index.htm: -------------------------------------------------------------------------------- 1 | {% extends 'layout.htm' %} 2 | {% block container %} 3 |
4 | {{ _('Flask Bookshelf') }} 5 |
6 | {% endblock %} -------------------------------------------------------------------------------- /bookshelf/static/images/books/702ec908-9d87-49fe-80a6-ef0bc6a95ee7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damyanbogoev/flask-bookshelf/HEAD/bookshelf/static/images/books/702ec908-9d87-49fe-80a6-ef0bc6a95ee7.jpg -------------------------------------------------------------------------------- /bookshelf/static/images/books/e9bf34c2-d1f7-4aef-99d8-846f6ca2404d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damyanbogoev/flask-bookshelf/HEAD/bookshelf/static/images/books/e9bf34c2-d1f7-4aef-99d8-846f6ca2404d.jpg -------------------------------------------------------------------------------- /bookshelf/static/images/books/ef0ceaab-32a8-47fb-ba13-c0b362d970da.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damyanbogoev/flask-bookshelf/HEAD/bookshelf/static/images/books/ef0ceaab-32a8-47fb-ba13-c0b362d970da.jpg -------------------------------------------------------------------------------- /bookshelf/utils.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | def get_app_base_path(): 5 | return os.path.dirname(os.path.realpath(__file__)) 6 | 7 | 8 | def get_instance_folder_path(): 9 | return os.path.join(get_app_base_path(), "instance") 10 | -------------------------------------------------------------------------------- /bookshelf/admin/forms/author_forms.py: -------------------------------------------------------------------------------- 1 | from wtforms import Form, TextField, validators 2 | from flask_babel import lazy_gettext as _ 3 | 4 | 5 | class CreateAuthorForm(Form): 6 | names = TextField(_("Names"), [validators.Length(min=5, max=70)]) 7 | -------------------------------------------------------------------------------- /bookshelf/admin/templates/admin_index.htm: -------------------------------------------------------------------------------- 1 | {% extends 'layout.htm' %} 2 | {% block container %} 3 |
4 | {{ _('Create an Author') }} 5 |
6 | {% endblock %} 7 | -------------------------------------------------------------------------------- /pylintrc: -------------------------------------------------------------------------------- 1 | [REPORTS] 2 | # Disable the reporting and just show messages. 3 | reports=no 4 | 5 | [MESSAGES CONTROL] 6 | disable=print-statement,C0103,C0111,R0801,R0903,W0612,W0613 7 | 8 | [TYPECHECK] 9 | generated-members=Column,Integer,String,ForeignKey,backref,relationship,Table,Boolean,query,add,commit 10 | -------------------------------------------------------------------------------- /bookshelf/main/templates/authors.htm: -------------------------------------------------------------------------------- 1 | {% extends 'layout.htm' %} 2 | {% block container %} 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | {% for data in authors %} 13 | 14 | 15 | 16 | 17 | {% endfor %} 18 | 19 |
{{ _('id') }}{{ _('names') }}
{{data.id}}{{data.names}}
20 |
21 | {% endblock %} -------------------------------------------------------------------------------- /bookshelf/admin/templates/create_author.htm: -------------------------------------------------------------------------------- 1 | {% extends 'layout.htm' %} 2 | {% block container %} 3 | {% if form.names.errors %} 4 |
9 | {% endif %} 10 |
11 |
12 | {{ form.csrf_token }} 13 | {{ form.names.label }} {{ form.names(size=20) }} 14 | 15 |
16 |
17 | {% endblock %} 18 | -------------------------------------------------------------------------------- /bookshelf/static/css/main.css: -------------------------------------------------------------------------------- 1 | ul.flashes, ul.errors { 2 | list-style: none; 3 | margin: 10px 10px 0 10px; 4 | padding: 0; 5 | } 6 | 7 | ul.flashes li { 8 | /*background: #DFF2BF;*/ 9 | /*color: #4F8A10;*/ 10 | /*border: 1px solid #81CEC6;*/ 11 | -moz-border-radius: 2px; 12 | -webkit-border-radius: 2px; 13 | padding: 4px; 14 | font-size: 15px; 15 | } 16 | 17 | ul.errors li { 18 | background: #FFBABA; 19 | color: #D8000C; 20 | border: 1px solid #81CEC6; 21 | -moz-border-radius: 2px; 22 | -webkit-border-radius: 2px; 23 | padding: 4px; 24 | font-size: 15px; 25 | } -------------------------------------------------------------------------------- /bookshelf/templates/security/login_user.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.htm' %} 2 | {% block container %} 3 | {% from "security/_macros.html" import render_field_with_errors, render_field %} 4 | {% include "security/_messages.html" %} 5 |

Login

6 |
7 | {{ login_user_form.hidden_tag() }} 8 | {{ render_field_with_errors(login_user_form.email) }} 9 | {{ render_field_with_errors(login_user_form.password) }} 10 | {{ render_field_with_errors(login_user_form.remember) }} 11 | {{ render_field(login_user_form.next) }} 12 | {{ render_field(login_user_form.submit) }} 13 |
14 | {% endblock %} 15 | -------------------------------------------------------------------------------- /bookshelf/templates/security/register_user.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.htm' %} 2 | {% block container %} 3 | {% from "security/_macros.html" import render_field_with_errors, render_field %} 4 | {% include "security/_messages.html" %} 5 |

Register

6 |
7 | {{ register_user_form.hidden_tag() }} 8 | {{ render_field_with_errors(register_user_form.email) }} 9 | {{ render_field_with_errors(register_user_form.password) }} 10 | {% if register_user_form.password_confirm %} 11 | {{ render_field_with_errors(register_user_form.password_confirm) }} 12 | {% endif %} 13 | {{ render_field(register_user_form.submit) }} 14 |
15 | {% endblock %} 16 | -------------------------------------------------------------------------------- /bookshelf/main/controllers.py: -------------------------------------------------------------------------------- 1 | from flask import Blueprint, current_app, render_template 2 | from bookshelf.cache import cache 3 | from bookshelf.data.models import Author, Book 4 | 5 | 6 | main = Blueprint("main", __name__, template_folder="templates") 7 | 8 | 9 | @main.route("/books/") 10 | @cache.cached(300) 11 | def display_books(): 12 | books = [book for book in Book.query.all()] 13 | current_app.logger.info("Displaying all books.") 14 | 15 | return render_template("books.htm", books=books) 16 | 17 | 18 | @main.route("/authors/") 19 | @cache.cached(300) 20 | def display_authors(): 21 | authors = [author for author in Author.query.all()] 22 | current_app.logger.info("Displaying all authors.") 23 | 24 | return render_template("authors.htm", authors=authors) 25 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | astroid==1.6.3 2 | autopep8==1.3.5 3 | Babel==2.9.1 4 | bcrypt==3.1.4 5 | blinker==1.4 6 | cffi==1.11.5 7 | click==6.7 8 | colorama==0.3.9 9 | Flask==1.0.2 10 | Flask-Babel==0.11.2 11 | Flask-BabelEx==0.9.3 12 | Flask-Caching==1.4.0 13 | Flask-Compress==1.4.0 14 | Flask-Login==0.4.1 15 | Flask-Mail==0.9.1 16 | Flask-Principal==0.4.0 17 | Flask-Security==3.0.0 18 | Flask-SQLAlchemy==2.3.2 19 | Flask-WTF==0.14.2 20 | healthcheck==1.3.3 21 | isort==4.3.4 22 | itsdangerous==0.24 23 | Jinja2==2.11.3 24 | lazy-object-proxy==1.3.1 25 | logilab-common==1.4.1 26 | MarkupSafe==1.0 27 | mccabe==0.6.1 28 | nose==1.3.7 29 | passlib==1.7.1 30 | pycodestyle==2.4.0 31 | pycparser==2.18 32 | pylint==1.8.4 33 | pytz==2018.4 34 | six==1.11.0 35 | speaklater==1.3 36 | SQLAlchemy==1.3.0 37 | Werkzeug==0.15.5 38 | wrapt==1.10.11 39 | WTForms==2.1 40 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Self-Documented Makefile https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html 2 | 3 | .PHONY: restore check lint test check help 4 | 5 | default: help 6 | 7 | restore: ## installs the dependencies based on the requirements file 8 | @pip install -r requirements.txt 9 | 10 | lint: ## runs pylint 11 | @echo "linting packages and modules ..." 12 | @pylint bookshelf 13 | @pylint tests 14 | @pylint check.py 15 | 16 | test: ## runs tests 17 | @echo "running tests ..." 18 | @nosetests 19 | 20 | check: lint test ## checks the runnable 21 | @if [ $$? -eq 0 ] ; then echo "NO ISSUES FOUND." ; else echo "ISSUES DETECTED." ; fi 22 | 23 | run: ## runs the app 24 | @echo "starting the application ..." 25 | @python run.py 26 | 27 | help: 28 | @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' -------------------------------------------------------------------------------- /bookshelf/main/templates/books.htm: -------------------------------------------------------------------------------- 1 | {% extends 'layout.htm' %} 2 | {% block container %} 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {% for data in books %} 15 | {# Checks if book is marked as hidden #} 16 | {%- if data.hidden %}{% continue %}{% endif %} 17 | 18 | 22 | 23 | 24 | 25 | 26 | {% endfor %} 27 | 28 |
{{ _('cover') }}{{ _('title') }}{{ _('author') }}{{ _('rating') }}
19 | {{title}} 21 | {{data.title | upper}}{{data.author.names}}{{data.rating}}
29 |
30 | {% endblock %} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | *.egg-info/ 23 | .installed.cfg 24 | *.egg 25 | 26 | # PyInstaller 27 | # Usually these files are written by a python script from a template 28 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 29 | *.manifest 30 | *.spec 31 | 32 | # Installer logs 33 | pip-log.txt 34 | pip-delete-this-directory.txt 35 | 36 | # Unit test / coverage reports 37 | htmlcov/ 38 | .tox/ 39 | .coverage 40 | .coverage.* 41 | .cache 42 | nosetests.xml 43 | coverage.xml 44 | *,cover 45 | 46 | # Translations 47 | *.mo 48 | *.pot 49 | 50 | # Django stuff: 51 | *.log 52 | 53 | # Sphinx documentation 54 | docs/_build/ 55 | 56 | # PyBuilder 57 | target/ 58 | 59 | # DB files 60 | *.db 61 | 62 | # VSCode 63 | settings.json -------------------------------------------------------------------------------- /tests/error_tests.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from bookshelf import app 3 | 4 | 5 | class ErrorTests(unittest.TestCase): 6 | @classmethod 7 | def setUpClass(cls): 8 | pass 9 | 10 | @classmethod 11 | def tearDownClass(cls): 12 | pass 13 | 14 | def setUp(self): 15 | self.app = app.test_client() 16 | self.app.testing = True 17 | 18 | def tearDown(self): 19 | pass 20 | 21 | def test_pagenotfound_statuscode(self): 22 | result = self.app.get("/bg/missing-page/") 23 | 24 | self.assertEqual(result.status_code, 404) 25 | 26 | def test_pagenotfound_data(self): 27 | result = self.app.get("/bg/missing-page/") 28 | 29 | self.assertIn("Not Found", result.data.decode("utf-8")) 30 | 31 | def test_unhandledexception_code(self): 32 | result = self.app.put("/books") 33 | 34 | self.assertEqual(result.status_code, 500) 35 | 36 | def test_unhandledexception_data(self): 37 | result = self.app.put("/books") 38 | 39 | self.assertIn("Something Went Wrong", result.data.decode("utf-8")) 40 | -------------------------------------------------------------------------------- /check.py: -------------------------------------------------------------------------------- 1 | import os 2 | from flask import Flask 3 | from healthcheck import HealthCheck, EnvironmentDump 4 | from bookshelf.config import config 5 | 6 | 7 | app = Flask(__name__) 8 | config_name = os.getenv("FLASK_CONFIGURATION", "default") 9 | app.config.from_object(config[config_name]) 10 | app.config.from_pyfile("config.cfg", silent=True) 11 | 12 | health = HealthCheck(app, "/healthcheck") 13 | envdump = EnvironmentDump( 14 | app, 15 | "/environment", 16 | include_python=True, 17 | include_os=False, 18 | include_process=False, 19 | include_config=True, 20 | ) 21 | 22 | 23 | def sqlite_available(): 24 | # add precise check against the database 25 | return True, "sqlite ok" 26 | 27 | 28 | health.add_check(sqlite_available) 29 | 30 | 31 | def application_data(): 32 | return { 33 | "maintainer": "Damyan Bogoev", 34 | "git_repo": "https://github.com/damyanbogoev/flask-bookshelf", 35 | } 36 | 37 | 38 | envdump.add_section("application", application_data) 39 | 40 | 41 | if __name__ == "__main__": 42 | app.run(host=os.getenv("IP", "0.0.0.0"), port=int(os.getenv("PORT", 8080))) 43 | -------------------------------------------------------------------------------- /tests/compress_tests.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from bookshelf import app 3 | 4 | 5 | class CompressTests(unittest.TestCase): 6 | def setUp(self): 7 | self.app = app 8 | self.client = app.test_client() 9 | self.client.testing = True 10 | 11 | def tearDown(self): 12 | pass 13 | 14 | def test_mimetypes(self): 15 | defaults = [ 16 | "text/html", 17 | "text/css", 18 | "text/xml", 19 | "application/json", 20 | "application/javascript", 21 | ] 22 | 23 | self.assertEqual(self.app.config["COMPRESS_MIMETYPES"], defaults) 24 | 25 | def test_level(self): 26 | self.assertEqual(self.app.config["COMPRESS_LEVEL"], 6) 27 | 28 | def test_min_size(self): 29 | self.assertEqual(self.app.config["COMPRESS_MIN_SIZE"], 500) 30 | 31 | def test_status_code(self): 32 | headers = [("Accept-Encoding", "gzip")] 33 | 34 | response = self.client.options("/", headers=headers) 35 | 36 | self.assertEqual(response.status_code, 200) 37 | 38 | def test_content_encoding(self): 39 | headers = [("Accept-Encoding", "gzip")] 40 | 41 | response = self.client.options("/", headers=headers) 42 | 43 | self.assertEqual(response.content_encoding, "gzip") 44 | -------------------------------------------------------------------------------- /bookshelf/admin/controllers.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import exc 2 | from flask import Blueprint, render_template, flash 3 | from flask import current_app, redirect, request, url_for 4 | from flask_security.decorators import roles_required 5 | from bookshelf.admin.forms.author_forms import CreateAuthorForm 6 | from bookshelf.cache import cache 7 | from bookshelf.data.models import Author, db 8 | 9 | 10 | admin = Blueprint("admin", __name__, template_folder="templates") 11 | 12 | 13 | @admin.route("/") 14 | @roles_required("admin") 15 | def index(): 16 | return render_template("admin_index.htm") 17 | 18 | 19 | @admin.route("/author/create", methods=["GET", "POST"]) 20 | @roles_required("admin") 21 | def create_author(): 22 | form = CreateAuthorForm(request.form) 23 | if request.method == "POST" and form.validate(): 24 | names = form.names.data 25 | current_app.logger.info("Adding a new author %s.", (names)) 26 | author = Author(names) 27 | 28 | try: 29 | db.session.add(author) 30 | db.session.commit() 31 | cache.clear() 32 | flash("Author successfully created.") 33 | except exc.SQLAlchemyError as e: 34 | flash("Author was not created.") 35 | current_app.logger.error(e) 36 | 37 | return redirect(url_for("admin.create_author")) 38 | 39 | return redirect(url_for("main.display_authors")) 40 | 41 | return render_template("create_author.htm", form=form) 42 | -------------------------------------------------------------------------------- /seed.py: -------------------------------------------------------------------------------- 1 | from flask_security.utils import encrypt_password 2 | from bookshelf.data.models import db, Author, Book 3 | from bookshelf import app 4 | 5 | 6 | def create_authors_and_books(ctx): 7 | author1 = Author("Ivan Vazov") 8 | author2 = Author("Hristo Botev") 9 | 10 | book1 = Book("Epic of the Forgotten", author1, "15705091.jpg", 5) 11 | book2 = Book("The Poems of Hristo Botev", author2, "20911420.jpg", 5) 12 | 13 | ctx.session.add(author1) 14 | ctx.session.add(author2) 15 | ctx.session.add(book1) 16 | ctx.session.add(book2) 17 | 18 | ctx.session.commit() 19 | 20 | 21 | def create_roles(ctx): 22 | ctx.create_role(name="admin") 23 | ctx.commit() 24 | 25 | 26 | def create_users(ctx): 27 | users = [ 28 | ("admin@test.com", "admin", "1234", ["admin"], True), 29 | ("user@test.com", "user", "6789", [], True), 30 | ] 31 | for user in users: 32 | email = user[0] 33 | username = user[1] 34 | password = user[2] 35 | is_active = user[4] 36 | if password is not None: 37 | password = encrypt_password(password) 38 | roles = [ctx.find_or_create_role(rn) for rn in user[3]] 39 | ctx.commit() 40 | user = ctx.create_user(email=email, password=password, active=is_active) 41 | ctx.commit() 42 | for role in roles: 43 | ctx.add_role_to_user(user, role) 44 | ctx.commit() 45 | 46 | 47 | data_store = app.security.datastore 48 | with app.app_context(): 49 | db.drop_all() 50 | db.create_all() 51 | 52 | create_authors_and_books(db) 53 | create_roles(data_store) 54 | create_users(data_store) 55 | -------------------------------------------------------------------------------- /bookshelf/translations/bg/LC_MESSAGES/messages.po: -------------------------------------------------------------------------------- 1 | # Bulgarian translations for PROJECT. 2 | # Copyright (C) 2016 ORGANIZATION 3 | # This file is distributed under the same license as the PROJECT project. 4 | # FIRST AUTHOR , 2016. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: PROJECT VERSION\n" 9 | "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 10 | "POT-Creation-Date: 2016-01-03 13:47+0200\n" 11 | "PO-Revision-Date: 2016-01-03 13:48+0200\n" 12 | "Last-Translator: \n" 13 | "Language: bg\n" 14 | "Language-Team: bg \n" 15 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=utf-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | "Generated-By: Babel 2.2.0\n" 20 | "X-Generator: Poedit 1.8.6\n" 21 | 22 | #: bookshelf/admin/forms/author_forms.py:6 23 | msgid "Names" 24 | msgstr "Имена" 25 | 26 | #: bookshelf/admin/templates/admin_index.htm:4 27 | msgid "Create an Author" 28 | msgstr "Създайте автор" 29 | 30 | #: bookshelf/admin/templates/create_author.htm:14 31 | msgid "Create" 32 | msgstr "Създайте" 33 | 34 | #: bookshelf/main/templates/authors.htm:7 35 | msgid "id" 36 | msgstr "id" 37 | 38 | #: bookshelf/main/templates/authors.htm:8 39 | msgid "names" 40 | msgstr "имена" 41 | 42 | #: bookshelf/templates/index.htm:4 bookshelf/templates/layout.htm:18 43 | msgid "Flask Bookshelf" 44 | msgstr "Flask Лавица за Книга" 45 | 46 | #: bookshelf/templates/layout.htm:22 47 | msgid "Authors" 48 | msgstr "Автори" 49 | 50 | #: bookshelf/templates/layout.htm:23 51 | msgid "Books" 52 | msgstr "Книги" 53 | 54 | #: bookshelf/templates/layout.htm:27 55 | msgid "Admin" 56 | msgstr "Админ" 57 | 58 | #: bookshelf/templates/layout.htm:30 59 | msgid "Log In" 60 | msgstr "Вход" 61 | 62 | #: bookshelf/templates/layout.htm:32 63 | msgid "Log Out" 64 | msgstr "Изход" 65 | -------------------------------------------------------------------------------- /bookshelf/translations/fr/LC_MESSAGES/messages.po: -------------------------------------------------------------------------------- 1 | # French translations for PROJECT. 2 | # Copyright (C) 2016 ORGANIZATION 3 | # This file is distributed under the same license as the PROJECT project. 4 | # FIRST AUTHOR , 2016. 5 | # 6 | msgid "" 7 | msgstr "" 8 | "Project-Id-Version: PROJECT VERSION\n" 9 | "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" 10 | "POT-Creation-Date: 2016-01-03 13:47+0200\n" 11 | "PO-Revision-Date: 2016-01-03 13:51+0200\n" 12 | "Language: fr\n" 13 | "Language-Team: fr \n" 14 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" 15 | "MIME-Version: 1.0\n" 16 | "Content-Type: text/plain; charset=utf-8\n" 17 | "Content-Transfer-Encoding: 8bit\n" 18 | "Generated-By: Babel 2.2.0\n" 19 | "Last-Translator: \n" 20 | "X-Generator: Poedit 1.8.6\n" 21 | 22 | #: bookshelf/admin/forms/author_forms.py:6 23 | msgid "Names" 24 | msgstr "Noms" 25 | 26 | #: bookshelf/admin/templates/admin_index.htm:4 27 | msgid "Create an Author" 28 | msgstr "Ajouter un auteur" 29 | 30 | #: bookshelf/admin/templates/create_author.htm:14 31 | msgid "Create" 32 | msgstr "Ajouter" 33 | 34 | #: bookshelf/main/templates/authors.htm:7 35 | msgid "id" 36 | msgstr "id" 37 | 38 | #: bookshelf/main/templates/authors.htm:8 39 | msgid "names" 40 | msgstr "noms" 41 | 42 | #: bookshelf/templates/index.htm:4 bookshelf/templates/layout.htm:18 43 | msgid "Flask Bookshelf" 44 | msgstr "Flask Bookshelf" 45 | 46 | #: bookshelf/templates/layout.htm:22 47 | msgid "Authors" 48 | msgstr "Auteurs" 49 | 50 | #: bookshelf/templates/layout.htm:23 51 | msgid "Books" 52 | msgstr "Livres" 53 | 54 | #: bookshelf/templates/layout.htm:27 55 | msgid "Admin" 56 | msgstr "Administrateur" 57 | 58 | #: bookshelf/templates/layout.htm:30 59 | msgid "Log In" 60 | msgstr "Se connecter" 61 | 62 | #: bookshelf/templates/layout.htm:32 63 | msgid "Log Out" 64 | msgstr "Se déconnecter" 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flask Series [![Travic CI](https://travis-ci.org/damyanbogoev/flask-bookshelf.svg?style=flat)](https://travis-ci.org/damyanbogoev/flask-bookshelf) 2 | 3 | A project describing how to implement a Flask based application. 4 | 5 | Detailed information about the Flask Series steps can be found here. 6 | 7 |
    8 |
  1. Prepare the Environment
  2. 9 |
  3. Structure the Application
  4. 10 |
  5. Application Configuration
  6. 11 |
  7. Templating
  8. 12 |
  9. Model
  10. 13 |
  11. Testing
  12. 14 |
  13. Views and Web Forms
  14. 15 |
  15. Error Management
  16. 16 |
  17. Security
  18. 17 |
  19. Optimizations: Caching, GZIP Compression and CDN
  20. 18 |
  21. Health Checking and Monitoring
  22. 19 |
  23. Internationalization
  24. 20 |
  25. Deployment
  26. 21 |
22 | 23 | *The demo application is updated with the latest major Flask 1.0 release.* 24 | -------------------------------------------------------------------------------- /bookshelf/data/models.py: -------------------------------------------------------------------------------- 1 | from flask_sqlalchemy import SQLAlchemy 2 | from flask_security import UserMixin, RoleMixin 3 | 4 | db = SQLAlchemy() 5 | 6 | 7 | class Book(db.Model): 8 | id = db.Column(db.Integer, primary_key=True) 9 | title = db.Column(db.String(80)) 10 | rating = db.Column(db.Integer) 11 | image = db.Column(db.String(30)) 12 | author_id = db.Column(db.Integer, db.ForeignKey("author.id")) 13 | author = db.relationship("Author", backref=db.backref("books", lazy="joined")) 14 | 15 | def __init__(self, title, author, image=None, rating=0): 16 | self.title = title 17 | self.author = author 18 | self.image = image 19 | self.rating = rating 20 | 21 | def __repr__(self): 22 | return "" % (self.title) 23 | 24 | 25 | class Author(db.Model): 26 | id = db.Column(db.Integer, primary_key=True) 27 | names = db.Column(db.String(100), unique=True) 28 | 29 | def __init__(self, names): 30 | self.names = names 31 | 32 | def __repr__(self): 33 | return "" % (self.names) 34 | 35 | 36 | roles_users = db.Table( 37 | "roles_users", 38 | db.Column("user_id", db.Integer(), db.ForeignKey("user.id")), 39 | db.Column("role_id", db.Integer(), db.ForeignKey("role.id")), 40 | ) 41 | 42 | 43 | class Role(db.Model, RoleMixin): 44 | id = db.Column(db.Integer(), primary_key=True) 45 | name = db.Column(db.String(80), unique=True) 46 | description = db.Column(db.String(255)) 47 | 48 | def __init__(self, name): 49 | self.name = name 50 | 51 | def __repr__(self): 52 | return "" % (self.name) 53 | 54 | 55 | class User(db.Model, UserMixin): 56 | id = db.Column(db.Integer, primary_key=True) 57 | email = db.Column(db.String(255), unique=True) 58 | password = db.Column(db.String(255)) 59 | active = db.Column(db.Boolean()) 60 | roles = db.relationship( 61 | "Role", secondary=roles_users, backref=db.backref("users", lazy="dynamic") 62 | ) 63 | 64 | def __init__(self, email, password, active, roles): 65 | self.email = email 66 | self.password = password 67 | self.active = active 68 | self.roles = roles 69 | 70 | def __repr__(self): 71 | return "" % (self.email) 72 | -------------------------------------------------------------------------------- /bookshelf/templates/layout.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Flask Bookshelf 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 51 |
52 | {% with messages = get_flashed_messages() %} {% if messages %} 53 |
    54 | {% for message in messages %} 55 |
  • {{ message }}
  • 56 | {% endfor %} 57 |
58 |
{% endif %} {% endwith %} {% block container %}{% endblock %} 59 |
60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /bookshelf/config.py: -------------------------------------------------------------------------------- 1 | import os 2 | import logging 3 | from flask_compress import Compress 4 | from flask_security import Security, SQLAlchemyUserDatastore 5 | from bookshelf.data.models import db, Role, User 6 | 7 | 8 | class BaseConfig(object): 9 | DEBUG = False 10 | TESTING = False 11 | # sqlite :memory: identifier is the default if no filepath is present 12 | SQLALCHEMY_DATABASE_URI = "sqlite://" 13 | SQLALCHEMY_TRACK_MODIFICATIONS = False 14 | SECRET_KEY = "1d94e52c-1c89-4515-b87a-f48cf3cb7f0b" 15 | LOGGING_FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s" 16 | LOGGING_LOCATION = "bookshelf.log" 17 | LOGGING_LEVEL = logging.DEBUG 18 | SECURITY_PASSWORD_SALT = "8312hjf123" 19 | CACHE_TYPE = "simple" 20 | COMPRESS_MIMETYPES = [ 21 | "text/html", 22 | "text/css", 23 | "text/xml", 24 | "application/json", 25 | "application/javascript", 26 | ] 27 | COMPRESS_LEVEL = 6 28 | COMPRESS_MIN_SIZE = 500 29 | SUPPORTED_LANGUAGES = {"bg": "Bulgarian", "en": "English", "fr": "Francais"} 30 | BABEL_DEFAULT_LOCALE = "en" 31 | BABEL_DEFAULT_TIMEZONE = "UTC" 32 | 33 | 34 | class DevelopmentConfig(BaseConfig): 35 | DEBUG = True 36 | TESTING = False 37 | ENV = "dev" 38 | SQLALCHEMY_DATABASE_URI = "sqlite:///bookshelf.db" 39 | SECRET_KEY = "a9eec0e0-23b7-4788-9a92-318347b9a39f" 40 | 41 | 42 | class StagingConfig(BaseConfig): 43 | DEBUG = False 44 | TESTING = True 45 | ENV = "staging" 46 | SQLALCHEMY_DATABASE_URI = "sqlite://" 47 | SECRET_KEY = "792842bc-c4df-4de1-9177-d5207bd9faa6" 48 | 49 | 50 | class ProductionConfig(BaseConfig): 51 | DEBUG = False 52 | TESTING = False 53 | ENV = "prod" 54 | SQLALCHEMY_DATABASE_URI = "sqlite://" 55 | SECRET_KEY = "8c0caeb1-6bb2-4d2d-b057-596b2dcab18e" 56 | 57 | 58 | config = { 59 | "dev": "bookshelf.config.DevelopmentConfig", 60 | "staging": "bookshelf.config.StagingConfig", 61 | "prod": "bookshelf.config.ProductionConfig", 62 | "default": "bookshelf.config.DevelopmentConfig", 63 | } 64 | 65 | 66 | def configure_app(app): 67 | config_name = os.getenv("FLASK_CONFIGURATION", "default") 68 | app.config.from_object(config[config_name]) 69 | app.config.from_pyfile("config.cfg", silent=True) 70 | # Configure logging 71 | handler = logging.FileHandler(app.config["LOGGING_LOCATION"]) 72 | handler.setLevel(app.config["LOGGING_LEVEL"]) 73 | formatter = logging.Formatter(app.config["LOGGING_FORMAT"]) 74 | handler.setFormatter(formatter) 75 | app.logger.addHandler(handler) 76 | # Configure Security 77 | user_datastore = SQLAlchemyUserDatastore(db, User, Role) 78 | app.security = Security(app, user_datastore) 79 | # Configure Compressing 80 | Compress(app) 81 | -------------------------------------------------------------------------------- /bookshelf/__init__.py: -------------------------------------------------------------------------------- 1 | from flask import abort, Flask, g, render_template, request, current_app 2 | from flask_babel import Babel 3 | from flask_security import current_user 4 | from bookshelf.utils import get_instance_folder_path 5 | from bookshelf.main.controllers import main 6 | from bookshelf.admin.controllers import admin 7 | from bookshelf.cache import cache 8 | from bookshelf.config import configure_app 9 | from bookshelf.data.models import db 10 | 11 | app = Flask( 12 | __name__, 13 | instance_path=get_instance_folder_path(), 14 | instance_relative_config=True, 15 | template_folder="templates", 16 | ) 17 | 18 | babel = Babel(app) 19 | configure_app(app) 20 | cache.init_app(app) 21 | db.init_app(app) 22 | app.jinja_env.add_extension("jinja2.ext.loopcontrols") 23 | 24 | 25 | @app.url_defaults 26 | def set_language_code(endpoint, values): 27 | if "lang_code" in values or not g.get("lang_code", None): 28 | return 29 | if app.url_map.is_endpoint_expecting(endpoint, "lang_code"): 30 | values["lang_code"] = g.lang_code 31 | 32 | 33 | @app.url_value_preprocessor 34 | def get_lang_code(endpoint, values): 35 | if values is not None: 36 | g.lang_code = values.pop("lang_code", None) 37 | 38 | 39 | @app.before_request 40 | def ensure_lang_support(): 41 | lang_code = g.get("lang_code", None) 42 | if lang_code and lang_code not in app.config["SUPPORTED_LANGUAGES"].keys(): 43 | abort(404) 44 | 45 | 46 | @babel.localeselector 47 | def get_locale(): 48 | return g.get("lang_code", app.config["BABEL_DEFAULT_LOCALE"]) 49 | 50 | 51 | @babel.timezoneselector 52 | def get_timezone(): 53 | user = g.get("user", None) 54 | if user is not None: 55 | return user.timezone 56 | return "UTC" 57 | 58 | 59 | @app.errorhandler(404) 60 | def page_not_found(error): 61 | current_app.logger.error("Page not found: %s", (request.path, error)) 62 | return render_template("404.htm"), 404 63 | 64 | 65 | @app.errorhandler(500) 66 | def internal_server_error(error): 67 | current_app.logger.error("Server Error: %s", (error)) 68 | return render_template("500.htm"), 500 69 | 70 | 71 | @app.errorhandler(Exception) 72 | def unhandled_exception(error): 73 | current_app.logger.error("Unhandled Exception: %s", (error)) 74 | return render_template("500.htm"), 500 75 | 76 | 77 | @app.context_processor 78 | def inject_data(): 79 | return dict(user=current_user, lang_code=g.get("lang_code", None)) 80 | 81 | 82 | @app.route("/") 83 | @app.route("//") 84 | @cache.cached(300) 85 | def home(lang_code=None): 86 | return render_template("index.htm") 87 | 88 | 89 | app.register_blueprint(main, url_prefix="/main") 90 | app.register_blueprint(main, url_prefix="//main") 91 | app.register_blueprint(admin, url_prefix="/admin") 92 | app.register_blueprint(admin, url_prefix="//admin") 93 | -------------------------------------------------------------------------------- /bookshelf/static/css/bootstrap-theme.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v3.3.4 (http://getbootstrap.com) 3 | * Copyright 2011-2015 Twitter, Inc. 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 | */.btn-danger,.btn-default,.btn-info,.btn-primary,.btn-success,.btn-warning{text-shadow:0 -1px 0 rgba(0,0,0,.2);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 1px rgba(0,0,0,.075)}.btn-danger.active,.btn-danger:active,.btn-default.active,.btn-default:active,.btn-info.active,.btn-info:active,.btn-primary.active,.btn-primary:active,.btn-success.active,.btn-success:active,.btn-warning.active,.btn-warning:active{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,.125);box-shadow:inset 0 3px 5px rgba(0,0,0,.125)}.btn-danger .badge,.btn-default .badge,.btn-info .badge,.btn-primary .badge,.btn-success .badge,.btn-warning .badge{text-shadow:none}.btn.active,.btn:active{background-image:none}.btn-default{text-shadow:0 1px 0 #fff;background-image:-webkit-linear-gradient(top,#fff 0,#e0e0e0 100%);background-image:-o-linear-gradient(top,#fff 0,#e0e0e0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fff),to(#e0e0e0));background-image:linear-gradient(to bottom,#fff 0,#e0e0e0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe0e0e0', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#dbdbdb;border-color:#ccc}.btn-default:focus,.btn-default:hover{background-color:#e0e0e0;background-position:0 -15px}.btn-default.active,.btn-default:active{background-color:#e0e0e0;border-color:#dbdbdb}.btn-default.disabled,.btn-default:disabled,.btn-default[disabled]{background-color:#e0e0e0;background-image:none}.btn-primary{background-image:-webkit-linear-gradient(top,#337ab7 0,#265a88 100%);background-image:-o-linear-gradient(top,#337ab7 0,#265a88 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#265a88));background-image:linear-gradient(to bottom,#337ab7 0,#265a88 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff265a88', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#245580}.btn-primary:focus,.btn-primary:hover{background-color:#265a88;background-position:0 -15px}.btn-primary.active,.btn-primary:active{background-color:#265a88;border-color:#245580}.btn-primary.disabled,.btn-primary:disabled,.btn-primary[disabled]{background-color:#265a88;background-image:none}.btn-success{background-image:-webkit-linear-gradient(top,#5cb85c 0,#419641 100%);background-image:-o-linear-gradient(top,#5cb85c 0,#419641 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5cb85c),to(#419641));background-image:linear-gradient(to bottom,#5cb85c 0,#419641 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff419641', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#3e8f3e}.btn-success:focus,.btn-success:hover{background-color:#419641;background-position:0 -15px}.btn-success.active,.btn-success:active{background-color:#419641;border-color:#3e8f3e}.btn-success.disabled,.btn-success:disabled,.btn-success[disabled]{background-color:#419641;background-image:none}.btn-info{background-image:-webkit-linear-gradient(top,#5bc0de 0,#2aabd2 100%);background-image:-o-linear-gradient(top,#5bc0de 0,#2aabd2 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5bc0de),to(#2aabd2));background-image:linear-gradient(to bottom,#5bc0de 0,#2aabd2 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff2aabd2', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#28a4c9}.btn-info:focus,.btn-info:hover{background-color:#2aabd2;background-position:0 -15px}.btn-info.active,.btn-info:active{background-color:#2aabd2;border-color:#28a4c9}.btn-info.disabled,.btn-info:disabled,.btn-info[disabled]{background-color:#2aabd2;background-image:none}.btn-warning{background-image:-webkit-linear-gradient(top,#f0ad4e 0,#eb9316 100%);background-image:-o-linear-gradient(top,#f0ad4e 0,#eb9316 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f0ad4e),to(#eb9316));background-image:linear-gradient(to bottom,#f0ad4e 0,#eb9316 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffeb9316', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#e38d13}.btn-warning:focus,.btn-warning:hover{background-color:#eb9316;background-position:0 -15px}.btn-warning.active,.btn-warning:active{background-color:#eb9316;border-color:#e38d13}.btn-warning.disabled,.btn-warning:disabled,.btn-warning[disabled]{background-color:#eb9316;background-image:none}.btn-danger{background-image:-webkit-linear-gradient(top,#d9534f 0,#c12e2a 100%);background-image:-o-linear-gradient(top,#d9534f 0,#c12e2a 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9534f),to(#c12e2a));background-image:linear-gradient(to bottom,#d9534f 0,#c12e2a 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc12e2a', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-color:#b92c28}.btn-danger:focus,.btn-danger:hover{background-color:#c12e2a;background-position:0 -15px}.btn-danger.active,.btn-danger:active{background-color:#c12e2a;border-color:#b92c28}.btn-danger.disabled,.btn-danger:disabled,.btn-danger[disabled]{background-color:#c12e2a;background-image:none}.img-thumbnail,.thumbnail{-webkit-box-shadow:0 1px 2px rgba(0,0,0,.075);box-shadow:0 1px 2px rgba(0,0,0,.075)}.dropdown-menu>li>a:focus,.dropdown-menu>li>a:hover{background-color:#e8e8e8;background-image:-webkit-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-o-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f5f5f5),to(#e8e8e8));background-image:linear-gradient(to bottom,#f5f5f5 0,#e8e8e8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);background-repeat:repeat-x}.dropdown-menu>.active>a,.dropdown-menu>.active>a:focus,.dropdown-menu>.active>a:hover{background-color:#2e6da4;background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x}.navbar-default{background-image:-webkit-linear-gradient(top,#fff 0,#f8f8f8 100%);background-image:-o-linear-gradient(top,#fff 0,#f8f8f8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fff),to(#f8f8f8));background-image:linear-gradient(to bottom,#fff 0,#f8f8f8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff8f8f8', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 5px rgba(0,0,0,.075);box-shadow:inset 0 1px 0 rgba(255,255,255,.15),0 1px 5px rgba(0,0,0,.075)}.navbar-default .navbar-nav>.active>a,.navbar-default .navbar-nav>.open>a{background-image:-webkit-linear-gradient(top,#dbdbdb 0,#e2e2e2 100%);background-image:-o-linear-gradient(top,#dbdbdb 0,#e2e2e2 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dbdbdb),to(#e2e2e2));background-image:linear-gradient(to bottom,#dbdbdb 0,#e2e2e2 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdbdbdb', endColorstr='#ffe2e2e2', GradientType=0);background-repeat:repeat-x;-webkit-box-shadow:inset 0 3px 9px rgba(0,0,0,.075);box-shadow:inset 0 3px 9px rgba(0,0,0,.075)}.navbar-brand,.navbar-nav>li>a{text-shadow:0 1px 0 rgba(255,255,255,.25)}.navbar-inverse{background-image:-webkit-linear-gradient(top,#3c3c3c 0,#222 100%);background-image:-o-linear-gradient(top,#3c3c3c 0,#222 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#3c3c3c),to(#222));background-image:linear-gradient(to bottom,#3c3c3c 0,#222 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3c3c3c', endColorstr='#ff222222', GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);background-repeat:repeat-x}.navbar-inverse .navbar-nav>.active>a,.navbar-inverse .navbar-nav>.open>a{background-image:-webkit-linear-gradient(top,#080808 0,#0f0f0f 100%);background-image:-o-linear-gradient(top,#080808 0,#0f0f0f 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#080808),to(#0f0f0f));background-image:linear-gradient(to bottom,#080808 0,#0f0f0f 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff080808', endColorstr='#ff0f0f0f', GradientType=0);background-repeat:repeat-x;-webkit-box-shadow:inset 0 3px 9px rgba(0,0,0,.25);box-shadow:inset 0 3px 9px rgba(0,0,0,.25)}.navbar-inverse .navbar-brand,.navbar-inverse .navbar-nav>li>a{text-shadow:0 -1px 0 rgba(0,0,0,.25)}.navbar-fixed-bottom,.navbar-fixed-top,.navbar-static-top{border-radius:0}@media (max-width:767px){.navbar .navbar-nav .open .dropdown-menu>.active>a,.navbar .navbar-nav .open .dropdown-menu>.active>a:focus,.navbar .navbar-nav .open .dropdown-menu>.active>a:hover{color:#fff;background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x}}.alert{text-shadow:0 1px 0 rgba(255,255,255,.2);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 2px rgba(0,0,0,.05);box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 2px rgba(0,0,0,.05)}.alert-success{background-image:-webkit-linear-gradient(top,#dff0d8 0,#c8e5bc 100%);background-image:-o-linear-gradient(top,#dff0d8 0,#c8e5bc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dff0d8),to(#c8e5bc));background-image:linear-gradient(to bottom,#dff0d8 0,#c8e5bc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffc8e5bc', GradientType=0);background-repeat:repeat-x;border-color:#b2dba1}.alert-info{background-image:-webkit-linear-gradient(top,#d9edf7 0,#b9def0 100%);background-image:-o-linear-gradient(top,#d9edf7 0,#b9def0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9edf7),to(#b9def0));background-image:linear-gradient(to bottom,#d9edf7 0,#b9def0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffb9def0', GradientType=0);background-repeat:repeat-x;border-color:#9acfea}.alert-warning{background-image:-webkit-linear-gradient(top,#fcf8e3 0,#f8efc0 100%);background-image:-o-linear-gradient(top,#fcf8e3 0,#f8efc0 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fcf8e3),to(#f8efc0));background-image:linear-gradient(to bottom,#fcf8e3 0,#f8efc0 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fff8efc0', GradientType=0);background-repeat:repeat-x;border-color:#f5e79e}.alert-danger{background-image:-webkit-linear-gradient(top,#f2dede 0,#e7c3c3 100%);background-image:-o-linear-gradient(top,#f2dede 0,#e7c3c3 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f2dede),to(#e7c3c3));background-image:linear-gradient(to bottom,#f2dede 0,#e7c3c3 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffe7c3c3', GradientType=0);background-repeat:repeat-x;border-color:#dca7a7}.progress{background-image:-webkit-linear-gradient(top,#ebebeb 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#ebebeb 0,#f5f5f5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#ebebeb),to(#f5f5f5));background-image:linear-gradient(to bottom,#ebebeb 0,#f5f5f5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb', endColorstr='#fff5f5f5', GradientType=0);background-repeat:repeat-x}.progress-bar{background-image:-webkit-linear-gradient(top,#337ab7 0,#286090 100%);background-image:-o-linear-gradient(top,#337ab7 0,#286090 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#286090));background-image:linear-gradient(to bottom,#337ab7 0,#286090 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff286090', GradientType=0);background-repeat:repeat-x}.progress-bar-success{background-image:-webkit-linear-gradient(top,#5cb85c 0,#449d44 100%);background-image:-o-linear-gradient(top,#5cb85c 0,#449d44 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5cb85c),to(#449d44));background-image:linear-gradient(to bottom,#5cb85c 0,#449d44 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c', endColorstr='#ff449d44', GradientType=0);background-repeat:repeat-x}.progress-bar-info{background-image:-webkit-linear-gradient(top,#5bc0de 0,#31b0d5 100%);background-image:-o-linear-gradient(top,#5bc0de 0,#31b0d5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#5bc0de),to(#31b0d5));background-image:linear-gradient(to bottom,#5bc0de 0,#31b0d5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de', endColorstr='#ff31b0d5', GradientType=0);background-repeat:repeat-x}.progress-bar-warning{background-image:-webkit-linear-gradient(top,#f0ad4e 0,#ec971f 100%);background-image:-o-linear-gradient(top,#f0ad4e 0,#ec971f 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f0ad4e),to(#ec971f));background-image:linear-gradient(to bottom,#f0ad4e 0,#ec971f 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff0ad4e', endColorstr='#ffec971f', GradientType=0);background-repeat:repeat-x}.progress-bar-danger{background-image:-webkit-linear-gradient(top,#d9534f 0,#c9302c 100%);background-image:-o-linear-gradient(top,#d9534f 0,#c9302c 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9534f),to(#c9302c));background-image:linear-gradient(to bottom,#d9534f 0,#c9302c 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9534f', endColorstr='#ffc9302c', GradientType=0);background-repeat:repeat-x}.progress-bar-striped{background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent)}.list-group{border-radius:4px;-webkit-box-shadow:0 1px 2px rgba(0,0,0,.075);box-shadow:0 1px 2px rgba(0,0,0,.075)}.list-group-item.active,.list-group-item.active:focus,.list-group-item.active:hover{text-shadow:0 -1px 0 #286090;background-image:-webkit-linear-gradient(top,#337ab7 0,#2b669a 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2b669a 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2b669a));background-image:linear-gradient(to bottom,#337ab7 0,#2b669a 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2b669a', GradientType=0);background-repeat:repeat-x;border-color:#2b669a}.list-group-item.active .badge,.list-group-item.active:focus .badge,.list-group-item.active:hover .badge{text-shadow:none}.panel{-webkit-box-shadow:0 1px 2px rgba(0,0,0,.05);box-shadow:0 1px 2px rgba(0,0,0,.05)}.panel-default>.panel-heading{background-image:-webkit-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-o-linear-gradient(top,#f5f5f5 0,#e8e8e8 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f5f5f5),to(#e8e8e8));background-image:linear-gradient(to bottom,#f5f5f5 0,#e8e8e8 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5', endColorstr='#ffe8e8e8', GradientType=0);background-repeat:repeat-x}.panel-primary>.panel-heading{background-image:-webkit-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-o-linear-gradient(top,#337ab7 0,#2e6da4 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#337ab7),to(#2e6da4));background-image:linear-gradient(to bottom,#337ab7 0,#2e6da4 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff337ab7', endColorstr='#ff2e6da4', GradientType=0);background-repeat:repeat-x}.panel-success>.panel-heading{background-image:-webkit-linear-gradient(top,#dff0d8 0,#d0e9c6 100%);background-image:-o-linear-gradient(top,#dff0d8 0,#d0e9c6 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#dff0d8),to(#d0e9c6));background-image:linear-gradient(to bottom,#dff0d8 0,#d0e9c6 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdff0d8', endColorstr='#ffd0e9c6', GradientType=0);background-repeat:repeat-x}.panel-info>.panel-heading{background-image:-webkit-linear-gradient(top,#d9edf7 0,#c4e3f3 100%);background-image:-o-linear-gradient(top,#d9edf7 0,#c4e3f3 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#d9edf7),to(#c4e3f3));background-image:linear-gradient(to bottom,#d9edf7 0,#c4e3f3 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffd9edf7', endColorstr='#ffc4e3f3', GradientType=0);background-repeat:repeat-x}.panel-warning>.panel-heading{background-image:-webkit-linear-gradient(top,#fcf8e3 0,#faf2cc 100%);background-image:-o-linear-gradient(top,#fcf8e3 0,#faf2cc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#fcf8e3),to(#faf2cc));background-image:linear-gradient(to bottom,#fcf8e3 0,#faf2cc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffcf8e3', endColorstr='#fffaf2cc', GradientType=0);background-repeat:repeat-x}.panel-danger>.panel-heading{background-image:-webkit-linear-gradient(top,#f2dede 0,#ebcccc 100%);background-image:-o-linear-gradient(top,#f2dede 0,#ebcccc 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#f2dede),to(#ebcccc));background-image:linear-gradient(to bottom,#f2dede 0,#ebcccc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2dede', endColorstr='#ffebcccc', GradientType=0);background-repeat:repeat-x}.well{background-image:-webkit-linear-gradient(top,#e8e8e8 0,#f5f5f5 100%);background-image:-o-linear-gradient(top,#e8e8e8 0,#f5f5f5 100%);background-image:-webkit-gradient(linear,left top,left bottom,from(#e8e8e8),to(#f5f5f5));background-image:linear-gradient(to bottom,#e8e8e8 0,#f5f5f5 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffe8e8e8', endColorstr='#fff5f5f5', GradientType=0);background-repeat:repeat-x;border-color:#dcdcdc;-webkit-box-shadow:inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.1);box-shadow:inset 0 1px 3px rgba(0,0,0,.05),0 1px 0 rgba(255,255,255,.1)} -------------------------------------------------------------------------------- /bookshelf/static/js/bootstrap.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v3.3.4 (http://getbootstrap.com) 3 | * Copyright 2011-2015 Twitter, Inc. 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 | */ 6 | if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.4",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a(f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.4",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")&&(c.prop("checked")&&this.$element.hasClass("active")?a=!1:b.find(".active").removeClass("active")),a&&c.prop("checked",!this.$element.hasClass("active")).trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active"));a&&this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),c.preventDefault()}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.4",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));return a>this.$items.length-1||0>a?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){return this.sliding?void 0:this.slide("next")},c.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.4",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){b&&3===b.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=c(d),f={relatedTarget:this};e.hasClass("open")&&(e.trigger(b=a.Event("hide.bs.dropdown",f)),b.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger("hidden.bs.dropdown",f)))}))}function c(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.4",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=c(e),g=f.hasClass("open");if(b(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a('',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(this.options.viewport.selector||this.options.viewport),this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c&&c.$tip&&c.$tip.is(":visible")?void(c.hoverState="in"):(c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.options.container?a(this.options.container):this.$element.parent(),p=this.getPosition(o);h="bottom"==h&&k.bottom+m>p.bottom?"top":"top"==h&&k.top-mp.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.width&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){return this.$tip=this.$tip||a(this.options.template)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type)})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;(e||!/destroy|hide/.test(b))&&(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.4",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.4",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.4",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=e?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=a(document.body).height();"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); -------------------------------------------------------------------------------- /bookshelf/static/fonts/glyphicons-halflings-regular.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | --------------------------------------------------------------------------------