2976 Commits

Author SHA1 Message Date
Sebastian Spaeth
1aac6a3c3c Also package i18n/*.mo
....
and I wondered why my production site fails to display German pages...

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-12-02 01:09:35 +01:00
Sebastian Spaeth
6ef75af50e Honor user's browser language (#558)
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>
2012-12-02 00:29:30 +01:00
Sebastian Spaeth
7b9f9d1edb Fix i18n in our browser
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>
2012-12-01 23:40:10 +01:00
Sebastian Spaeth
7989cd6e49 docs: Add trim_whitespaces plugin to relnotes and documentation
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>
2012-12-01 20:31:18 +01:00
Sebastian Spaeth
9945468603 trim_whitespace meddleware plugin
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>
2012-12-01 20:19:43 +01:00
Sebastian Spaeth
a30fb1d89d Make ENABLED_MEDDLEWARES a list and not a tuple, so we can modify it
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>
2012-12-01 20:19:43 +01:00
Sebastian Spaeth
d7d422ca04 Remove the NoOp meddleware
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>
2012-12-01 20:19:43 +01:00
Sebastian Spaeth
138a18fd6e Implement licenses.get_license_by_url
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>
2012-11-30 14:31:43 +01:00
Sebastian Spaeth
8e5fae9b43 Improve mediagoblin.tools.licenses
"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...
2012-11-30 14:31:43 +01:00
Sebastian Spaeth
df1c497609 Use mediagoblin import machinery
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>
2012-11-30 14:25:26 +01:00
Sebastian Spaeth
27886480ab Remove importlib (python2.7'ism)
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>
2012-11-30 11:25:50 +01:00
Elrond
e4f33f4093 Merge remote-tracking branch 'spaetz/formerge/538_FORBIDDEN_admin_pages'
* spaetz/formerge/538_FORBIDDEN_admin_pages:
  Fix error page text
  Return code 403 when accessing admin pages
  Implement generic error pages
2012-11-29 15:27:50 +01:00
Sebastian Spaeth
26c71029b4 Fix error page text
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>
2012-11-29 14:51:24 +01:00
Elrond
6adcea2451 Merge remote-tracking branch 'spaetz/formerge/bundle_xml_templates_too'
* spaetz/formerge/bundle_xml_templates_too:
  Also package webfinger.xml
2012-11-29 14:34:16 +01:00
Sebastian Spaeth
e501c619cb Also package webfinger.xml
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>
2012-11-29 14:32:28 +01:00
Elrond
f52301d261 Merge remote-tracking branch 'spaetz/formerge/507_remove_routes'
* spaetz/formerge/507_remove_routes:
  Purge routes package from MG (#507)
2012-11-29 14:29:43 +01:00
Sebastian Spaeth
60de3209b9 Return code 403 when accessing admin pages
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>
2012-11-29 09:10:43 +01:00
Sebastian Spaeth
6b5f1ca79b Implement generic error pages
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>
2012-11-29 09:01:08 +01:00
Elrond
efb70b529f Merge some small bits by spaetz. Needed later.
* commit '9437ea4742':
  Add commit argument to clean_orphan_tags
  Add "commit" argument to Base model delete()
2012-11-28 16:45:15 +01:00
Sebastian Spaeth
9437ea4742 Add commit argument to clean_orphan_tags
So we can prevent the session from being committed if we don't want it.
2012-11-28 14:43:04 +01:00
Elrond
329e39034b Add "commit" argument to Base model delete()
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>
2012-11-28 13:52:41 +01:00
Jef van Schendel
0d599e5341 Merge remote-tracking branch 'spaetz/focus_on_user_creation' 2012-11-27 13:56:38 +01:00
Christopher Allan Webber
fbfcf1a57a Merge remote-tracking branch 'refs/remotes/elrond/sql/migrate_new_tables' 2012-11-26 15:15:13 -06:00
Sebastian Spaeth
a3009452fa Autofocus the username field on user creation
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>
2012-11-26 21:38:29 +01:00
Elrond
fa2f6ba162 Merge remote-tracking branch 'spaetz/390_delim' into review
* 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
2012-11-26 19:52:11 +01:00
Christopher Allan Webber
dc0b39b747 Merge remote-tracking branch 'elrond/for-schendje' 2012-11-26 12:50:17 -06:00
Christopher Allan Webber
f891d5fe50 geolocation now on by default 2012-11-26 11:57:33 -06:00
Christopher Allan Webber
11e887f274 Merge remote-tracking branch 'remotes/spaetz/410_OSM_attrib_v2' 2012-11-26 11:53:59 -06:00
Elrond
9498e3e73b Some small template changes
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
2012-11-26 00:36:07 +01:00
Tryggvi Björgvinsson
2d8ce464de Documented the get_original_date method 2012-11-25 16:38:44 +00:00
Tryggvi Björgvinsson
d682d066d3 Moved exif date transformation logic from template to image data model (as a function) 2012-11-25 16:09:35 +00:00
Elrond
9abd664bf2 Stop unicode conversion warning during dbupdate.
Just force the passed in name to MigrationManager() to unicode.
2012-11-24 22:57:46 +01:00
Elrond
316e1dfdde SQL Migrations: Rewrite table creation completely.
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.
2012-11-24 19:23:08 +01:00
Christopher Allan Webber
4211d03014 Marking "attachment" stuff for translation (thanks for catching AVRS) 2012-11-24 10:22:11 -06:00
Elrond
df7e06c40c Require werkzeug >= 0.7
We need it, really. For csrf.py's request.scheme.

Thanks to Sebastian Spaeth!
2012-11-24 00:16:51 +01:00
Elrond
c356dc1635 Very small typo fix in deploying docs.
Thanks to #mediagoblin.
2012-11-20 14:32:29 +01:00
Sebastian Spaeth
60389b21f5 Purge routes package from MG (#507)
We were not actually using the routes package anymore, but it was
still mentioned in the documention. Adapt the plugin documentation to
actually represent reality, although I don't like the API design.
(but this is for another day)

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-11-20 09:29:37 +01:00
Christopher Allan Webber
4d8a3cd808 Suggest checking out the wiki for additional recipes 2012-11-19 12:17:44 -06:00
Sebastian Spaeth
9061383de2 No need to strip the tag 4 times
spaetz' rule: Don't do sth 4 times when once suffices.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-11-16 13:18:37 +01:00
Sebastian Spaeth
ee97ac6c2f Add geolocation_visible setting to mediagoblin.ini
Place the geolocation_visible setting (defaults to false) in
mediagoblin.ini to make it more discoverable (I needed to check
the source to find out how to enable it). I'd vote for a default
of true, we should come with some batteries included IMHO..

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-11-16 12:59:25 +01:00
Sebastian Spaeth
fd79d33a87 Pop up OpenStreetMap license on demand (#410)
Only a short blurb "see map license" in the small map which will
pop up the full license text via jquery when clicked.
Adapt the license text as recommended by OpenStreetMap
http://www.openstreetmap.org/copyright and link there.

The disadvantage is that this only works when Javascript is enabled,
but as the map only works when Javascript is enabled in the first place,
this should not be too much of a limitation.

TODO: Our esteemed web designer needs to have a look at the desired color
style for this. Right now, I simply placed it in the message_warning
class. This might want fine-tuning.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-11-16 12:59:23 +01:00
Christopher Allan Webber
59e2656e11 Borrowing an image from Tango! 2012-11-15 14:40:00 -06:00
Sebastian Spaeth
2e4ad35962 Simplify/Robustify the thumbnail URL usage in templates
So far templates required a very complex blurb to simply insert a
thumbnail URL, exposing much of the internal logic to the template
designer. In addition, we would fail with an error if for some
reason the media_files['thumb'] entry was never populated.

This adds the MediaEntry.thumb_url property that template designers
can simply use. It will do the right thing, either fetching the proper
thumbnail or hand back a generic icon specified in a media's
MEDIA_MANAGER as "default_thumb".

Add an image default fallback icon (stolen from Tangos, which are
Public Domain since version 0.8.90 as I understand) since the one
we referred to was not existing. Perhaps, a "broken image" icon
would be better, but I'll leave that to our capable designers.

All templates have been modified to make use of the new thumb_url
function.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-11-15 12:01:31 +01:00
Sebastian Spaeth
2a6a3b8cce Slightly shorten the media_tags_as_string function
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-11-14 09:04:17 +01:00
dunkyp
36c7d93481 Remove tag delimiter configurability (#390), fixed pep-8 compliance
Hardcode commas as tag delimiters per discussion in issue 390. Also
improved PEP-8'ness of the file while touching. Includes some improvements
suggested by gandaro.

Reviewed-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-11-14 08:38:24 +01:00
Christopher Allan Webber
ee62c51d79 Merge remote-tracking branch 'refs/remotes/spaetz/trac_475_email_notification_checkbox' 2012-11-13 08:55:14 -06:00
LotusEcho
5e5b8acfec Don't put checkbox text on separate line (#475)
Manually render the "notify me" checkbox line in the account settings
to not put the form label as a heading but in the same line as the
checkbox.

Edit forms.py to use the label attribute for the caption.

Original patch modified by Sebastian Spaeth to 1) not translate the
checkbox label in the template, it is translated in forms.py already.
2) Simplify the HTML, manually constructing the <label> tag is not
necessary, WTforms does it automatically.

Author:    LotusEcho <Emma.C.Echo@gmail.com>
Modified-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
2012-11-13 15:47:34 +01:00
Tryggvi Björgvinsson
24d310e46f A template fix to show the EXIF DateTimeOriginal (as creation date). Added as a configurable option 'original_date_visible' (default false). Since the EXIF tag is a string with the date formatted as 'YYYY:MM:DD HH:MM:SS' the fix slices the string to give only the date and then replaces : by - to conform with the 'Added on' date. 2012-11-08 00:14:17 +00:00
Jef van Schendel
52aef5b445 Revert thumbnail styling and sizing; allows for 5 thumbnails per row 2012-11-01 17:10:16 +01:00
Jef van Schendel
02e100ea1f Change to 5 thumbnails per row 2012-11-01 17:03:45 +01:00