From 495aecfe7417918c45d8ea32b1ee8903018449cd Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 1 Mar 2015 08:22:29 +0100 Subject: Cleanup & simplify theme --- .../CoreBundle/Helper/DetectActiveTheme.php | 25 ++- .../CoreBundle/Resources/config/services.yml | 1 + .../CoreBundle/Resources/public/js/bookmarklet.js | 2 - .../Resources/views/Config/index.html.twig | 4 - .../Resources/views/Entry/entries.html.twig | 4 - .../Resources/views/Entry/entry.html.twig | 4 - .../CoreBundle/Resources/views/Entry/new.html.twig | 4 - .../Resources/views/Security/login.html.twig | 13 +- .../Resources/views/Static/about.html.twig | 4 +- .../CoreBundle/Resources/views/_footer.html.twig | 3 - .../CoreBundle/Resources/views/_head.html.twig | 16 -- .../CoreBundle/Resources/views/_menu.html.twig | 14 -- .../CoreBundle/Resources/views/_messages.html.twig | 9 - .../Resources/views/_save_form.html.twig | 10 -- .../Resources/views/_search_form.html.twig | 9 - .../CoreBundle/Resources/views/_top.html.twig | 5 - .../CoreBundle/Resources/views/base.html.twig | 115 +++++++++++++ .../Resources/views/layout-login.html.twig | 27 --- .../CoreBundle/Resources/views/layout.html.twig | 29 ---- .../views/themes/_global/_head_icon.html.twig | 26 --- .../views/themes/_global/public/js/bookmarklet.js | 2 + .../views/themes/_global/public/js/closeMessage.js | 17 ++ .../themes/_global/public/js/jquery.cookie.js | 117 +++++++++++++ .../views/themes/baggy/_display-mode.twig | 5 - .../Resources/views/themes/baggy/config.twig | 187 --------------------- .../Resources/views/themes/baggy/edit-tags.twig | 29 ---- .../Resources/views/themes/baggy/layout.html.twig | 56 ++---- .../Resources/views/themes/baggy/login.twig | 34 ---- .../views/themes/baggy/public/js/closeMessage.js | 17 -- .../views/themes/baggy/public/js/jquery.cookie.js | 117 ------------- .../Resources/views/themes/baggy/tags.twig | 13 -- .../Resources/views/themes/baggy/theme.ini | 3 - 32 files changed, 294 insertions(+), 627 deletions(-) delete mode 100644 src/Wallabag/CoreBundle/Resources/public/js/bookmarklet.js delete mode 100644 src/Wallabag/CoreBundle/Resources/views/_footer.html.twig delete mode 100755 src/Wallabag/CoreBundle/Resources/views/_head.html.twig delete mode 100644 src/Wallabag/CoreBundle/Resources/views/_menu.html.twig delete mode 100644 src/Wallabag/CoreBundle/Resources/views/_messages.html.twig delete mode 100755 src/Wallabag/CoreBundle/Resources/views/_save_form.html.twig delete mode 100644 src/Wallabag/CoreBundle/Resources/views/_search_form.html.twig delete mode 100755 src/Wallabag/CoreBundle/Resources/views/_top.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/base.html.twig delete mode 100644 src/Wallabag/CoreBundle/Resources/views/layout-login.html.twig delete mode 100644 src/Wallabag/CoreBundle/Resources/views/layout.html.twig delete mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/_global/_head_icon.html.twig create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/_global/public/js/bookmarklet.js create mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/_global/public/js/closeMessage.js create mode 100755 src/Wallabag/CoreBundle/Resources/views/themes/_global/public/js/jquery.cookie.js delete mode 100755 src/Wallabag/CoreBundle/Resources/views/themes/baggy/_display-mode.twig delete mode 100755 src/Wallabag/CoreBundle/Resources/views/themes/baggy/config.twig delete mode 100755 src/Wallabag/CoreBundle/Resources/views/themes/baggy/edit-tags.twig delete mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/baggy/login.twig delete mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/closeMessage.js delete mode 100755 src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/jquery.cookie.js delete mode 100755 src/Wallabag/CoreBundle/Resources/views/themes/baggy/tags.twig delete mode 100644 src/Wallabag/CoreBundle/Resources/views/themes/baggy/theme.ini (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php index 2a943bb7..2c742e6a 100644 --- a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php +++ b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php @@ -6,13 +6,26 @@ use Liip\ThemeBundle\Helper\DeviceDetectionInterface; use Symfony\Component\Security\Core\SecurityContextInterface; use Wallabag\CoreBundle\Entity\User; +/** + * This class intend to detect the active theme for the logged in user. + * It will retrieve the configured theme of the user. + * + * If no user where logged in, it will returne the default theme + */ + class DetectActiveTheme implements DeviceDetectionInterface { protected $securityContext; + protected $defaultTheme; - public function __construct(SecurityContextInterface $securityContext) + /** + * @param SecurityContextInterface $securityContext Needed to retrieve the current user + * @param string $defaultTheme Default theme when user isn't logged in + */ + public function __construct(SecurityContextInterface $securityContext, $defaultTheme) { $this->securityContext = $securityContext; + $this->defaultTheme = $defaultTheme; } public function setUserAgent($userAgent) @@ -21,9 +34,10 @@ class DetectActiveTheme implements DeviceDetectionInterface /** * This should return the active theme for the logged in user. - * No active theme for: + * + * Default theme for: * - anonymous user - * - user without a config (shouldn't happen..) + * - user without a config (shouldn't happen ..) * * @return string */ @@ -31,15 +45,14 @@ class DetectActiveTheme implements DeviceDetectionInterface { $user = $this->securityContext->getToken()->getUser(); - // anon user don't deserve a theme if (!$user instanceof User) { - return false; + return $this->defaultTheme; } $config = $user->getConfig(); if (!$config) { - return false; + return $this->defaultTheme; } return $config->getTheme(); diff --git a/src/Wallabag/CoreBundle/Resources/config/services.yml b/src/Wallabag/CoreBundle/Resources/config/services.yml index 5437d1cf..c734a3a5 100644 --- a/src/Wallabag/CoreBundle/Resources/config/services.yml +++ b/src/Wallabag/CoreBundle/Resources/config/services.yml @@ -20,6 +20,7 @@ services: class: Wallabag\CoreBundle\Helper\DetectActiveTheme arguments: - @security.context + - %theme% # default theme from parameters.yml wallabag_core.form.type.config: class: Wallabag\CoreBundle\Form\Type\ConfigType diff --git a/src/Wallabag/CoreBundle/Resources/public/js/bookmarklet.js b/src/Wallabag/CoreBundle/Resources/public/js/bookmarklet.js deleted file mode 100644 index 2afdfc3c..00000000 --- a/src/Wallabag/CoreBundle/Resources/public/js/bookmarklet.js +++ /dev/null @@ -1,2 +0,0 @@ - -top["bookmarklet-url@wallabag.org"]=""+""+""+""+"bag it!"+''+""+""+" - - - - - - - diff --git a/src/Wallabag/CoreBundle/Resources/views/_menu.html.twig b/src/Wallabag/CoreBundle/Resources/views/_menu.html.twig deleted file mode 100644 index 9a3cf053..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/_menu.html.twig +++ /dev/null @@ -1,14 +0,0 @@ - - diff --git a/src/Wallabag/CoreBundle/Resources/views/_messages.html.twig b/src/Wallabag/CoreBundle/Resources/views/_messages.html.twig deleted file mode 100644 index 18e294c9..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/_messages.html.twig +++ /dev/null @@ -1,9 +0,0 @@ - -{% if flashMessages %} -
- × - {% for flashMessage in flashMessages %} -

{{ flashMessage }}

- {% endfor %} -
-{% endif %} diff --git a/src/Wallabag/CoreBundle/Resources/views/_save_form.html.twig b/src/Wallabag/CoreBundle/Resources/views/_save_form.html.twig deleted file mode 100755 index acaa5dbc..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/_save_form.html.twig +++ /dev/null @@ -1,10 +0,0 @@ - diff --git a/src/Wallabag/CoreBundle/Resources/views/_search_form.html.twig b/src/Wallabag/CoreBundle/Resources/views/_search_form.html.twig deleted file mode 100644 index 1e6f327d..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/_search_form.html.twig +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/src/Wallabag/CoreBundle/Resources/views/_top.html.twig b/src/Wallabag/CoreBundle/Resources/views/_top.html.twig deleted file mode 100755 index a4403c13..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/_top.html.twig +++ /dev/null @@ -1,5 +0,0 @@ -
-

- {% block logo %}wallabag logo{% endblock %} -

-
diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig new file mode 100644 index 00000000..4f27f413 --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig @@ -0,0 +1,115 @@ + + + + + + + + {% block head %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {% block css %}{% endblock %} + {% block scripts %} + + + + + + + + {% endblock %} + + {% block title %}{% endblock %} - wallabag + {% endblock %} + + + + {% block header %} +
+

+ {% block logo %} + wallabag logo + {% endblock %} +

+
+ {% endblock %} + +
+ {% block menu %} + + + {% endblock %} + + {% block precontent %}{% endblock %} + + {% block messages %} + {% for flashMessage in app.session.flashbag.get('notice') %} +
+ × +

{{ flashMessage }}

+
+ {% endfor %} + {% endblock %} + +
+ {% block content %}{% endblock %} +
+
+ + {% block footer %} + + {% endblock %} + + diff --git a/src/Wallabag/CoreBundle/Resources/views/layout-login.html.twig b/src/Wallabag/CoreBundle/Resources/views/layout-login.html.twig deleted file mode 100644 index 45deee8f..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/layout-login.html.twig +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - {% block title %}{% endblock %} - wallabag - {% include "WallabagCoreBundle::_head.html.twig" %} - - -

DEFAULTDEFAULTDEFAULTDEFAULTDEFAULTDEFAULTDEFAULTDEFAULT

- {% include "WallabagCoreBundle::_top.html.twig" %} -
- {% block menu %}{% endblock %} -
- {% block content %}{% endblock %} -
-
- {% include "WallabagCoreBundle::_footer.html.twig" %} - - diff --git a/src/Wallabag/CoreBundle/Resources/views/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/layout.html.twig deleted file mode 100644 index 1cf871d6..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/layout.html.twig +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - {% block title %}{% endblock %} - wallabag - {% include "WallabagCoreBundle::_head.html.twig" %} - - -

DEFAULTDEFAULTDEFAULTDEFAULTDEFAULTDEFAULTDEFAULTDEFAULT

- {% include "WallabagCoreBundle::_top.html.twig" %} -
- {% block menu %}{% endblock %} - {% block precontent %}{% endblock %} - {{ include("WallabagCoreBundle::_messages.html.twig", {'flashMessages': app.session.flashbag.get('notice')}) }} -
- {% block content %}{% endblock %} -
-
- {% include "WallabagCoreBundle::_footer.html.twig" %} - - diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/_global/_head_icon.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/_global/_head_icon.html.twig deleted file mode 100644 index 175a4b3a..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/themes/_global/_head_icon.html.twig +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/_global/public/js/bookmarklet.js b/src/Wallabag/CoreBundle/Resources/views/themes/_global/public/js/bookmarklet.js new file mode 100644 index 00000000..2afdfc3c --- /dev/null +++ b/src/Wallabag/CoreBundle/Resources/views/themes/_global/public/js/bookmarklet.js @@ -0,0 +1,2 @@ + +top["bookmarklet-url@wallabag.org"]=""+""+""+""+"bag it!"+''+""+""+" - - - -
-

{{ entry.title|raw }} -

-{% if tags is empty %} -
{% trans "no tags" %}
-{% endif %} - -
- - - -

{% trans "Start typing for auto complete." %}
- {% trans "You can enter multiple tags, separated by commas." %}

-
-{% trans "return to article" %} -{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig index 16070c7f..dffea036 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig @@ -1,43 +1,17 @@ - - - - - - - - - - - {% block title %}{% endblock %} - wallabag - {% include "WallabagCoreBundle:themes:_global/_head_icon.html.twig" %} +{% extends "WallabagCoreBundle::base.html.twig" %} - - - - - +{% block css %} + {{ parent() }} - - - - - - - - - - - {% include "WallabagCoreBundle::_top.html.twig" %} -
- {% block menu %}{% endblock %} - {% block precontent %}{% endblock %} - {{ include("WallabagCoreBundle::_messages.html.twig", {'flashMessages': app.session.flashbag.get('notice')}) }} -
- {% block content %}{% endblock %} -
-
- {% include "WallabagCoreBundle::_footer.html.twig" %} - - + + + + + +{% endblock %} + +{% block scripts %} + {{ parent() }} + + +{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/login.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/login.twig deleted file mode 100644 index 4a1dc05d..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/login.twig +++ /dev/null @@ -1,34 +0,0 @@ -{% extends "layout-login.twig" %} - -{% block title %}{% trans "login to your wallabag" %}{% endblock %} -{% block content %} - {% if http_auth == 0 %} -
-
-

{% trans "Login to wallabag" %}

- {% if constant('MODE_DEMO') == 1 %}

{% trans "you are in demo mode, some features may be disabled." %}

{% endif %} -
- - -
- -
- - -
-
- -
-
- {% trans "(Do not check on public computers)" %} -
-
-
- -
-
- - -
- {% endif %} -{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/closeMessage.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/closeMessage.js deleted file mode 100644 index 527719d5..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/closeMessage.js +++ /dev/null @@ -1,17 +0,0 @@ -$(function(){ - //--------------------------------------------------------------------------- - // Show the close icon when the user hover over a message - //--------------------------------------------------------------------------- - // $('.messages').on('mouseenter', function(){ - // $(this).find('a.closeMessage').stop(true, true).show(); - // }).on('mouseleave', function(){ - // $(this).find('a.closeMessage').stop(true, true).hide(); - // }); - //--------------------------------------------------------------------------- - // Close the message box when the user clicks the close icon - //--------------------------------------------------------------------------- - $('a.closeMessage').on('click', function(){ - $(this).parents('div.messages').slideUp(300, function(){ $(this).remove(); }); - return false; - }); -}); \ No newline at end of file diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/jquery.cookie.js b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/jquery.cookie.js deleted file mode 100755 index 92719000..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/public/js/jquery.cookie.js +++ /dev/null @@ -1,117 +0,0 @@ -/*! - * jQuery Cookie Plugin v1.4.0 - * https://github.com/carhartl/jquery-cookie - * - * Copyright 2013 Klaus Hartl - * Released under the MIT license - */ -(function (factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as anonymous module. - define(['jquery'], factory); - } else { - // Browser globals. - factory(jQuery); - } -}(function ($) { - - var pluses = /\+/g; - - function encode(s) { - return config.raw ? s : encodeURIComponent(s); - } - - function decode(s) { - return config.raw ? s : decodeURIComponent(s); - } - - function stringifyCookieValue(value) { - return encode(config.json ? JSON.stringify(value) : String(value)); - } - - function parseCookieValue(s) { - if (s.indexOf('"') === 0) { - // This is a quoted cookie as according to RFC2068, unescape... - s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); - } - - try { - // Replace server-side written pluses with spaces. - // If we can't decode the cookie, ignore it, it's unusable. - s = decodeURIComponent(s.replace(pluses, ' ')); - } catch(e) { - return; - } - - try { - // If we can't parse the cookie, ignore it, it's unusable. - return config.json ? JSON.parse(s) : s; - } catch(e) {} - } - - function read(s, converter) { - var value = config.raw ? s : parseCookieValue(s); - return $.isFunction(converter) ? converter(value) : value; - } - - var config = $.cookie = function (key, value, options) { - - // Write - if (value !== undefined && !$.isFunction(value)) { - options = $.extend({}, config.defaults, options); - - if (typeof options.expires === 'number') { - var days = options.expires, t = options.expires = new Date(); - t.setDate(t.getDate() + days); - } - - return (document.cookie = [ - encode(key), '=', stringifyCookieValue(value), - options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE - options.path ? '; path=' + options.path : '', - options.domain ? '; domain=' + options.domain : '', - options.secure ? '; secure' : '' - ].join('')); - } - - // Read - - var result = key ? undefined : {}; - - // To prevent the for loop in the first place assign an empty array - // in case there are no cookies at all. Also prevents odd result when - // calling $.cookie(). - var cookies = document.cookie ? document.cookie.split('; ') : []; - - for (var i = 0, l = cookies.length; i < l; i++) { - var parts = cookies[i].split('='); - var name = decode(parts.shift()); - var cookie = parts.join('='); - - if (key && key === name) { - // If second argument (value) is a function it's a converter... - result = read(cookie, value); - break; - } - - // Prevent storing a cookie that we couldn't decode. - if (!key && (cookie = read(cookie)) !== undefined) { - result[name] = cookie; - } - } - - return result; - }; - - config.defaults = {}; - - $.removeCookie = function (key, options) { - if ($.cookie(key) !== undefined) { - // Must not alter options, thus extending a fresh object... - $.cookie(key, '', $.extend({}, options, { expires: -1 })); - return true; - } - return false; - }; - -})); diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/tags.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/tags.twig deleted file mode 100755 index 65930eb2..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/tags.twig +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "layout.twig" %} -{% block title %}Tags{% endblock %} -{% block menu %} -{% include '_menu.twig' %} -{% endblock %} -{% block content %} -

{% trans "Tags" %}

- -{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/theme.ini b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/theme.ini deleted file mode 100644 index 31665e18..00000000 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/theme.ini +++ /dev/null @@ -1,3 +0,0 @@ -name = Baggy -description = Responsive black and white theme especially adapted to smartphones. -requirements[] = default -- cgit v1.2.3