diff options
author | jpope <jpope@jpope.org> | 2014-01-05 16:55:58 -0600 |
---|---|---|
committer | jpope <jpope@jpope.org> | 2014-01-05 16:55:58 -0600 |
commit | 0172ad000148f1cfe6f5110982c364f46b3d0ecb (patch) | |
tree | a32f97b2cc6fa6fb41de8263f8c6136922e87799 | |
parent | 1e298b10c7cba2d27cb19f1aee03134f66ef6e20 (diff) | |
parent | 64eab630bf99e4d92e567628dbfc7cecf4cc27c4 (diff) | |
download | mediagoblin-0172ad000148f1cfe6f5110982c364f46b3d0ecb.tar.lz mediagoblin-0172ad000148f1cfe6f5110982c364f46b3d0ecb.tar.xz mediagoblin-0172ad000148f1cfe6f5110982c364f46b3d0ecb.zip |
Merge remote-tracking branch 'upstream/master' into skeletongobblin
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | mediagoblin/app.py | 4 | ||||
-rw-r--r-- | mediagoblin/db/util.py | 18 | ||||
-rw-r--r-- | mediagoblin/gmg_commands/dbupdate.py | 1 | ||||
-rw-r--r-- | mediagoblin/media_types/video/processing.py | 5 | ||||
-rw-r--r-- | mediagoblin/templates/mediagoblin/base.html | 10 | ||||
-rw-r--r-- | mediagoblin/tools/template.py | 5 | ||||
-rw-r--r-- | mediagoblin/tools/translate.py | 6 | ||||
-rw-r--r-- | setup.py | 2 |
9 files changed, 46 insertions, 6 deletions
@@ -82,6 +82,7 @@ Thank you! * Tran Thanh Bao * Tryggvi Björgvinsson * Shawn Khan +* Sergio Durigan Junior * Will Kahn-Greene Special thanks to: diff --git a/mediagoblin/app.py b/mediagoblin/app.py index e9177eff..e65e6d10 100644 --- a/mediagoblin/app.py +++ b/mediagoblin/app.py @@ -25,6 +25,7 @@ from werkzeug.exceptions import HTTPException from werkzeug.routing import RequestRedirect from mediagoblin import meddleware, __version__ +from mediagoblin.db.util import check_db_up_to_date from mediagoblin.tools import common, session, translate, template from mediagoblin.tools.response import render_http_exception from mediagoblin.tools.theme import register_themes @@ -91,6 +92,9 @@ class MediaGoblinApp(object): # Set up the database self.db = setup_database(app_config['run_migrations']) + # Quit app if need to run dbupdate + check_db_up_to_date() + # Register themes self.theme_registry, self.current_theme = register_themes(app_config) diff --git a/mediagoblin/db/util.py b/mediagoblin/db/util.py index 7a0a3a73..aba9c59c 100644 --- a/mediagoblin/db/util.py +++ b/mediagoblin/db/util.py @@ -14,9 +14,12 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import sys + +from mediagoblin import mg_globals as mgg from mediagoblin.db.base import Session from mediagoblin.db.models import MediaEntry, Tag, MediaTag, Collection - +from mediagoblin.gmg_commands.dbupdate import gather_database_data ########################## # Random utility functions @@ -67,6 +70,19 @@ def check_collection_slug_used(creator_id, slug, ignore_c_id): does_exist = Session.query(Collection.id).filter(filt).first() is not None return does_exist + +def check_db_up_to_date(): + """Check if the database is up to date and quit if not""" + dbdatas = gather_database_data(mgg.global_config.get('plugins', {}).keys()) + + for dbdata in dbdatas: + migration_manager = dbdata.make_migration_manager(Session()) + if migration_manager.database_current_migration is None or \ + migration_manager.migrations_to_run(): + sys.exit("Your database is not up to date. Please run " + "'gmg dbupdate' before starting MediaGoblin.") + + if __name__ == '__main__': from mediagoblin.db.open import setup_connection_and_db_from_config diff --git a/mediagoblin/gmg_commands/dbupdate.py b/mediagoblin/gmg_commands/dbupdate.py index 05762946..27283a20 100644 --- a/mediagoblin/gmg_commands/dbupdate.py +++ b/mediagoblin/gmg_commands/dbupdate.py @@ -28,6 +28,7 @@ logging.basicConfig() ## Let's not set the level as debug by default to avoid confusing users :) # _log.setLevel(logging.DEBUG) + def dbupdate_parse_setup(subparser): pass diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py index eb5a062c..abd5f36e 100644 --- a/mediagoblin/media_types/video/processing.py +++ b/mediagoblin/media_types/video/processing.py @@ -266,6 +266,11 @@ class CommonVideoProcessor(MediaProcessor): tmp_thumb, thumb_size[0]) + # Checking if the thumbnail was correctly created. If it was not, + # then just give up. + if not os.path.exists (tmp_thumb): + return + # Push the thumbnail to public storage _log.debug('Saving thumbnail...') store_public(self.entry, 'thumb', tmp_thumb, diff --git a/mediagoblin/templates/mediagoblin/base.html b/mediagoblin/templates/mediagoblin/base.html index 93086205..ecc24f89 100644 --- a/mediagoblin/templates/mediagoblin/base.html +++ b/mediagoblin/templates/mediagoblin/base.html @@ -16,10 +16,14 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. -#} <!doctype html> + <html -{% block mediagoblin_html_tag %} -{% endblock mediagoblin_html_tag %} -> + {% block mediagoblin_html_tag %} + {% endblock mediagoblin_html_tag %} + {% if is_rtl -%} + dir="rtl" + {%- endif -%} + > <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> diff --git a/mediagoblin/tools/template.py b/mediagoblin/tools/template.py index fa290611..e5acdf45 100644 --- a/mediagoblin/tools/template.py +++ b/mediagoblin/tools/template.py @@ -26,7 +26,9 @@ from mediagoblin import mg_globals from mediagoblin import messages from mediagoblin import _version from mediagoblin.tools import common +from mediagoblin.tools.translate import is_rtl from mediagoblin.tools.translate import set_thread_locale +from mediagoblin.tools.translate import get_locale_from_request from mediagoblin.tools.pluginapi import get_hook_templates, hook_transform from mediagoblin.tools.timesince import timesince from mediagoblin.meddleware.csrf import render_csrf_form_token @@ -72,12 +74,13 @@ def get_jinja_env(template_loader, locale): # ... fetch all waiting messages and remove them from the queue # ... construct a grid of thumbnails or other media # ... have access to the global and app config + # ... determine if the language is rtl or ltr template_env.globals['fetch_messages'] = messages.fetch_messages template_env.globals['app_config'] = mg_globals.app_config template_env.globals['global_config'] = mg_globals.global_config template_env.globals['version'] = _version.__version__ template_env.globals['auth'] = mg_globals.app.auth - + template_env.globals['is_rtl'] = is_rtl(locale) template_env.filters['urlencode'] = url_quote_plus # add human readable fuzzy date time diff --git a/mediagoblin/tools/translate.py b/mediagoblin/tools/translate.py index b20e57d1..f55ce349 100644 --- a/mediagoblin/tools/translate.py +++ b/mediagoblin/tools/translate.py @@ -31,6 +31,12 @@ AVAILABLE_LOCALES = None TRANSLATIONS_PATH = pkg_resources.resource_filename( 'mediagoblin', 'i18n') +# Known RTL languages +KNOWN_RTL = set(["ar", "fa", "zh","he","iw","ja","ur","yi","ji"]) + +def is_rtl(lang): + """Returns true when the local language is right to left""" + return lang in KNOWN_RTL def set_available_locales(): """Set available locales for which we have translations""" @@ -58,7 +58,7 @@ try: 'webtest<2', 'ConfigObj', 'Markdown', - 'sqlalchemy>=0.8.0', + 'sqlalchemy<0.9.0', 'sqlalchemy-migrate', 'mock', 'itsdangerous', |