diff --git a/.travis.yml b/.travis.yml index 471da5a7..b11b7b3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,12 @@ script: - pip install -r requirements/test.txt - ./tests/lintstats.sh - ./tests/docker_tests.sh - - nose2 + - docker build ./ -t arxiv/base + - nose2 --with-coverage after_success: - coveralls + - if [ "$TRAVIS_BRANCH" == "master" ] && [ -z {$TRAVIS_TAG} ]; then + docker login -u "$DOCKERHUB_USERNAME" -p "$DOCKERHUB_PASSWORD"; + docker tag arxiv/base arxiv/base:${TRAVIS_TAG}; + docker push arxiv/base:${TRAVIS_TAG}; + fi diff --git a/README.md b/README.md index 873dc197..dd8ae9a3 100644 --- a/README.md +++ b/README.md @@ -49,11 +49,11 @@ Add it to your ``requirements.txt`` file. For the time being, we'll distribute directly from GitHub. To use a specific version, for example, you would write: -``-e git://github.com/cul-it/arxiv-base-ui.git@0.1#egg=arxiv-base-ui`` +``-e git://github.com/cul-it/arxiv-base.git@0.1#egg=arxiv-base`` Or if this repo is private, and you want to install a specific commit: -``-e git+ssh://git@github.com/cul-it/arxiv-base-ui.git@d9af6c670afdf6f0fda6d92f7b110dcd60514f4a#egg=arxiv-base-ui`` +``-e git+ssh://git@github.com/cul-it/arxiv-base.git@d9af6c670afdf6f0fda6d92f7b110dcd60514f4a#egg=arxiv-base`` See the [pip documentation](https://pip.pypa.io/en/latest/reference/pip_install/#git) for details. @@ -64,7 +64,7 @@ templates and static files available to you. For example, in your ```python from flask import Flask -from baseui import BaseUI +from arxiv.base import Base from someapp import routes @@ -72,7 +72,7 @@ def create_web_app() -> Flask: app = Flask('someapp') app.config.from_pyfile('config.py') - BaseUI(app) # Registers the base UI blueprint. + Base(app) # Registers the base/UI blueprint. app.register_blueprint(routes.blueprint) # Your blueprint. return app ``` @@ -80,7 +80,7 @@ return app You can now extend base templates, e.g.: ```html -{%- extends "baseui/base.html" %} +{%- extends "base/base.html" %} {% block content %} Hello world! @@ -90,17 +90,17 @@ Hello world! And use static files in your templates, e.g.: ``` -{{ url_for('baseui.static', filename='images/CUL-reduced-white-SMALL.svg') }} +{{ url_for('base.static', filename='images/CUL-reduced-white-SMALL.svg') }} ``` ## Editing and compiling sass The file arxivstyle.css should never be edited directly. It is compiled from arxivstyle.sass with this command from project directory root: -```sass baseui/static/sass/arxivstyle.sass:baseui/static/css/arxivstyle.css``` +```sass base/static/sass/arxivstyle.sass:base/static/css/arxivstyle.css``` or you can use the ``--watch`` option to autocompile on any changed file: -```sass --watch baseui/static/sass/arxivstyle.sass:baseui/static/css/arxivstyle.css``` +```sass --watch base/static/sass/arxivstyle.sass:baseui/static/css/arxivstyle.css``` Bulma source files are included in the ``static/sass`` directory so that variables can be overridden directly during compile. The ``arxivstyle.sass`` file has been written to do this; do not edit it. diff --git a/app.py b/app.py index 0c3bf99c..e411eff8 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,5 @@ """Provides application for development purposes.""" -from base.factory import create_web_app +from arxiv.base.factory import create_web_app app = create_web_app() diff --git a/arxiv/base/config.py b/arxiv/base/config.py index 2c278ccf..118d14d2 100644 --- a/arxiv/base/config.py +++ b/arxiv/base/config.py @@ -3,3 +3,27 @@ import os SERVER_NAME = None + +ARXIV_TWITTER_URL = os.environ.get('ARXIV_TWITTER_URL', + 'https://twitter.com/arxiv') +ARXIV_SEARCH_BOX_URL = os.environ.get('SEARCH_BOX_URL', '/search') +ARXIV_SEARCH_ADVANCED_URL = os.environ.get('ARXIV_SEARCH_ADVANCED_URL', + '/search/advanced') +ARXIV_ACCOUNT_URL = os.environ.get('ACCOUNT_URL', '/user') +ARXIV_LOGIN_URL = os.environ.get('LOGIN_URL', '/user/login') +ARXIV_LOGOUT_URL = os.environ.get('LOGOUT_URL', '/user/logout') +ARXIV_HOME_URL = os.environ.get('ARXIV_HOME_URL', 'https://arxiv.org') +ARXIV_HELP_URL = os.environ.get('ARXIV_HELP_URL', '/help') +ARXIV_CONTACT_URL = os.environ.get('ARXIV_CONTACT_URL', '/help/contact') +ARXIV_BLOG_URL = os.environ.get('ARXIV_BLOG_URL', + "https://blogs.cornell.edu/arxiv/") +ARXIV_WIKI_URL = os.environ.get( + 'ARXIV_WIKI_URL', + "https://confluence.cornell.edu/display/arxivpub/arXiv+Public+Wiki" +) +ARXIV_ACCESSIBILITY_URL = os.environ.get( + 'ARXIV_ACCESSIBILITY_URL', + "mailto:web-accessibility@cornell.edu" +) +ARXIV_LIBRARY_URL = os.environ.get('ARXIV_LIBRARY_URL', + 'https://library.cornell.edu') diff --git a/arxiv/base/routes.py b/arxiv/base/routes.py index 0bfcb29a..7c78149d 100644 --- a/arxiv/base/routes.py +++ b/arxiv/base/routes.py @@ -1,7 +1,7 @@ """Provides routes for verifying base templates.""" -from typing import Any, Tuple -from flask import Blueprint, render_template +from typing import Any, Tuple, Callable, Dict +from flask import Blueprint, render_template, current_app from arxiv import status @@ -12,3 +12,15 @@ def test_page() -> Tuple[dict, int, dict]: """Render the test page.""" return render_template("base/base.html"), status.HTTP_200_OK, {} + + +@blueprint.context_processor +def config_url_builder() -> Dict[str, Callable]: + """Inject a configurable URL factory.""" + def config_url(target: str) -> str: + """Generate a URL from this app's configuration.""" + target = target.upper() + # Will raise a KeyError; that seems reasonable? + url: str = current_app.config[f'ARXIV_{target}_URL'] + return url + return dict(config_url=config_url) diff --git a/arxiv/base/templates/base/footer.html b/arxiv/base/templates/base/footer.html index 5a1708d1..881601ff 100644 --- a/arxiv/base/templates/base/footer.html +++ b/arxiv/base/templates/base/footer.html @@ -1,20 +1,20 @@
diff --git a/arxiv/base/templates/base/header.html b/arxiv/base/templates/base/header.html index 12b1df62..17cfe733 100644 --- a/arxiv/base/templates/base/header.html +++ b/arxiv/base/templates/base/header.html @@ -1,15 +1,15 @@