]> git.wh0rd.org - tt-rss.git/commitdiff
rework user CSS support (bump schema)
authorAndrew Dolgov <fox@fakecake.org>
Wed, 24 Nov 2010 16:23:24 +0000 (19:23 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Wed, 24 Nov 2010 16:23:24 +0000 (19:23 +0300)
12 files changed:
functions.php
modules/popup-dialog.php
modules/pref-prefs.php
prefs.js
prefs.php
sanity_check.php
schema/ttrss_schema_mysql.sql
schema/ttrss_schema_pgsql.sql
schema/versions/mysql/77.sql [new file with mode: 0644]
schema/versions/pgsql/77.sql [new file with mode: 0644]
tt-rss.css
tt-rss.php

index 5e567af033710edb515abf38ebdcb67c30ed5047..28f2cc892f9a8bc80ed63c704cd4893b6873e275 100644 (file)
                }
        }
 
+       function print_user_stylesheet($link) {
+               $value = get_pref($link, 'USER_STYLESHEET');
+
+               if ($value) {
+                       print "<style type=\"text/css\">";
+                       print $value;
+                       print "</style>";
+               }
+
+       }
+
 ?>
index 52b1f94f6da33ddaf7cb04905a9677626cbea53f..394ee16a07e852124ab2ff64f4b5c05260902d24 100644 (file)
 
                }
 
+               if ($id == "customizeCSS") {
+
+                       $value = get_pref($link, "USER_STYLESHEET");
+
+                       print T_sprintf("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here. <a target=\"_blank\" class=\"visibleLink\" href=\"%s\">This file</a> can be used as a baseline.", "tt-rss.css");
+
+                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"rpc\">";
+                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"subop\" value=\"setpref\">";
+                       print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"key\" value=\"USER_STYLESHEET\">";
+
+                       print "<p><textarea dojoType=\"dijit.form.SimpleTextarea\"
+                               style='font-size : 12px; width : 100%; height: 200px;'
+                               placeHolder='body#ttrssMain { font-size : 14px; };'
+                               name='value'>$value</textarea>";
+
+                       print "<div class='dlgButtons'>";
+                       print "<button dojoType=\"dijit.form.Button\"
+                               onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> ";
+                       print "<button dojoType=\"dijit.form.Button\"
+                               onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>";
+                       print "</div>";
+
+               }
+
                print "</dlg>"; 
        }
 ?>
index 5bc180de4986c6429c35e2fbd09839edd4e7b113..359359733315095245b6cf540316f4782ee20ace 100644 (file)
@@ -16,7 +16,7 @@
                $prefs_blacklist = array("HIDE_FEEDLIST", "SYNC_COUNTERS", "ENABLE_LABELS",
                        "ENABLE_SEARCH_TOOLBAR", "HIDE_READ_FEEDS", "ENABLE_FEED_ICONS", 
                        "ENABLE_OFFLINE_READING", "EXTENDED_FEEDLIST", "FEEDS_SORT_BY_UNREAD",
-                       "OPEN_LINKS_IN_NEW_WINDOW");
+                       "OPEN_LINKS_IN_NEW_WINDOW", "USER_STYLESHEET_URL");
 
                $profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS", 
                        "PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP", 
                                        $timezones = explode("\n", file_get_contents("lib/timezones.txt"));
 
                                        print_select($pref_name, $value, $timezones, 'dojoType="dijit.form.FilteringSelect"');
