Simply append the current URL (sans querystring) as a ?next= parameter
to the login URL. This will always take us back to the original page
where we were pre-login.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Astonishingly, the great jinja2 does not provide a builtin urlquote filter,
although it is obviously needed. (jina1 had one) This is:
https://github.com/mitsuhiko/jinja2/issues/17
Provide an urlencode filter, based on werkzeug's url_quote_plus function.
This is dead easy to implement and gives us all the freedom we want.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
It complains about a non-compatible license string. so use the
GNU AGPL v3+ string that is listed at
http://pypi.python.org/pypi?%3Aaction=list_classifiers
With this change, we are able to create a pypi mediagoblin package.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
We were using "en" as fallback only when no preferred language matched.
This is obviously bad. Always insert en_US as available locale, so we
can match it with the accept_languages.
Don't set available_locales as mg_global, per discussion with paroneaya,
make it a global var in translate.py
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
In case of no matching translations, target_lang was "None" which
blew up things. Fall back to "en" in case we don't find a
corresponding translation.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Previously we would attempt to satisfy the user's first language
preference, immediately falling back to english if that was not
possible. Now, we will get the best match of the user's preferred
languages.
This requires storing the available locales on app startup, so we
have mg_globals.available_locales ready to compare them against the
list of preferred user languages.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
We only ever served english pages since the switch to werkzeug's requests.
Fix this by actually checking the accepted languages that our web browser
sends and using that or falling back to english.
This is not optimal, imaging our browser sends "klingon, de" as accepted
languages and we happen to not have a klingon translation ready (a deficiency
that should be corrected immediately anyway!!). We would then fall back
to english rather than sending the sensible and pleasant German language
which the user would understand. This will require more backend work though.
Removing the gettext.find() in mg_globals.py. It looked in the wrong directory
anyway (mediagoblin/translations) and as that does not exist, had always returned
None without anyone noticing.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Rather than mentioning a hypothetical module restrictfive, we use the
existing plugin mediagoblin-licenses that people can install. Also,
mention that plugin in the release notes.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Our HTML output is very verbose (=whitespacy) as our templates are
written with an 80 char limit and lots of newlines between blocks,
variables etc....
This is a plugin that naively strips of all but the first whitespace
from the HTML response. We might want to have an all-fancy html tidy
interface here at some point, but it nicely decreases the HTML size
about a third on some simple pages.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Plugins may want to insert meddlewares, so this list should be modifiable
at very list (if we don't want to provide helper methods for this, which
seems a tad overkill for now).
This change is required for the upcoming trim_whitespace plugin.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
There is really no reason to provide and enable a meddleware that
does exactly... NOTHING ...by default.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Rather than exploding in the user's face (for example if we custom-configure
licenses in our MG instance, and there are still media with now "unknown"
licenses in the db), simply return a License object as a fallback, where all
attributes are set to the URL we were handed.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
"Objectify" our licenses to have .uri, .abbreviation, .name attributes
that we can pass into the templates and use there. namedtuples are a good
poor man's choice to make a License a class. (a named tuple really)
Document and optimize licenses_as_choices(), it is a one-liner really.
No need for verbose appends here...
Rather than manually __importing__ the MEDIA_MANAGER, we should have
been using tools.common.import_component in the first place.
But even better to use the existing get_media_manager() function that
exists for exactly our purpose. Also improve documentation of what happens
in case of failure.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
importlib is cool, but only included in python2.7 which is beyond our
minimum python version that we support. So simply use plain old
__import__.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Thanks to Elrond for noticing. We wrap error messages in <p> tags,
so there is no need to start the error message with <p>. DOH
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
MANIFEST.in did not include *.xml for our templates, so the webfinger
template files got left out of our packaging with e.g. "setup.py install".
Fixed.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
without being an admin. Previously we were just returning a 404 page
and this confused the heck out of me, as I did not understand why the
admin pages were not there at all (I was no admin).
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Rather than having a 404.html, a 403.html, a 500.html,...
we have a generic error.html template that we pass in an
error code, a title and a (html'ish) error message.
Implement the common render_404 and render_403 shortcuts. More exotic
cases can be achieved by the generic render_error function.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
In case we want to bundle db actions into a single transaction, we
can now use delete(commit=False) to prevent the transaction from being
committed immediately. This is useful when e.g. deleting a User() and
thousands of his MediaEntries in a single commit.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
On a page with the single purpose to enter new user data, we should
auto-focus the username field. It is very annoying to have to click in
that field before starting to type. Theoretically, there is the "autofocus"
attribute in html5, but IE does not support that.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
* spaetz/390_delim:
No need to strip the tag 4 times
Slightly shorten the media_tags_as_string function
Remove tag delimiter configurability (#390), fixed pep-8 compliance
1) Change the "dashboard":
- Add a bunch of new links: Processing panel, Add media
- Use <ul>+<li> for the *list* of possible actions
2) Add a title attribute to the "add media to collection" link
We have migrations creating new tables. Those currently use
"raw" table definitions. This easily gives errors (we
already had this problem).
So instead rewrite those to use declarative tables and use
those to create new tables. Just copy the new table over to
the migration, strip it down to the bare minimum, rename to
_v0, base it on declarative_base() and be done!
Do this for the current migrations.