From 4a4e4e4ae83d6ff3f09580238049e74444b01416 Mon Sep 17 00:00:00 2001 From: Jiyda Mint Moussa Date: Mon, 29 Apr 2013 00:01:30 +0300 Subject: [PATCH 1/6] Added rtl language support RTL languages like Arabic, Hebrew etc were displayed from left to right. I fixed this by adding a function to check whether the language of the locale is rtl and change the direction of the html in "base.html" accordingly. [Fixes #220] --- mediagoblin/templates/mediagoblin/base.html | 7 +++++-- mediagoblin/tools/template.py | 5 ++++- mediagoblin/tools/translate.py | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/mediagoblin/templates/mediagoblin/base.html b/mediagoblin/templates/mediagoblin/base.html index 9c42a756..83bc65d4 100644 --- a/mediagoblin/templates/mediagoblin/base.html +++ b/mediagoblin/templates/mediagoblin/base.html @@ -16,11 +16,12 @@ # along with this program. If not, see . -#} + - + {% block title %}{{ app_config['html_title'] }}{% endblock %} @@ -48,6 +49,7 @@ {% endblock mediagoblin_head %} +
{% include 'mediagoblin/bits/body-start.html' %} {% block mediagoblin_body %} {% block mediagoblin_header %} @@ -133,5 +135,6 @@
{%- endblock mediagoblin_body %} {% include 'mediagoblin/bits/body-end.html' %} - + + diff --git a/mediagoblin/tools/template.py b/mediagoblin/tools/template.py index 54aeac92..5d320f75 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 from mediagoblin.tools.timesince import timesince from mediagoblin.meddleware.csrf import render_csrf_form_token @@ -67,11 +69,12 @@ 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['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""" From 26583b2cab650cc27af845fd2ef20cccae2aeceb Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Mon, 2 Sep 2013 09:47:55 -0700 Subject: [PATCH 2/6] check if db is up to date --- mediagoblin/app.py | 4 ++++ mediagoblin/db/util.py | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) 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 8431361a..19e23d7f 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 . +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 @@ -68,6 +71,18 @@ def check_collection_slug_used(creator_id, slug, ignore_c_id): 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 the webserver.") + + if __name__ == '__main__': from mediagoblin.db.open import setup_connection_and_db_from_config From 635dd6cc31d4d9afbe648f76af2f799eebf8f1f1 Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Mon, 2 Sep 2013 11:55:41 -0700 Subject: [PATCH 3/6] don't set logging level to debug --- mediagoblin/gmg_commands/dbupdate.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/mediagoblin/gmg_commands/dbupdate.py b/mediagoblin/gmg_commands/dbupdate.py index 961752f6..77eaf01d 100644 --- a/mediagoblin/gmg_commands/dbupdate.py +++ b/mediagoblin/gmg_commands/dbupdate.py @@ -24,8 +24,6 @@ from mediagoblin.init import setup_global_and_app_config from mediagoblin.tools.common import import_component _log = logging.getLogger(__name__) -logging.basicConfig() -_log.setLevel(logging.DEBUG) def dbupdate_parse_setup(subparser): pass From f7f38fb047059f0289060f2b87a213e2909e1a20 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Wed, 1 Jan 2014 16:42:04 -0600 Subject: [PATCH 4/6] sqlalchemy-migrate 0.8.X doesn't get along with sqlalchemy 0.9.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 420d90ab..a5b52f18 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ try: 'webtest<2', 'ConfigObj', 'Markdown', - 'sqlalchemy>=0.8.0', + 'sqlalchemy<0.9.0', 'sqlalchemy-migrate', 'mock', 'itsdangerous', From f4703ae9cdea5a2c5697444c0610dbee105f35dc Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Thu, 2 Jan 2014 11:17:59 -0600 Subject: [PATCH 5/6] Don't fail transcoding if we fail to generate a thumbnail. This patch by Sergio Durigan Junior. Thank you, Sergio! --- AUTHORS | 1 + mediagoblin/media_types/video/processing.py | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/AUTHORS b/AUTHORS index d1b082e0..2b2bb48a 100644 --- a/AUTHORS +++ b/AUTHORS @@ -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/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, From 64eab630bf99e4d92e567628dbfc7cecf4cc27c4 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Thu, 2 Jan 2014 15:07:54 -0600 Subject: [PATCH 6/6] Not only the web server starts MediaGoblin app! Better phrasing. --- mediagoblin/db/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediagoblin/db/util.py b/mediagoblin/db/util.py index 19e23d7f..aba9c59c 100644 --- a/mediagoblin/db/util.py +++ b/mediagoblin/db/util.py @@ -80,7 +80,7 @@ def check_db_up_to_date(): 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 the webserver.") + "'gmg dbupdate' before starting MediaGoblin.") if __name__ == '__main__':