+                               } else if ($pref_name == "USER_STYLESHEET") {
+
+                                       print "<button dojoType=\"dijit.form.Button\"
+                                               onclick=\"customizeCSS()\">" . __('Customize') . "</button>";
 
                                } else if ($pref_name == "DEFAULT_UPDATE_INTERVAL") {
 
index f83ff0d92623ec422241db632bb85bb3bb4e1953..ea2bf09d343134d55235be5a94d206628c35c26e 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -926,6 +926,7 @@ function init() {
                dojo.require("dijit.InlineEditBox");
                dojo.require("dijit.ColorPalette");
                dojo.require("dijit.ProgressBar"); 
+               dojo.require("dijit.form.SimpleTextarea");
 
                dojo.registerModulePath("lib", "..");
                dojo.registerModulePath("fox", "../..");
@@ -1719,3 +1720,33 @@ function clearTwitterCredentials() {
                exception_error("clearTwitterCredentials", e);
        }
 }
+
+function customizeCSS() {
+       try {
+               var query = "backend.php?op=dlg&id=customizeCSS";
+
+               if (dijit.byId("cssEditDlg"))
+                       dijit.byId("cssEditDlg").destroyRecursive();
+
+               dialog = new dijit.Dialog({
+                       id: "cssEditDlg",
+                       title: __("Customize stylesheet"),
+                       style: "width: 600px",
+                       execute: function() {
+                               notify_progress('Saving data...', true);
+                               new Ajax.Request("backend.php", {
+                                       parameters: dojo.objectToQuery(this.attr('value')),
+                                       onComplete: function(transport) { 
+                                               notify('');
+                                               window.location.reload();
+                               } });
+
+                       },
+                       href: query});
+
+               dialog.show();
+
+       } catch (e) {
+               exception_error("customizeCSS", e);
+       }
+}
index 972e577ca6840ee6225dda5ed9e63fb839560330..891b9c8aaa092a6d607422b107b42bc9625b313f 100644 (file)
--- a/prefs.php
+++ b/prefs.php
        <link rel="stylesheet" type="text/css" href="lib/dijit/themes/claro/claro.css"/>
 
        <?php print_theme_includes($link) ?>
+       <?php print_user_stylesheet($link) ?>
        
-       <?php $user_css_url = get_pref($link, 'USER_STYLESHEET_URL'); ?>
-       <?php if ($user_css_url) { ?>
-               <link type="text/css" href="<?php echo $user_css_url ?>"/> 
-       <?php } ?>
-
        <link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
 
        <script type="text/javascript" src="lib/prototype.js"></script>
index 1651ceec03cf99e568363237499332b6a5d9e033..628499d172391416a5e414a32fc6014a71b23071 100644 (file)
@@ -2,7 +2,7 @@
        require_once "functions.php";
 
        define('EXPECTED_CONFIG_VERSION', 20);
-       define('SCHEMA_VERSION', 76);
+       define('SCHEMA_VERSION', 77);
 
        if (!file_exists("config.php")) {
                print "<b>Fatal Error</b>: You forgot to copy 
index e64df5a904163d2efe84b52d0671335004136ab1..cf0cbb5fa626fdd12c77bff82cd51ba423655caa 100644 (file)
@@ -258,7 +258,7 @@ create table ttrss_tags (id integer primary key auto_increment,
 
 create table ttrss_version (schema_version int not null) TYPE=InnoDB DEFAULT CHARSET=UTF8;
 
-insert into ttrss_version values (76);
+insert into ttrss_version values (77);
 
 create table ttrss_enclosures (id integer primary key auto_increment,
        content_url text not null,
@@ -419,13 +419,15 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
 
 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) values('USER_TIMEZONE', 2, 'UTC', 'User timezone', 1);
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('USER_STYLESHEET', 2, '', 'Customize stylesheet', 2, 'Customize CSS stylesheet to your liking');
+
 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'true', 'Sort headlines by feed date',3,
        'Use feed-specified date to sort headlines instead of local import date.');
 
 create table ttrss_user_prefs (
    owner_uid integer not null,
    pref_name varchar(250),
-   value text not null,
+   value longtext not null,
        profile integer,
        index (profile),
        foreign key (profile) references ttrss_settings_profiles(id) ON DELETE CASCADE,
index fbbcab05b8d6b49bc28dfeb442c2f5965abc2184..b7be21d8efc5b9a6d00816c3357f9e83735b4389 100644 (file)
@@ -229,7 +229,7 @@ create index ttrss_tags_post_int_id_idx on ttrss_tags(post_int_id);
 
 create table ttrss_version (schema_version int not null);
 
-insert into ttrss_version values (76);
+insert into ttrss_version values (77);
 
 create table ttrss_enclosures (id serial not null primary key,
        content_url text not null,
@@ -385,6 +385,8 @@ insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id) valu
 insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('SORT_HEADLINES_BY_FEED_DATE', 1, 'true', 'Sort headlines by feed date',3,
        'Use feed-specified date to sort headlines instead of local import date.');
 
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('USER_STYLESHEET', 2, '', 'Customize stylesheet', 2, 'Customize CSS stylesheet to your liking');
+
 create table ttrss_user_prefs (
        owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
        pref_name varchar(250) not null references ttrss_prefs(pref_name) ON DELETE CASCADE,
diff --git a/schema/versions/mysql/77.sql b/schema/versions/mysql/77.sql
new file mode 100644 (file)
index 0000000..944f31d
--- /dev/null
@@ -0,0 +1,7 @@
+begin;
+
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('USER_STYLESHEET', 2, '', 'Customize stylesheet', 2, 'Customize CSS stylesheet to your liking');
+
+update ttrss_version set schema_version = 77;
+
+commit;
diff --git a/schema/versions/pgsql/77.sql b/schema/versions/pgsql/77.sql
new file mode 100644 (file)
index 0000000..944f31d
--- /dev/null
@@ -0,0 +1,7 @@
+begin;
+
+insert into ttrss_prefs (pref_name,type_id,def_value,short_desc,section_id,help_text) values('USER_STYLESHEET', 2, '', 'Customize stylesheet', 2, 'Customize CSS stylesheet to your liking');
+
+update ttrss_version set schema_version = 77;
+
+commit;
index e5184d73e64cceb864cfecb85a4553c6fff8528b..4e767efb8c09e83fe1458cc61370b4a6dbd086ac 100644 (file)
@@ -306,13 +306,13 @@ input.editbox {
 
 /* preferences */
 
-table.prefPrefsList tr:hover td.prefValue {
+/* table.prefPrefsList tr:hover td.prefValue {
        color : #88b0f0;
 }
 
 table.prefPrefsList tr:hover td.prefValue input {
        color : #88b0f0;
-}
+} */
 
 table.prefPrefsList h3 {
        margin-top : 0px;
@@ -1664,3 +1664,4 @@ a.bookmarklet {
        top : -1px;
 }
 
+
index f51648fef449fe725e6f7bce15e180229496fc73..b3dcd6a8d3b3701d223f4115cb010937f0405f7c 100644 (file)
        <link rel="stylesheet" type="text/css" href="lib/dijit/themes/claro/claro.css"/>
 
        <?php print_theme_includes($link) ?>
-
-       <?php $user_css_url = get_pref($link, 'USER_STYLESHEET_URL'); ?>
-       <?php if ($user_css_url) { ?>
-               <link rel="stylesheet" type="text/css" href="<?php echo $user_css_url ?>"/> 
-       <?php } ?>
+       <?php print_user_stylesheet($link) ?>
 
        <link rel="shortcut icon" type="image/png" href="images/favicon.png"/>