83 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Joar Wandborg
d56e82635f Fixed OAuth access_token duplicate route
Changed route name to "[...]list_connections"
2012-10-15 22:59:53 +02:00
Joar Wandborg
1ec7ff2adb Fixed 404 page under werkzeug.routing
- Removed ?lang=<langcode> feature due to incompatibility with werkzeug
  routes in the current state of the architecture.
2012-10-14 20:05:44 +02:00
Joar Wandborg
7742dcc1fb Switched most stuff over from Routes
Removed the Routes routing functionality and replaced it with
werkzeug.routes. Most views are functional.

Known issues:

 - Translation integration with the request object is not yet figured
   out. This breaks 404 pages.
2012-10-14 13:46:31 +02:00
Joar Wandborg
e2890c729f Fixed pylint issues, removed unused import 2012-10-02 22:29:22 +02:00
Joar Wandborg
3d7fa496ee Changed copy.copy(get_params) to dict(get_params)
in pagination because request.GET/request.args is immutable since the
switch to werkzeug.
2012-09-30 20:34:39 +02:00
Joar Wandborg
111a609df5 Replaced all request.POST with request.form, ...
- Fixed error handling in OAuth plugin
- Changed request.POST file fields to request.files
2012-09-29 21:08:20 +02:00
Joar Wandborg
f1d06e1d6c Switch from webob.Request to werkzeug.wrappers.Request 2012-09-29 21:08:20 +02:00
Joar Wandborg
0df00eb68f Added tests for HTTP callbacks 2012-09-27 00:45:25 +02:00
Joar Wandborg
939d57a022 HTTP callback fixes
- Added HTTPError catching around the callback request, to not mark the
  entry as failed, just log the exception.
- Fixed bug where I forgot to actually fetch the entry before passing it
  to json_processing_callback.
- Changed __main__ migration #6 to create the ProcessingMetaData table
  as it is currently, to prevent possible breakage if a siteadmin
  is lagging behind with his db migrations and more than one migration
  wants to fix stuff with the ProcessingMetaData table.
2012-09-26 23:53:51 +02:00
Joar Wandborg
5354f954dc Added support for http callbacks on processing
Sends an HTTP POST request back to an URL given on submission to the API
submit view.
2012-09-26 23:53:51 +02:00
Joar Wandborg
0e21b2342f Added flask-wtf html5 fields to extlib 2012-09-21 13:16:24 +02:00
Joar Wandborg
a062149e90 Created API plugin, moved api_auth to the API plugin 2012-09-13 20:59:00 +02:00
Joar Wandborg
f46e2a4db9 Add OAuth models, plugin DB migrations, api_auth 2012-09-13 20:38:59 +02:00
warp
bc875dc7cc Fix for issue #491, invert latitude when neccesary. 2012-08-27 15:55:43 +02:00
Aleksej
9d3e56d500 replaced os.path.split()[0] with os.path.dirname() and corrected a couple of comments 2012-08-13 16:07:58 +04:00
Jakob Kramer
cf29edcd74 allow pre+code tags in rendered HTML 2012-08-07 22:19:10 +02:00
Jakob Kramer
c042801650 renamed MARKDOWN_INSTANCE to UNSAFE_...
as proposed by Elrond.

Conflicts:
	mediagoblin/tools/text.py

Signed-off-by: Joar Wandborg <git@wandborg.com>
2012-08-07 18:48:57 +02:00
Christopher Allan Webber
a04c07376d Merge remote-tracking branch 'refs/remotes/gandaro/369-thread-gettext' 2012-07-26 11:09:52 -05:00
Jakob Kramer
c80982c7a0 make mg_globals.translations thread-safe
I added mg_globals.thread_scope (an instance of threading.local)
and made `translations' an attribute of it.
2012-07-18 19:25:53 +02:00
Will Kahn-Greene
05e007c1db Rework plugin infrastructure to nix side-effects
This reworks the plugin infrastructure so as to remove module-loading
side-effects which were making things a pain in the ass to test.

With the new system, there's no auto-registering meta class. Instead
plugins do whatever they want and then specify a hooks dict that maps
hook names to callables for the things they're tying into. The most
common one (and the only one we've implemented so far) is "setup".

This also simplifies the sampleplugin a little by moving the code
to __init__.py.
2012-07-17 21:02:12 -04:00
Will Kahn-Greene
4bd65f69c7 Finish flatpagesplugin; add plugin docs 2012-07-16 09:26:28 -04:00
Will Kahn-Greene
8545dd50f0 Flatpages first pass
This fixes the template loader so that it can load plugin templates.

This adds code for registering template paths so that plugins can add
their own templates.

This adds the base code for the flatpagesfile plugin. It doesn't serve
pages, yet, but it's pretty close.
2012-07-16 09:26:28 -04:00
Christopher Allan Webber
27c9bb8a58 Small fix to themedata_for_theme_dir utility about sections
If we can't find the theme section, we should use a dictionary instead
of None in this section of code.
2012-07-14 22:44:06 -05:00
Christopher Allan Webber
faa74bf9f5 Store licensing info as well 2012-07-14 20:23:21 -05:00
Christopher Allan Webber
35a24fc263 Moving the "dependency injection printer tools" over to tools/common.py 2012-07-14 12:55:14 -05:00
Christopher Allan Webber
975be468cf Making the register_themes() tool also return the current theme
This will reduce the amount of work reproducing this behavior when
pulling together the theme registry elsewhere.
2012-07-14 12:55:14 -05:00
Christopher Allan Webber
5377114c4d Update staticdirect stuff so it can handle "domains" of staticdirection 2012-07-14 12:55:14 -05:00
Christopher Allan Webber
00eda826cb Kill MultiRemoteStaticDirect... nobody was really using it anyway
Since we're adding the new "domain" staticdirect system we should
clean this up.
2012-07-14 12:55:13 -05:00
Christopher Allan Webber
e8d4e58214 Moving staticdirect to tools/ 2012-07-14 12:55:13 -05:00
Christopher Allan Webber
828fc6300a Early version of theme registry code 2012-07-14 12:55:13 -05:00
Brett Smith
81d3c4cf1c Merge branch 'master' into 201207-testfixes 2012-07-08 11:07:02 -04:00
Brett Smith
16b8e3afd8 Don't rely on app_config if common.TESTS_ENABLED.
app_config will be None in this case, so all of these subscripts will
fail.
2012-07-08 10:37:33 -04:00
Joar Wandborg
8588505c6f Decoding EXIF strings as UTF-8 with replace in the ifd_tag_to_dict
method.
2012-07-07 20:01:19 +02:00
Christopher Allan Webber
118bafbd81 Switching the syntax of this exception-raise
It's nicer to raise exceptions like
  raise Exception("foo")
than
  raise Exception, "foo"
2012-07-06 09:06:01 -05:00
Christopher Allan Webber
1ec85bb3de Removing _jointhat()... not really needed. 2012-07-06 09:03:08 -05:00
Christopher Allan Webber
a850b1e2a2 one more noSuchFiles->no_such_files 2012-07-06 09:02:24 -05:00
Christopher Allan Webber
46583ff4e6 Merge remote-tracking branch 'refs/remotes/merge-requests/37' 2012-07-06 08:52:35 -05:00
Jorge Araya Navarro
6d539afda6 changing NoSuchFiles for no_such_files 2012-07-05 22:07:44 -06:00
Jorge Araya Navarro
fb2fbe2c0a fixing bug #255 as Joar and CWebber ask me to do :) 2012-06-28 22:13:26 -06:00