Skip to content

Commit

Permalink
Merge pull request #18 from cul-it/develop
Browse files Browse the repository at this point in the history
Pre-release merge for v0.2
  • Loading branch information
erickpeirson authored Feb 9, 2018
2 parents 78d12fc + f8a93d1 commit 1fa4c41
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 25 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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[email protected]#egg=arxiv-base-ui``
``-e git://github.com/cul-it/[email protected]#egg=arxiv-base``

Or if this repo is private, and you want to install a specific commit:

``-e git+ssh://[email protected]/cul-it/arxiv-base-ui.git@d9af6c670afdf6f0fda6d92f7b110dcd60514f4a#egg=arxiv-base-ui``
``-e git+ssh://[email protected]/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.
Expand All @@ -64,23 +64,23 @@ 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


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
```

You can now extend base templates, e.g.:

```html
{%- extends "baseui/base.html" %}
{%- extends "base/base.html" %}

{% block content %}
Hello world!
Expand All @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -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()
24 changes: 24 additions & 0 deletions arxiv/base/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:[email protected]"
)
ARXIV_LIBRARY_URL = os.environ.get('ARXIV_LIBRARY_URL',
'https://library.cornell.edu')
16 changes: 14 additions & 2 deletions arxiv/base/routes.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)
12 changes: 6 additions & 6 deletions arxiv/base/templates/base/footer.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<div class="columns" role="navigation" aria-label="Secondary">
<div class="column">
<ul class="nav-spaced">
<li><a href="/help/contact">Contact</a></li>
<li><a href="https://twitter.com/arxiv">Find us on Twitter</a></li>
<li><a href="{{ config_url('contact') }}">Contact</a></li>
<li><a href="{{ config_url('twitter') }}">Find us on Twitter</a></li>
</ul>
</div>
<div class="column">
<ul class="nav-spaced">
<li><a href="https://blogs.cornell.edu/arxiv/">Blog - the latest news</a></li>
<li><a href="https://confluence.cornell.edu/display/arxivpub/arXiv+Public+Wiki">Wiki - project documentation</a></li>
<li><a href="{{ config_url('blog') }}">Blog - the latest news</a></li>
<li><a href="{{ config_url('wiki') }}">Wiki - project documentation</a></li>
</ul>
</div>
<div class="column">
<ul class="nav-spaced">
<li><a href="mailto:web-accessibility@cornell.edu">Web Accessibility Help</a></li>
<li><a href="/help">Help with using arXiv</a></li>
<li><a href="{{ config_url('accessibility') }}">Web Accessibility Help</a></li>
<li><a href="{{ config_url('help') }}">Help with using arXiv</a></li>
</ul>
</div>
</div>
8 changes: 4 additions & 4 deletions arxiv/base/templates/base/header.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!-- contains Cornell logo and sponsor statement -->
<div class="attribution level is-marginless" role="banner">
<div class="level-left">
<a class="level-item" href="https://library.cornell.edu"><img src="{{ url_for('base.static', filename='images/CUL-reduced-white-SMALL.svg') }}" alt="Cornell University Library" width="300" aria-label="logo" /></a>
<a class="level-item" href="{{ config_url('library') }}"><img src="{{ url_for('base.static', filename='images/CUL-reduced-white-SMALL.svg') }}" alt="Cornell University Library" width="300" aria-label="logo" /></a>
</div>
<div class="level-right"><p class="sponsors level-item">We gratefully acknowledge support from<br /> the Simons Foundation and member institutions</p></div>
</div>
<!-- contains arXiv identity and search bar -->
<div class="identity level is-marginless">
<div class="level-left">
<h1 class="level-item"><a href="" aria-label="arxiv-logo">arXiv.org</a></h1>
<h1 class="level-item"><a href="{{ config_url('home') }}" aria-label="arxiv-logo">arXiv.org</a></h1>
</div>
{{ macros.compactsearch('level-right') }}
{{ macros.compactsearch(config_url, 'level-right') }}
</div> <!-- closes identity -->
<div class="user-tools box is-pulled-right" role="navigation" aria-label="User menu"><a href="">Login</a> | <a href="">My Account</a> | <a href="">Logout</a></div>
<div class="user-tools box is-pulled-right" role="navigation" aria-label="User menu"><a href="{{ config_url('login') }}">Login</a> | <a href="{{ config_url('account') }}">My Account</a> | <a href="{{ config_url('logout') }}">Logout</a></div>
6 changes: 3 additions & 3 deletions arxiv/base/templates/base/macros.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{# macros to be available to all templates across arxiv #}

{% macro compactsearch(alignstyle="level-right") -%}
{% macro compactsearch(config_url, alignstyle="level-right") -%}
{# Creates an inline search widget with one input box, a dropdown for field
selection, a button, and two tiny help/advanced links. Can be wrapped with
Bulma's level element to align vertically with other elements in the same
horizontal band. Parameter is a Bulma class that sets overall alignment
within level wrapper, allowed values are level-left or level-right.
#}
<div class="search-block {{ alignstyle }}">
<form class="level-item">
<form class="level-item" method="GET" action="{{ config_url('search_box') }}">
<div class="field has-addons">
<div class="control">
<input class="input is-small" type="text" name="query" placeholder="Search..." aria-label="Search term or terms" />
<p class="help"><a href="">Help</a> | <a href="">Advanced Search</a></p>
<p class="help"><a href="{{ config_url('help') }}">Help</a> | <a href="{{ config_url('search_advanced') }}">Advanced Search</a></p>
</div>
<div class="control">
<div class="select is-small">
Expand Down
1 change: 1 addition & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ jsonschema==2.6.0
mypy==0.560
pylint==1.8.2
coverage==4.4.2
coveralls==1.2.0

0 comments on commit 1fa4c41

Please sign in to comment.