diff options
137 files changed, 11102 insertions, 8170 deletions
diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000..6d76f6082 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,300 @@ +module.exports = { + "env": { + "browser": true, + "es6": true, + "jquery": true, + "webextensions": true + }, + "extends": "eslint:recommended", + "parserOptions": { + "ecmaVersion": 2017 + }, + "rules": { + "accessor-pairs": "error", + "array-bracket-newline": "off", + "array-bracket-spacing": "off", + "array-callback-return": "error", + "array-element-newline": "off", + "arrow-body-style": "error", + "arrow-parens": "error", + "arrow-spacing": "error", + "block-scoped-var": "off", + "block-spacing": [ + "error", + "always" + ], + "brace-style": "off", + "callback-return": "off", + "camelcase": "off", + "capitalized-comments": "off", + "class-methods-use-this": "error", + "comma-dangle": "off", + "comma-spacing": "off", + "comma-style": [ + "error", + "last" + ], + "complexity": "off", + "computed-property-spacing": [ + "error", + "never" + ], + "consistent-return": "off", + "consistent-this": "off", + "curly": "off", + "default-case": "off", + "dot-location": "off", + "dot-notation": "off", + "eol-last": "error", + "eqeqeq": "off", + "func-call-spacing": "error", + "func-name-matching": "error", + "func-names": "off", + "func-style": "off", + "function-paren-newline": "off", + "generator-star-spacing": "error", + "global-require": "error", + "guard-for-in": "off", + "handle-callback-err": "off", + "id-blacklist": "error", + "id-length": "off", + "id-match": "error", + "implicit-arrow-linebreak": "off", + "indent": "off", + "indent-legacy": "off", + "init-declarations": "off", + "jsx-quotes": "error", + "key-spacing": "off", + "keyword-spacing": [ + "error", + { + "after": true, + "before": true + } + ], + "line-comment-position": "off", + "linebreak-style": [ + "error", + "unix" + ], + "lines-around-comment": "off", + "lines-around-directive": "error", + "lines-between-class-members": "error", + "max-classes-per-file": "off", + "max-depth": "off", + "max-len": "off", + "max-lines": "off", + "max-lines-per-function": "off", + "max-nested-callbacks": "error", + "max-params": "off", + "max-statements": "off", + "max-statements-per-line": [ "warn", { "max" : 2 } ], + "multiline-comment-style": "off", + "multiline-ternary": "off", + "new-cap": "warn", + "new-parens": "error", + "newline-after-var": "off", + "newline-before-return": "off", + "newline-per-chained-call": "off", + "no-alert": "off", + "no-array-constructor": "error", + "no-async-promise-executor": "off", + "no-await-in-loop": "warn", + "no-bitwise": "off", + "no-buffer-constructor": "error", + "no-caller": "error", + "no-catch-shadow": "off", + "no-confusing-arrow": "error", + "no-continue": "off", + "no-console": "off", + "no-div-regex": "error", + "no-duplicate-imports": "error", + "no-else-return": "off", + "no-empty": [ + "error", + { + "allowEmptyCatch": true + } + ], + "no-empty-function": "error", + "no-eq-null": "off", + "no-eval": "error", + "no-extend-native": "off", + "no-extra-bind": "error", + "no-extra-label": "error", + "no-extra-parens": "off", + "no-floating-decimal": "error", + "no-implicit-globals": "off", + "no-implied-eval": "off", + "no-inline-comments": "off", + "no-inner-declarations": [ + "error", + "functions" + ], + "no-invalid-this": "error", + "no-iterator": "error", + "no-label-var": "error", + "no-labels": "error", + "no-lone-blocks": "error", + "no-lonely-if": "error", + "no-loop-func": "off", + "no-magic-numbers": "off", + "no-misleading-character-class": "off", + "no-mixed-operators": "off", + "no-mixed-requires": "error", + "no-multi-assign": "error", + "no-multi-spaces": "off", + "no-multi-str": "error", + "no-multiple-empty-lines": "error", + "no-native-reassign": "error", + "no-negated-condition": "off", + "no-negated-in-lhs": "error", + "no-nested-ternary": "error", + "no-new": "warn", + "no-new-func": "error", + "no-new-object": "off", + "no-new-require": "error", + "no-new-wrappers": "error", + "no-octal-escape": "error", + "no-param-reassign": "off", + "no-path-concat": "error", + "no-plusplus": "off", + "no-process-env": "error", + "no-process-exit": "error", + "no-proto": "error", + "no-prototype-builtins": "warn", + "no-restricted-globals": "error", + "no-restricted-imports": "error", + "no-restricted-modules": "error", + "no-restricted-properties": "error", + "no-restricted-syntax": "error", + "no-return-assign": [ + "error", + "except-parens" + ], + "no-return-await": "error", + "no-script-url": "error", + "no-self-compare": "error", + "no-sequences": "error", + "no-shadow": "off", + "no-shadow-restricted-names": "error", + "no-spaced-func": "error", + "no-sync": "error", + "no-tabs": "off", + "no-template-curly-in-string": "error", + "no-ternary": "off", + "no-throw-literal": "error", + "no-trailing-spaces": "error", + "no-undef-init": "error", + "no-undefined": "off", + "no-undef": "warn", + "no-underscore-dangle": "off", + "no-unmodified-loop-condition": "error", + "no-unneeded-ternary": [ + "error", + { + "defaultAssignment": true + } + ], + "no-unused-expressions": "off", + "no-unused-vars": "warn", + "no-use-before-define": "off", + "no-useless-call": "error", + "no-useless-computed-key": "error", + "no-useless-concat": "error", + "no-useless-constructor": "error", + "no-useless-rename": "error", + "no-useless-return": "off", + "no-var": "warn", + "no-void": "error", + "no-warning-comments": "off", + "no-whitespace-before-property": "error", + "no-with": "error", + "nonblock-statement-body-position": [ + "error", + "any" + ], + "object-curly-newline": "off", + "object-curly-spacing": "off", + "object-property-newline": "off", + "object-shorthand": "off", + "one-var": "off", + "one-var-declaration-per-line": "error", + "operator-assignment": "off", + "operator-linebreak": [ + "error", + "after" + ], + "padded-blocks": "off", + "padding-line-between-statements": "error", + "prefer-arrow-callback": "off", + "prefer-const": "error", + "prefer-destructuring": "off", + "prefer-numeric-literals": "error", + "prefer-object-spread": "off", + "prefer-promise-reject-errors": "error", + "prefer-reflect": "off", + "prefer-rest-params": "error", + "prefer-spread": "error", + "prefer-template": "off", + "quote-props": "off", + "quotes": "off", + "radix": [ + "error", + "as-needed" + ], + "require-atomic-updates": "off", + "require-await": "warn", + "require-jsdoc": "off", + "require-unicode-regexp": "off", + "rest-spread-spacing": "error", + "semi": "off", + "semi-spacing": [ + "error", + { + "after": true, + "before": false + } + ], + "semi-style": [ + "error", + "last" + ], + "sort-imports": "error", + "sort-keys": "off", + "sort-vars": "off", + "space-before-blocks": "off", + "space-before-function-paren": "off", + "space-in-parens": "off", + "space-infix-ops": "off", + "space-unary-ops": [ + "error", + { + "nonwords": false, + "words": false + } + ], + "spaced-comment": "off", + "strict": [ + "off", + "never" + ], + "switch-colon-spacing": "error", + "symbol-description": "error", + "template-curly-spacing": "error", + "template-tag-spacing": "error", + "unicode-bom": [ + "error", + "never" + ], + "valid-jsdoc": "error", + "vars-on-top": "off", + "wrap-iife": "error", + "wrap-regex": "error", + "yield-star-spacing": "error", + "yoda": [ + "error", + "never" + ] + } +}; diff --git a/.gitignore b/.gitignore index 3f98b7a42..3796eeb8c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ Thumbs.db /deploy.exclude /deploy.sh /messages.mo +/node_modules +/package-lock.json *~ *.DS_Store #* diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..006e87850 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,11 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "gulp", + "task": "default", + "problemMatcher": [], + "label": "gulp: default" + } + ] +}
\ No newline at end of file diff --git a/api/index.php b/api/index.php index 363f2ae13..8e85919c6 100644 --- a/api/index.php +++ b/api/index.php @@ -67,7 +67,7 @@ return; } - load_user_plugins( $_SESSION["uid"]); + UserHelper::load_user_plugins( $_SESSION["uid"]); } $method = strtolower($_REQUEST["op"]); diff --git a/atom-to-html.xsl b/atom-to-html.xsl deleted file mode 100644 index 79ce42891..000000000 --- a/atom-to-html.xsl +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<xsl:stylesheet - xmlns:atom="http://www.w3.org/2005/Atom" - xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> - -<xsl:output method="html"/> - -<xsl:template match="/atom:feed"> -<html> - <head> - <title><xsl:value-of select="atom:title"/></title> - <link rel="stylesheet" type="text/css" href="themes/light.css"/> - <script language="javascript" src="lib/xsl_mop-up.js"></script> - </head> - - <body onload="go_decoding()" class="ttrss_utility"> - - <div id="cometestme" style="display:none;"> - <xsl:text disable-output-escaping="yes">&amp;</xsl:text> - </div> - - <div class="rss"> - - <h1><xsl:value-of select="atom:title"/></h1> - - <p class="description">This feed has been exported from - <a target="_new" class="extlink" href="http://tt-rss.org">Tiny Tiny RSS</a>. - It contains the following items:</p> - - <xsl:for-each select="atom:entry"> - <h2><a target="_new" href="{atom:link/@href}"><xsl:value-of select="atom:title"/></a></h2> - - <div name="decodeme" class="content"> - <xsl:value-of select="atom:content" disable-output-escaping="yes"/> - </div> - - <xsl:if test="enclosure"> - <p><a href="{enclosure/@url}">Extra...</a></p> - </xsl:if> - - - </xsl:for-each> - - </div> - - </body> - </html> -</xsl:template> - -</xsl:stylesheet> - diff --git a/backend.php b/backend.php index e65ce1b94..4c93f9b6d 100644 --- a/backend.php +++ b/backend.php @@ -12,15 +12,14 @@ /* Public calls compatibility shim */ - $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share", - "fbexport", "logout", "pubsub"); + $public_calls = array("globalUpdateFeeds", "rss", "getUnread", "getProfiles", "share"); if (array_search($op, $public_calls) !== false) { header("Location: public.php?" . $_SERVER['QUERY_STRING']); return; } - @$csrf_token = $_REQUEST['csrf_token']; + @$csrf_token = $_POST['csrf_token']; require_once "autoload.php"; require_once "sessions.php"; @@ -42,7 +41,7 @@ } if (SINGLE_USER_MODE) { - authenticate_user( "admin", null); + UserHelper::authenticate( "admin", null); } if ($_SESSION["uid"]) { @@ -51,7 +50,7 @@ print error_json(6); return; } - load_user_plugins( $_SESSION["uid"]); + UserHelper::load_user_plugins($_SESSION["uid"]); } $purge_intervals = array( @@ -108,7 +107,14 @@ if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) { if ($handler->before($method)) { if ($method && method_exists($handler, $method)) { - $handler->$method(); + $reflection = new ReflectionMethod($handler, $method); + + if ($reflection->getNumberOfRequiredParameters() == 0) { + $handler->$method(); + } else { + header("Content-Type: text/json"); + print error_json(6); + } } else { if (method_exists($handler, "catchall")) { $handler->catchall($method); diff --git a/classes/api.php b/classes/api.php index 339e9eef1..928148b5e 100755 --- a/classes/api.php +++ b/classes/api.php @@ -74,10 +74,10 @@ class API extends Handler { } if (get_pref("ENABLE_API_ACCESS", $uid)) { - if (authenticate_user($login, $password, false, Auth_Base::AUTH_SERVICE_API)) { // try login with normal password + if (UserHelper::authenticate($login, $password, false, Auth_Base::AUTH_SERVICE_API)) { // try login with normal password $this->wrap(self::STATUS_OK, array("session_id" => session_id(), "api_level" => self::API_LEVEL)); - } else if (authenticate_user($login, $password_base64, false, Auth_Base::AUTH_SERVICE_API)) { // else try with base64_decoded password + } else if (UserHelper::authenticate($login, $password_base64, false, Auth_Base::AUTH_SERVICE_API)) { // else try with base64_decoded password $this->wrap(self::STATUS_OK, array("session_id" => session_id(), "api_level" => self::API_LEVEL)); } else { // else we are not logged in @@ -91,7 +91,7 @@ class API extends Handler { } function logout() { - logout_user(); + Pref_Users::logout_user(); $this->wrap(self::STATUS_OK, array("status" => "OK")); } @@ -117,10 +117,10 @@ class API extends Handler { function getFeeds() { $cat_id = clean($_REQUEST["cat_id"]); - $unread_only = API::param_to_bool(clean($_REQUEST["unread_only"])); + $unread_only = self::param_to_bool(clean($_REQUEST["unread_only"])); $limit = (int) clean($_REQUEST["limit"]); $offset = (int) clean($_REQUEST["offset"]); - $include_nested = API::param_to_bool(clean($_REQUEST["include_nested"])); + $include_nested = self::param_to_bool(clean($_REQUEST["include_nested"])); $feeds = $this->api_get_feeds($cat_id, $unread_only, $limit, $offset, $include_nested); @@ -128,9 +128,9 @@ class API extends Handler { } function getCategories() { - $unread_only = API::param_to_bool(clean($_REQUEST["unread_only"])); - $enable_nested = API::param_to_bool(clean($_REQUEST["enable_nested"])); - $include_empty = API::param_to_bool(clean($_REQUEST['include_empty'])); + $unread_only = self::param_to_bool(clean($_REQUEST["unread_only"])); + $enable_nested = self::param_to_bool(clean($_REQUEST["enable_nested"])); + $include_empty = self::param_to_bool(clean($_REQUEST['include_empty'])); // TODO do not return empty categories, return Uncategorized and standard virtual cats @@ -160,9 +160,9 @@ class API extends Handler { $unread += Feeds::getCategoryChildrenUnread($line["id"]); if ($unread || !$unread_only) { - array_push($cats, array("id" => $line["id"], + array_push($cats, array("id" => (int) $line["id"], "title" => $line["title"], - "unread" => $unread, + "unread" => (int) $unread, "order_id" => (int) $line["order_id"], )); } @@ -174,9 +174,9 @@ class API extends Handler { $unread = getFeedUnread($cat_id, true); if ($unread || !$unread_only) { - array_push($cats, array("id" => $cat_id, + array_push($cats, array("id" => (int) $cat_id, "title" => Feeds::getCategoryTitle($cat_id), - "unread" => $unread)); + "unread" => (int) $unread)); } } } @@ -196,39 +196,25 @@ class API extends Handler { $offset = (int)clean($_REQUEST["skip"]); $filter = clean($_REQUEST["filter"]); - $is_cat = API::param_to_bool(clean($_REQUEST["is_cat"])); - $show_excerpt = API::param_to_bool(clean($_REQUEST["show_excerpt"])); - $show_content = API::param_to_bool(clean($_REQUEST["show_content"])); + $is_cat = self::param_to_bool(clean($_REQUEST["is_cat"])); + $show_excerpt = self::param_to_bool(clean($_REQUEST["show_excerpt"])); + $show_content = self::param_to_bool(clean($_REQUEST["show_content"])); /* all_articles, unread, adaptive, marked, updated */ $view_mode = clean($_REQUEST["view_mode"]); - $include_attachments = API::param_to_bool(clean($_REQUEST["include_attachments"])); + $include_attachments = self::param_to_bool(clean($_REQUEST["include_attachments"])); $since_id = (int)clean($_REQUEST["since_id"]); - $include_nested = API::param_to_bool(clean($_REQUEST["include_nested"])); + $include_nested = self::param_to_bool(clean($_REQUEST["include_nested"])); $sanitize_content = !isset($_REQUEST["sanitize"]) || - API::param_to_bool($_REQUEST["sanitize"]); - $force_update = API::param_to_bool(clean($_REQUEST["force_update"])); - $has_sandbox = API::param_to_bool(clean($_REQUEST["has_sandbox"])); + self::param_to_bool($_REQUEST["sanitize"]); + $force_update = self::param_to_bool(clean($_REQUEST["force_update"])); + $has_sandbox = self::param_to_bool(clean($_REQUEST["has_sandbox"])); $excerpt_length = (int)clean($_REQUEST["excerpt_length"]); $check_first_id = (int)clean($_REQUEST["check_first_id"]); - $include_header = API::param_to_bool(clean($_REQUEST["include_header"])); + $include_header = self::param_to_bool(clean($_REQUEST["include_header"])); $_SESSION['hasSandbox'] = $has_sandbox; - $skip_first_id_check = false; - - $override_order = false; - switch (clean($_REQUEST["order_by"])) { - case "title": - $override_order = "ttrss_entries.title, date_entered, updated"; - break; - case "date_reverse": - $override_order = "score DESC, date_entered, updated"; - $skip_first_id_check = true; - break; - case "feed_dates": - $override_order = "updated DESC"; - break; - } + list($override_order, $skip_first_id_check) = Feeds::order_to_override_query(clean($_REQUEST["order_by"])); /* do not rely on params below */ @@ -313,7 +299,7 @@ class API extends Handler { $article_ids = explode(",", clean($_REQUEST["article_id"])); $sanitize_content = !isset($_REQUEST["sanitize"]) || - API::param_to_bool($_REQUEST["sanitize"]); + self::param_to_bool($_REQUEST["sanitize"]); if ($article_ids) { @@ -342,9 +328,9 @@ class API extends Handler { "title" => $line["title"], "link" => $line["link"], "labels" => Article::get_article_labels($line['id']), - "unread" => API::param_to_bool($line["unread"]), - "marked" => API::param_to_bool($line["marked"]), - "published" => API::param_to_bool($line["published"]), + "unread" => self::param_to_bool($line["unread"]), + "marked" => self::param_to_bool($line["marked"]), + "published" => self::param_to_bool($line["published"]), "comments" => $line["comments"], "author" => $line["author"], "updated" => (int) strtotime($line["updated"]), @@ -357,9 +343,9 @@ class API extends Handler { ); if ($sanitize_content) { - $article["content"] = sanitize( + $article["content"] = Sanitizer::sanitize( $line["content"], - API::param_to_bool($line['hide_images']), + self::param_to_bool($line['hide_images']), false, $line["site_url"], false, $line["id"]); } else { $article["content"] = $line["content"]; @@ -463,7 +449,7 @@ class API extends Handler { $article_ids = explode(",", clean($_REQUEST["article_ids"])); $label_id = (int) clean($_REQUEST['label_id']); - $assign = API::param_to_bool(clean($_REQUEST['assign'])); + $assign = self::param_to_bool(clean($_REQUEST['assign'])); $label = Labels::find_caption(Labels::feed_to_label_id($label_id), $_SESSION["uid"]); @@ -670,7 +656,7 @@ class API extends Handler { if ($row = $sth->fetch()) { $last_updated = strtotime($row["last_updated"]); - $cache_images = API::param_to_bool($row["cache_images"]); + $cache_images = self::param_to_bool($row["cache_images"]); if (!$cache_images && time() - $last_updated > 120) { RSSUtils::update_rss_feed($feed_id, true); @@ -740,9 +726,9 @@ class API extends Handler { $headline_row = array( "id" => (int)$line["id"], "guid" => $line["guid"], - "unread" => API::param_to_bool($line["unread"]), - "marked" => API::param_to_bool($line["marked"]), - "published" => API::param_to_bool($line["published"]), + "unread" => self::param_to_bool($line["unread"]), + "marked" => self::param_to_bool($line["marked"]), + "published" => self::param_to_bool($line["published"]), "updated" => (int)strtotime($line["updated"]), "is_updated" => $is_updated, "title" => $line["title"], @@ -762,9 +748,9 @@ class API extends Handler { if ($show_content) { if ($sanitize_content) { - $headline_row["content"] = sanitize( + $headline_row["content"] = Sanitizer::sanitize( $line["content"], - API::param_to_bool($line['hide_images']), + self::param_to_bool($line['hide_images']), false, $line["site_url"], false, $line["id"]); } else { $headline_row["content"] = $line["content"]; @@ -782,7 +768,7 @@ class API extends Handler { $headline_row["comments_count"] = (int)$line["num_comments"]; $headline_row["comments_link"] = $line["comments"]; - $headline_row["always_display_attachments"] = API::param_to_bool($line["always_display_enclosures"]); + $headline_row["always_display_attachments"] = self::param_to_bool($line["always_display_enclosures"]); $headline_row["author"] = $line["author"]; @@ -841,7 +827,7 @@ class API extends Handler { } function getFeedTree() { - $include_empty = API::param_to_bool(clean($_REQUEST['include_empty'])); + $include_empty = self::param_to_bool(clean($_REQUEST['include_empty'])); $pf = new Pref_Feeds($_REQUEST); diff --git a/classes/article.php b/classes/article.php index 74dbdae53..430109283 100755 --- a/classes/article.php +++ b/classes/article.php @@ -1,12 +1,6 @@ <?php class Article extends Handler_Protected { - function csrf_ignore($method) { - $csrf_ignored = array("redirect", "editarticletags"); - - return array_search($method, $csrf_ignored) !== false; - } - function redirect() { $id = clean($_REQUEST['id']); @@ -60,7 +54,7 @@ class Article extends Handler_Protected { if (!$title) $title = $url; if (!$title && !$url) return false; - if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) return false; + if (filter_var($url, FILTER_VALIDATE_URL) === false) return false; $pdo = Db::pdo(); @@ -94,7 +88,7 @@ class Article extends Handler_Protected { ":id" => $ref_id]; $sth->execute($params); } - + $sth = $pdo->prepare("UPDATE ttrss_user_entries SET published = true, last_published = NOW() WHERE int_id = ? AND owner_uid = ?"); @@ -165,7 +159,7 @@ class Article extends Handler_Protected { $param = clean($_REQUEST['param']); - $tags = Article::get_article_tags($param); + $tags = self::get_article_tags($param); $tags_str = join(", ", $tags); @@ -267,7 +261,7 @@ class Article extends Handler_Protected { $this->pdo->commit(); - $tags = Article::get_article_tags($id); + $tags = self::get_article_tags($id); $tags_str = $this->format_tags_string($tags, $id); $tags_str_full = join(", ", $tags); @@ -350,7 +344,7 @@ class Article extends Handler_Protected { static function format_article_enclosures($id, $always_display_enclosures, $article_content, $hide_images = false) { - $result = Article::get_article_enclosures($id); + $result = self::get_article_enclosures($id); $rv = ''; foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FORMAT_ENCLOSURES) as $plugin) { @@ -393,7 +387,7 @@ class Article extends Handler_Protected { # $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\" rel=\"noopener noreferrer\">" . # $filename . " (" . $ctype . ")" . "</a>"; - $entry = "<div onclick=\"popupOpenUrl('".htmlspecialchars($url)."')\" + $entry = "<div onclick=\"Article.popupOpenUrl('".htmlspecialchars($url)."')\" dojoType=\"dijit.MenuItem\">$filename ($ctype)</div>"; array_push($entries_html, $entry); @@ -473,7 +467,7 @@ class Article extends Handler_Protected { else $filename = ""; - $rv .= "<div onclick='popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' + $rv .= "<div onclick='Article.popupOpenUrl(\"".htmlspecialchars($entry["url"])."\")' dojoType=\"dijit.MenuItem\">".$filename . $title."</div>"; }; @@ -583,7 +577,7 @@ class Article extends Handler_Protected { return "<div class='article-note $note_class'> <i class='material-icons'>note</i> - <div $onclick class='body'>$note</div> + <div $onclick class='body'>$note</div> </div>"; return $str; @@ -658,7 +652,7 @@ class Article extends Handler_Protected { } static function getLastArticleId() { - $pdo = DB::pdo(); + $pdo = Db::pdo(); $sth = $pdo->prepare("SELECT ref_id AS id FROM ttrss_user_entries WHERE owner_uid = ? ORDER BY ref_id DESC LIMIT 1"); @@ -763,7 +757,7 @@ class Article extends Handler_Protected { if (!$article_image) foreach ($enclosures as $enc) { - if (strpos($enc["content_type"], "image/") !== FALSE) { + if (strpos($enc["content_type"], "image/") !== false) { $article_image = $enc["content_url"]; break; } diff --git a/classes/backend.php b/classes/backend.php index 122e28c65..16c20660a 100644 --- a/classes/backend.php +++ b/classes/backend.php @@ -1,12 +1,6 @@ <?php -class Backend extends Handler { - function loading() { - header("Content-type: text/html"); - print __("Loading, please wait...") . " " . - "<img src='images/indicator_tiny.gif'>"; - } - - function digestTest() { +class Backend extends Handler_Protected { + /* function digestTest() { if (isset($_SESSION['uid'])) { header("Content-type: text/html"); @@ -19,80 +13,14 @@ class Backend extends Handler { } else { print error_json(6); } - } - - private function display_main_help() { - $info = get_hotkeys_info(); - $imap = get_hotkeys_map(); - $omap = array(); - - foreach ($imap[1] as $sequence => $action) { - if (!isset($omap[$action])) $omap[$action] = array(); - - array_push($omap[$action], $sequence); - } - - print "<ul class='panel panel-scrollable hotkeys-help' style='height : 300px'>"; - - print "<h2>" . __("Keyboard Shortcuts") . "</h2>"; - - foreach ($info as $section => $hotkeys) { - - print "<li><hr></li>"; - print "<li><h3>" . $section . "</h3></li>"; - - foreach ($hotkeys as $action => $description) { - - if (is_array($omap[$action])) { - foreach ($omap[$action] as $sequence) { - if (strpos($sequence, "|") !== FALSE) { - $sequence = substr($sequence, - strpos($sequence, "|")+1, - strlen($sequence)); - } else { - $keys = explode(" ", $sequence); - - for ($i = 0; $i < count($keys); $i++) { - if (strlen($keys[$i]) > 1) { - $tmp = ''; - foreach (str_split($keys[$i]) as $c) { - switch ($c) { - case '*': - $tmp .= __('Shift') . '+'; - break; - case '^': - $tmp .= __('Ctrl') . '+'; - break; - default: - $tmp .= $c; - } - } - $keys[$i] = $tmp; - } - } - $sequence = join(" ", $keys); - } - - print "<li>"; - print "<div class='hk'><code>$sequence</code></div>"; - print "<div class='desc'>$description</div>"; - print "</li>"; - } - } - } - } - - print "</ul>"; - - - } + } */ function help() { - $topic = clean_filename($_REQUEST["topic"]); // only one for now + $topic = basename(clean($_REQUEST["topic"])); // only one for now if ($topic == "main") { - $info = get_hotkeys_info(); - $imap = get_hotkeys_map(); + $info = RPC::get_hotkeys_info(); + $imap = RPC::get_hotkeys_map(); $omap = array(); foreach ($imap[1] as $sequence => $action) { @@ -114,7 +42,7 @@ class Backend extends Handler { if (is_array($omap[$action])) { foreach ($omap[$action] as $sequence) { - if (strpos($sequence, "|") !== FALSE) { + if (strpos($sequence, "|") !== false) { $sequence = substr($sequence, strpos($sequence, "|")+1, strlen($sequence)); diff --git a/classes/counters.php b/classes/counters.php index d8ed27621..be634c52a 100644 --- a/classes/counters.php +++ b/classes/counters.php @@ -2,12 +2,12 @@ class Counters { static function getAllCounters() { - $data = Counters::getGlobalCounters(); + $data = self::getGlobalCounters(); - $data = array_merge($data, Counters::getVirtCounters()); - $data = array_merge($data, Counters::getLabelCounters()); - $data = array_merge($data, Counters::getFeedCounters()); - $data = array_merge($data, Counters::getCategoryCounters()); + $data = array_merge($data, self::getVirtCounters()); + $data = array_merge($data, self::getLabelCounters()); + $data = array_merge($data, self::getFeedCounters()); + $data = array_merge($data, self::getCategoryCounters()); return $data; } @@ -23,7 +23,7 @@ class Counters { $marked = 0; while ($line = $sth->fetch()) { - list ($tmp_unread, $tmp_marked) = Counters::getCategoryChildrenCounters($line["id"], $owner_uid); + list ($tmp_unread, $tmp_marked) = self::getCategoryChildrenCounters($line["id"], $owner_uid); $unread += $tmp_unread + Feeds::getCategoryUnread($line["id"], $owner_uid); $marked += $tmp_marked + Feeds::getCategoryMarked($line["id"], $owner_uid); @@ -42,7 +42,7 @@ class Counters { array_push($ret, $cv); - $pdo = DB::pdo(); + $pdo = Db::pdo(); $sth = $pdo->prepare("SELECT fc.id, SUM(CASE WHEN unread THEN 1 ELSE 0 END) AS count, @@ -68,7 +68,7 @@ class Counters { while ($line = $sth->fetch()) { if ($line["num_children"] > 0) { - list ($child_counter, $child_marked_counter) = Counters::getCategoryChildrenCounters($line["id"], $_SESSION["uid"]); + list ($child_counter, $child_marked_counter) = self::getCategoryChildrenCounters($line["id"], $_SESSION["uid"]); } else { $child_counter = 0; $child_marked_counter = 0; @@ -112,7 +112,7 @@ class Counters { $id = $line["id"]; $last_error = htmlspecialchars($line["last_error"]); - $last_updated = make_local_datetime($line['last_updated'], false); + $last_updated = TimeHelper::make_local_datetime($line['last_updated'], false); if (Feeds::feedHasIcon($id)) { $has_img = filemtime(Feeds::getIconFile($id)); @@ -234,8 +234,8 @@ class Counters { COUNT(u1.unread) AS total FROM ttrss_labels2 LEFT JOIN ttrss_user_labels2 ON (ttrss_labels2.id = label_id) - LEFT JOIN ttrss_user_entries AS u1 ON u1.ref_id = article_id - WHERE ttrss_labels2.owner_uid = :uid AND u1.owner_uid = :uid + LEFT JOIN ttrss_user_entries AS u1 ON u1.ref_id = article_id AND u1.owner_uid = :uid + WHERE ttrss_labels2.owner_uid = :uid GROUP BY ttrss_labels2.id, ttrss_labels2.caption"); $sth->execute([":uid" => $_SESSION['uid']]); diff --git a/classes/db.php b/classes/db.php index ac493f6d6..70b97d0ee 100755 --- a/classes/db.php +++ b/classes/db.php @@ -113,4 +113,13 @@ class Db return self::$instance->pdo; } + + public static function sql_random_function() { + if (DB_TYPE == "mysql") { + return "RAND()"; + } else { + return "RANDOM()"; + } + } + } diff --git a/classes/debug.php b/classes/debug.php index c62f0c9f5..3061c6893 100644 --- a/classes/debug.php +++ b/classes/debug.php @@ -11,40 +11,40 @@ class Debug { private static $loglevel = 0; public static function set_logfile($logfile) { - Debug::$logfile = $logfile; + self::$logfile = $logfile; } public static function enabled() { - return Debug::$enabled; + return self::$enabled; } public static function set_enabled($enable) { - Debug::$enabled = $enable; + self::$enabled = $enable; } public static function set_quiet($quiet) { - Debug::$quiet = $quiet; + self::$quiet = $quiet; } public static function set_loglevel($level) { - Debug::$loglevel = $level; + self::$loglevel = $level; } public static function get_loglevel() { - return Debug::$loglevel; + return self::$loglevel; } public static function log($message, $level = 0) { - if (!Debug::$enabled || Debug::$loglevel < $level) return false; + if (!self::$enabled || self::$loglevel < $level) return false; $ts = strftime("%H:%M:%S", time()); if (function_exists('posix_getpid')) { $ts = "$ts/" . posix_getpid(); } - if (Debug::$logfile) { - $fp = fopen(Debug::$logfile, 'a+'); + if (self::$logfile) { + $fp = fopen(self::$logfile, 'a+'); if ($fp) { $locked = false; @@ -60,7 +60,7 @@ class Debug { if (!$locked) { fclose($fp); - user_error("Unable to lock debugging log file: " . Debug::$logfile, E_USER_WARNING); + user_error("Unable to lock debugging log file: " . self::$logfile, E_USER_WARNING); return; } } @@ -73,14 +73,14 @@ class Debug { fclose($fp); - if (Debug::$quiet) + if (self::$quiet) return; } else { - user_error("Unable to open debugging log file: " . Debug::$logfile, E_USER_WARNING); + user_error("Unable to open debugging log file: " . self::$logfile, E_USER_WARNING); } } print "[$ts] $message\n"; } -}
\ No newline at end of file +} diff --git a/classes/digest.php b/classes/digest.php index c9e9f24e7..5128b4186 100644 --- a/classes/digest.php +++ b/classes/digest.php @@ -90,16 +90,14 @@ class Digest static function prepare_headlines_digest($user_id, $days = 1, $limit = 1000) { - require_once "lib/MiniTemplator.class.php"; + $tpl = new Templator(); + $tpl_t = new Templator(); - $tpl = new MiniTemplator; - $tpl_t = new MiniTemplator; - - $tpl->readTemplateFromFile("templates/digest_template_html.txt"); - $tpl_t->readTemplateFromFile("templates/digest_template.txt"); + $tpl->readTemplateFromFile("digest_template_html.txt"); + $tpl_t->readTemplateFromFile("digest_template.txt"); $user_tz_string = get_pref('USER_TIMEZONE', $user_id); - $local_ts = convert_timestamp(time(), 'UTC', $user_tz_string); + $local_ts = TimeHelper::convert_timestamp(time(), 'UTC', $user_tz_string); $tpl->setVariable('CUR_DATE', date('Y/m/d', $local_ts)); $tpl->setVariable('CUR_TIME', date('G:i', $local_ts)); @@ -161,7 +159,7 @@ class Digest array_push($affected_ids, $line["ref_id"]); - $updated = make_local_datetime($line['last_updated'], false, + $updated = TimeHelper::make_local_datetime($line['last_updated'], false, $user_id); if (get_pref('ENABLE_FEED_CATS', $user_id)) { diff --git a/classes/diskcache.php b/classes/diskcache.php index 7e4a8335d..24e45ea8b 100644 --- a/classes/diskcache.php +++ b/classes/diskcache.php @@ -2,8 +2,196 @@ class DiskCache { private $dir; + // https://stackoverflow.com/a/53662733 + private $mimeMap = [ + 'video/3gpp2' => '3g2', + 'video/3gp' => '3gp', + 'video/3gpp' => '3gp', + 'application/x-compressed' => '7zip', + 'audio/x-acc' => 'aac', + 'audio/ac3' => 'ac3', + 'application/postscript' => 'ai', + 'audio/x-aiff' => 'aif', + 'audio/aiff' => 'aif', + 'audio/x-au' => 'au', + 'video/x-msvideo' => 'avi', + 'video/msvideo' => 'avi', + 'video/avi' => 'avi', + 'application/x-troff-msvideo' => 'avi', + 'application/macbinary' => 'bin', + 'application/mac-binary' => 'bin', + 'application/x-binary' => 'bin', + 'application/x-macbinary' => 'bin', + 'image/bmp' => 'bmp', + 'image/x-bmp' => 'bmp', + 'image/x-bitmap' => 'bmp', + 'image/x-xbitmap' => 'bmp', + 'image/x-win-bitmap' => 'bmp', + 'image/x-windows-bmp' => 'bmp', + 'image/ms-bmp' => 'bmp', + 'image/x-ms-bmp' => 'bmp', + 'application/bmp' => 'bmp', + 'application/x-bmp' => 'bmp', + 'application/x-win-bitmap' => 'bmp', + 'application/cdr' => 'cdr', + 'application/coreldraw' => 'cdr', + 'application/x-cdr' => 'cdr', + 'application/x-coreldraw' => 'cdr', + 'image/cdr' => 'cdr', + 'image/x-cdr' => 'cdr', + 'zz-application/zz-winassoc-cdr' => 'cdr', + 'application/mac-compactpro' => 'cpt', + 'application/pkix-crl' => 'crl', + 'application/pkcs-crl' => 'crl', + 'application/x-x509-ca-cert' => 'crt', + 'application/pkix-cert' => 'crt', + 'text/css' => 'css', + 'text/x-comma-separated-values' => 'csv', + 'text/comma-separated-values' => 'csv', + 'application/vnd.msexcel' => 'csv', + 'application/x-director' => 'dcr', + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx', + 'application/x-dvi' => 'dvi', + 'message/rfc822' => 'eml', + 'application/x-msdownload' => 'exe', + 'video/x-f4v' => 'f4v', + 'audio/x-flac' => 'flac', + 'video/x-flv' => 'flv', + 'image/gif' => 'gif', + 'application/gpg-keys' => 'gpg', + 'application/x-gtar' => 'gtar', + 'application/x-gzip' => 'gzip', + 'application/mac-binhex40' => 'hqx', + 'application/mac-binhex' => 'hqx', + 'application/x-binhex40' => 'hqx', + 'application/x-mac-binhex40' => 'hqx', + 'text/html' => 'html', + 'image/x-icon' => 'ico', + 'image/x-ico' => 'ico', + 'image/vnd.microsoft.icon' => 'ico', + 'text/calendar' => 'ics', + 'application/java-archive' => 'jar', + 'application/x-java-application' => 'jar', + 'application/x-jar' => 'jar', + 'image/jp2' => 'jp2', + 'video/mj2' => 'jp2', + 'image/jpx' => 'jp2', + 'image/jpm' => 'jp2', + 'image/jpeg' => 'jpg', + 'image/pjpeg' => 'jpg', + 'application/x-javascript' => 'js', + 'application/json' => 'json', + 'text/json' => 'json', + 'application/vnd.google-earth.kml+xml' => 'kml', + 'application/vnd.google-earth.kmz' => 'kmz', + 'text/x-log' => 'log', + 'audio/x-m4a' => 'm4a', + 'audio/mp4' => 'm4a', + 'application/vnd.mpegurl' => 'm4u', + 'audio/midi' => 'mid', + 'application/vnd.mif' => 'mif', + 'video/quicktime' => 'mov', + 'video/x-sgi-movie' => 'movie', + 'audio/mpeg' => 'mp3', + 'audio/mpg' => 'mp3', + 'audio/mpeg3' => 'mp3', + 'audio/mp3' => 'mp3', + 'video/mp4' => 'mp4', + 'video/mpeg' => 'mpeg', + 'application/oda' => 'oda', + 'audio/ogg' => 'ogg', + 'video/ogg' => 'ogg', + 'application/ogg' => 'ogg', + 'font/otf' => 'otf', + 'application/x-pkcs10' => 'p10', + 'application/pkcs10' => 'p10', + 'application/x-pkcs12' => 'p12', + 'application/x-pkcs7-signature' => 'p7a', + 'application/pkcs7-mime' => 'p7c', + 'application/x-pkcs7-mime' => 'p7c', + 'application/x-pkcs7-certreqresp' => 'p7r', + 'application/pkcs7-signature' => 'p7s', + 'application/pdf' => 'pdf', + 'application/octet-stream' => 'pdf', + 'application/x-x509-user-cert' => 'pem', + 'application/x-pem-file' => 'pem', + 'application/pgp' => 'pgp', + 'application/x-httpd-php' => 'php', + 'application/php' => 'php', + 'application/x-php' => 'php', + 'text/php' => 'php', + 'text/x-php' => 'php', + 'application/x-httpd-php-source' => 'php', + 'image/png' => 'png', + 'image/x-png' => 'png', + 'application/powerpoint' => 'ppt', + 'application/vnd.ms-powerpoint' => 'ppt', + 'application/vnd.ms-office' => 'ppt', + 'application/msword' => 'ppt', + 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'pptx', + 'application/x-photoshop' => 'psd', + 'image/vnd.adobe.photoshop' => 'psd', + 'audio/x-realaudio' => 'ra', + 'audio/x-pn-realaudio' => 'ram', + 'application/x-rar' => 'rar', + 'application/rar' => 'rar', + 'application/x-rar-compressed' => 'rar', + 'audio/x-pn-realaudio-plugin' => 'rpm', + 'application/x-pkcs7' => 'rsa', + 'text/rtf' => 'rtf', + 'text/richtext' => 'rtx', + 'video/vnd.rn-realvideo' => 'rv', + 'application/x-stuffit' => 'sit', + 'application/smil' => 'smil', + 'text/srt' => 'srt', + 'image/svg+xml' => 'svg', + 'application/x-shockwave-flash' => 'swf', + 'application/x-tar' => 'tar', + 'application/x-gzip-compressed' => 'tgz', + 'image/tiff' => 'tiff', + 'font/ttf' => 'ttf', + 'text/plain' => 'txt', + 'text/x-vcard' => 'vcf', + 'application/videolan' => 'vlc', + 'text/vtt' => 'vtt', + 'audio/x-wav' => 'wav', + 'audio/wave' => 'wav', + 'audio/wav' => 'wav', + 'application/wbxml' => 'wbxml', + 'video/webm' => 'webm', + 'image/webp' => 'webp', + 'audio/x-ms-wma' => 'wma', + 'application/wmlc' => 'wmlc', + 'video/x-ms-wmv' => 'wmv', + 'video/x-ms-asf' => 'wmv', + 'font/woff' => 'woff', + 'font/woff2' => 'woff2', + 'application/xhtml+xml' => 'xhtml', + 'application/excel' => 'xl', + 'application/msexcel' => 'xls', + 'application/x-msexcel' => 'xls', + 'application/x-ms-excel' => 'xls', + 'application/x-excel' => 'xls', + 'application/x-dos_ms_excel' => 'xls', + 'application/xls' => 'xls', + 'application/x-xls' => 'xls', + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'xlsx', + 'application/vnd.ms-excel' => 'xlsx', + 'application/xml' => 'xml', + 'text/xml' => 'xml', + 'text/xsl' => 'xsl', + 'application/xspf+xml' => 'xspf', + 'application/x-compress' => 'z', + 'application/x-zip' => 'zip', + 'application/zip' => 'zip', + 'application/x-zip-compressed' => 'zip', + 'application/s-compressed' => 'zip', + 'multipart/x-zip' => 'zip', + 'text/x-scriptzsh' => 'zsh' + ]; + public function __construct($dir) { - $this->dir = CACHE_DIR . "/" . clean_filename($dir); + $this->dir = CACHE_DIR . "/" . basename(clean($dir)); } public function getDir() { @@ -39,9 +227,7 @@ class DiskCache { } public function getFullPath($filename) { - $filename = clean_filename($filename); - - return $this->dir . "/" . $filename; + return $this->dir . "/" . basename(clean($filename)); } public function put($filename, $data) { @@ -66,19 +252,34 @@ class DiskCache { return null; } + public function getFakeExtension($filename) { + $mimetype = $this->getMimeType($filename); + + if ($mimetype) + return isset($this->mimeMap[$mimetype]) ? $this->mimeMap[$mimetype] : ""; + else + return ""; + } + public function send($filename) { - header("Content-Disposition: inline; filename=\"$filename\""); + $fake_extension = $this->getFakeExtension($filename); + + if ($fake_extension) + $fake_extension = ".$fake_extension"; + + header("Content-Disposition: inline; filename=\"${filename}${fake_extension}\""); - return send_local_file($this->getFullPath($filename)); + return $this->send_local_file($this->getFullPath($filename)); } public function getUrl($filename) { - return get_self_url_prefix() . "/public.php?op=cached_url&file=" . basename($this->dir) . "/" . $filename; + return get_self_url_prefix() . "/public.php?op=cached_url&file=" . basename($this->dir) . "/" . basename($filename); } // check for locally cached (media) URLs and rewrite to local versions // this is called separately after sanitize() and plugin render article hooks to allow // plugins work on original source URLs used before caching + // NOTE: URLs should be already absolutized because this is called after sanitize() static public function rewriteUrls($str) { $res = trim($str); @@ -89,31 +290,41 @@ class DiskCache { $xpath = new DOMXPath($doc); $cache = new DiskCache("images"); - $entries = $xpath->query('(//img[@src]|//picture/source[@src]|//video[@poster]|//video/source[@src]|//audio/source[@src])'); + $entries = $xpath->query('(//img[@src]|//source[@src|@srcset]|//video[@poster|@src])'); $need_saving = false; foreach ($entries as $entry) { + foreach (array('src', 'poster') as $attr) { + if ($entry->hasAttribute($attr)) { + $url = $entry->getAttribute($attr); + $cached_filename = sha1($url); - if ($entry->hasAttribute('src') || $entry->hasAttribute('poster')) { + if ($cache->exists($cached_filename)) { + $url = $cache->getUrl($cached_filename); - // should be already absolutized because this is called after sanitize() - $src = $entry->hasAttribute('poster') ? $entry->getAttribute('poster') : $entry->getAttribute('src'); - $cached_filename = sha1($src); + $entry->setAttribute($attr, $url); + $entry->removeAttribute("srcset"); - if ($cache->exists($cached_filename)) { + $need_saving = true; + } + } + } - $src = $cache->getUrl(sha1($src)); + if ($entry->hasAttribute("srcset")) { + $matches = RSSUtils::decode_srcset($entry->getAttribute('srcset')); - if ($entry->hasAttribute('poster')) - $entry->setAttribute('poster', $src); - else { - $entry->setAttribute('src', $src); - $entry->removeAttribute("srcset"); - } + for ($i = 0; $i < count($matches); $i++) { + $cached_filename = sha1($matches[$i]["url"]); + + if ($cache->exists($cached_filename)) { + $matches[$i]["url"] = $cache->getUrl($cached_filename); - $need_saving = true; + $need_saving = true; + } } + + $entry->setAttribute("srcset", RSSUtils::encode_srcset($matches)); } } @@ -148,4 +359,56 @@ class DiskCache { } } } + + /* this is essentially a wrapper for readfile() which allows plugins to hook + output with httpd-specific "fast" implementation i.e. X-Sendfile or whatever else + + hook function should return true if request was handled (or at least attempted to) + + note that this can be called without user context so the plugin to handle this + should be loaded systemwide in config.php */ + function send_local_file($filename) { + if (file_exists($filename)) { + + if (is_writable($filename)) touch($filename); + + $mimetype = mime_content_type($filename); + + // this is hardly ideal but 1) only media is cached in images/ and 2) seemingly only mp4 + // video files are detected as octet-stream by mime_content_type() + + if ($mimetype == "application/octet-stream") + $mimetype = "video/mp4"; + + # block SVG because of possible embedded javascript (.....) + $mimetype_blacklist = [ "image/svg+xml" ]; + + /* only serve video and images */ + if (!preg_match("/(image|video)\//", $mimetype) || in_array($mimetype, $mimetype_blacklist)) { + http_response_code(400); + header("Content-type: text/plain"); + + print "Stored file has disallowed content type ($mimetype)"; + return false; + } + + $tmppluginhost = new PluginHost(); + + $tmppluginhost->load(PLUGINS, PluginHost::KIND_SYSTEM); + $tmppluginhost->load_data(); + + foreach ($tmppluginhost->get_hooks(PluginHost::HOOK_SEND_LOCAL_FILE) as $plugin) { + if ($plugin->hook_send_local_file($filename)) return true; + } + + header("Content-type: $mimetype"); + + $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)) . " GMT"; + header("Last-Modified: $stamp", true); + + return readfile($filename); + } else { + return false; + } + } } diff --git a/classes/feeds.php b/classes/feeds.php index 77add790e..2d41be2e1 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -8,7 +8,7 @@ class Feeds extends Handler_Protected { private $params; function csrf_ignore($method) { - $csrf_ignored = array("index", "quickaddfeed", "search"); + $csrf_ignored = array("index"); return array_search($method, $csrf_ignored) !== false; } @@ -204,14 +204,14 @@ class Feeds extends Handler_Protected { } $vfeed_group_enabled = get_pref("VFEED_GROUP_BY_FEED") && - !(in_array($feed, Feeds::NEVER_GROUP_FEEDS) && !$cat_view); + !(in_array($feed, self::NEVER_GROUP_FEEDS) && !$cat_view); $result = $qfh_ret[0]; // this could be either a PDO query result or a -1 if first id changed $feed_title = $qfh_ret[1]; $feed_site_url = $qfh_ret[2]; $last_error = $qfh_ret[3]; - $last_updated = strpos($qfh_ret[4], '1970-') === FALSE ? - make_local_datetime($qfh_ret[4], false) : __("Never"); + $last_updated = strpos($qfh_ret[4], '1970-') === false ? + TimeHelper::make_local_datetime($qfh_ret[4], false) : __("Never"); $highlight_words = $qfh_ret[5]; $reply['first_id'] = $qfh_ret[6]; $reply['is_vfeed'] = $qfh_ret[7]; @@ -305,7 +305,7 @@ class Feeds extends Handler_Protected { $line["buttons"] .= $p->hook_article_button($line); } - $line["content"] = sanitize($line["content"], + $line["content"] = Sanitizer::sanitize($line["content"], $line['hide_images'], false, $line["site_url"], $highlight_words, $line["id"]); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_CDM) as $p) { @@ -343,12 +343,12 @@ class Feeds extends Handler_Protected { } } - $line["updated_long"] = make_local_datetime($line["updated"],true); - $line["updated"] = make_local_datetime($line["updated"], false, false, false, true); + $line["updated_long"] = TimeHelper::make_local_datetime($line["updated"],true); + $line["updated"] = TimeHelper::make_local_datetime($line["updated"], false, false, false, true); $line['imported'] = T_sprintf("Imported at %s", - make_local_datetime($line["date_entered"], false)); + TimeHelper::make_local_datetime($line["date_entered"], false)); if ($line["tag_cache"]) $tags = explode(",", $line["tag_cache"]); @@ -357,7 +357,7 @@ class Feeds extends Handler_Protected { $line["tags_str"] = Article::format_tags_string($tags, $id); - if (feeds::feedHasIcon($feed_id)) { + if (self::feedHasIcon($feed_id)) { $line['feed_icon'] = "<img class=\"icon\" src=\"".ICONS_URL."/$feed_id.ico\" alt=\"\">"; } else { $line['feed_icon'] = "<i class='icon-no-feed material-icons'>rss_feed</i>"; @@ -426,7 +426,7 @@ class Feeds extends Handler_Protected { $sth->execute([$_SESSION['uid']]); $row = $sth->fetch(); - $last_updated = make_local_datetime($row["last_updated"], false); + $last_updated = TimeHelper::make_local_datetime($row["last_updated"], false); $reply['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); @@ -529,21 +529,7 @@ class Feeds extends Handler_Protected { $reply['headlines'] = []; - $override_order = false; - $skip_first_id_check = false; - - switch ($order_by) { - case "title": - $override_order = "ttrss_entries.title, date_entered, updated"; - break; - case "date_reverse": - $override_order = "score DESC, date_entered, updated"; - $skip_first_id_check = true; - break; - case "feed_dates": - $override_order = "updated DESC"; - break; - } + list($override_order, $skip_first_id_check) = self::order_to_override_query($order_by); $ret = $this->format_headlines_list($feed, $method, $view_mode, $limit, $cat_view, $offset, @@ -564,7 +550,7 @@ class Feeds extends Handler_Protected { "disable_cache" => (bool) $disable_cache]; // this is parsed by handleRpcJson() on first viewfeed() to set cdm expanded, etc - $reply['runtime-info'] = make_runtime_info(); + $reply['runtime-info'] = RPC::make_runtime_info(); $reply_json = json_encode($reply); @@ -594,7 +580,7 @@ class Feeds extends Handler_Protected { $sth->execute([$_SESSION['uid']]); $row = $sth->fetch(); - $last_updated = make_local_datetime($row["last_updated"], false); + $last_updated = TimeHelper::make_local_datetime($row["last_updated"], false); $reply['headlines']['content'] .= sprintf(__("Feeds last updated at %s"), $last_updated); @@ -701,12 +687,12 @@ class Feeds extends Handler_Protected { print "<section>"; print "<label> <label class='checkbox'><input type='checkbox' name='need_auth' dojoType='dijit.form.CheckBox' id='feedDlg_loginCheck' - onclick='displayIfChecked(this, \"feedDlg_loginContainer\")'> + onclick='App.displayIfChecked(this, \"feedDlg_loginContainer\")'> ".__('This feed requires authentication.')."</label>"; print "</section>"; print "<footer>"; - print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' + print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"return dijit.byId('feedAddDlg').execute()\">".__('Subscribe')."</button>"; print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('feedAddDlg').hide()\">".__('Cancel')."</button>"; @@ -765,7 +751,7 @@ class Feeds extends Handler_Protected { $feed_id = (int)$_REQUEST["feed_id"]; @$do_update = $_REQUEST["action"] == "do_update"; - $csrf_token = $_REQUEST["csrf_token"]; + $csrf_token = $_POST["csrf_token"]; $sth = $this->pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ? AND owner_uid = ?"); $sth->execute([$feed_id, $_SESSION['uid']]); @@ -813,7 +799,7 @@ class Feeds extends Handler_Protected { <div class="container"> <h1>Feed Debugger: <?php echo "$feed_id: " . $this->getFeedTitle($feed_id) ?></h1> <div class="content"> - <form method="GET" action=""> + <form method="post" action=""> <input type="hidden" name="op" value="feeds"> <input type="hidden" name="method" value="update_debugger"> <input type="hidden" name="xdebug" value="1"> @@ -865,7 +851,7 @@ class Feeds extends Handler_Protected { // fall back in case of no plugins if (!$search_qpart) { - list($search_qpart, $search_words) = Feeds::search_to_sql($search[0], $search[1]); + list($search_qpart, $search_words) = self::search_to_sql($search[0], $search[1], $owner_uid); } } else { $search_qpart = "true"; @@ -905,7 +891,7 @@ class Feeds extends Handler_Protected { if ($feed >= 0) { if ($feed > 0) { - $children = Feeds::getChildCategories($feed, $owner_uid); + $children = self::getChildCategories($feed, $owner_uid); array_push($children, $feed); $children = array_map("intval", $children); @@ -1035,7 +1021,7 @@ class Feeds extends Handler_Protected { $match_part = ""; if ($is_cat) { - return Feeds::getCategoryUnread($n_feed, $owner_uid); + return self::getCategoryUnread($n_feed, $owner_uid); } else if ($n_feed == -6) { return 0; } else if ($feed != "0" && $n_feed == 0) { @@ -1081,7 +1067,7 @@ class Feeds extends Handler_Protected { $label_id = Labels::feed_to_label_id($feed); - return Feeds::getLabelUnread($label_id, $owner_uid); + return self::getLabelUnread($label_id, $owner_uid); } if ($match_part) { @@ -1138,11 +1124,11 @@ class Feeds extends Handler_Protected { $pdo = Db::pdo(); - $url = Feeds::fix_url($url); + $url = UrlHelper::validate($url); - if (!$url || !Feeds::validate_feed_url($url)) return array("code" => 2); + if (!$url) return array("code" => 2); - $contents = @fetch_file_contents($url, false, $auth_login, $auth_pass); + $contents = @UrlHelper::fetch($url, false, $auth_login, $auth_pass); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SUBSCRIBE_FEED) as $plugin) { $contents = $plugin->hook_subscribe_feed($contents, $url, $auth_login, $auth_pass); @@ -1156,8 +1142,8 @@ class Feeds extends Handler_Protected { return array("code" => 5, "message" => $fetch_last_error); } - if (mb_strpos($fetch_last_content_type, "html") !== FALSE && Feeds::is_html($contents)) { - $feedUrls = Feeds::get_feeds_from_html($url, $contents); + if (mb_strpos($fetch_last_content_type, "html") !== false && self::is_html($contents)) { + $feedUrls = self::get_feeds_from_html($url, $contents); if (count($feedUrls) == 0) { return array("code" => 3); @@ -1248,7 +1234,7 @@ class Feeds extends Handler_Protected { $pdo = Db::pdo(); if ($cat) { - return Feeds::getCategoryTitle($id); + return self::getCategoryTitle($id); } else if ($id == -1) { return __("Starred articles"); } else if ($id == -2) { @@ -1337,7 +1323,7 @@ class Feeds extends Handler_Protected { return 0; } else if ($cat == -2) { - $sth = $pdo->prepare("SELECT COUNT(DISTINCT article_id) AS unread + $sth = $pdo->prepare("SELECT COUNT(DISTINCT article_id) AS unread FROM ttrss_user_entries ue, ttrss_user_labels2 l WHERE article_id = ref_id AND unread IS true AND ue.owner_uid = :uid"); $sth->execute(["uid" => $owner_uid]); @@ -1360,8 +1346,8 @@ class Feeds extends Handler_Protected { $unread = 0; while ($line = $sth->fetch()) { - $unread += Feeds::getCategoryUnread($line["id"], $owner_uid); - $unread += Feeds::getCategoryChildrenUnread($line["id"], $owner_uid); + $unread += self::getCategoryUnread($line["id"], $owner_uid); + $unread += self::getCategoryChildrenUnread($line["id"], $owner_uid); } return $unread; @@ -1373,8 +1359,8 @@ class Feeds extends Handler_Protected { $pdo = Db::pdo(); - $sth = $pdo->prepare("SELECT SUM(CASE WHEN unread THEN 1 ELSE 0 END) AS count - FROM ttrss_user_entries ue + $sth = $pdo->prepare("SELECT SUM(CASE WHEN unread THEN 1 ELSE 0 END) AS count + FROM ttrss_user_entries ue WHERE ue.owner_uid = ?"); $sth->execute([$user_id]); @@ -1464,11 +1450,11 @@ class Feeds extends Handler_Protected { // fall back in case of no plugins if (!$search_query_part) { - list($search_query_part, $search_words) = Feeds::search_to_sql($search, $search_language); + list($search_query_part, $search_words) = self::search_to_sql($search, $search_language, $owner_uid); } if (DB_TYPE == "pgsql") { - $test_sth = $pdo->prepare("select $search_query_part + $test_sth = $pdo->prepare("select $search_query_part FROM ttrss_entries, ttrss_user_entries WHERE id = ref_id limit 1"); try { @@ -1502,7 +1488,7 @@ class Feeds extends Handler_Protected { $unread = getFeedUnread($feed, $cat_view); if ($cat_view && $feed > 0 && $include_children) - $unread += Feeds::getCategoryChildrenUnread($feed); + $unread += self::getCategoryChildrenUnread($feed); if ($unread > 0) { $view_query_part = " unread = true AND "; @@ -1546,7 +1532,7 @@ class Feeds extends Handler_Protected { if ($feed > 0) { if ($include_children) { # sub-cats - $subcats = Feeds::getChildCategories($feed, $owner_uid); + $subcats = self::getChildCategories($feed, $owner_uid); array_push($subcats, $feed); $subcats = array_map("intval", $subcats); @@ -1665,7 +1651,7 @@ class Feeds extends Handler_Protected { $feed_title = T_sprintf("Search results: %s", $search); } else { if ($cat_view) { - $feed_title = Feeds::getCategoryTitle($feed); + $feed_title = self::getCategoryTitle($feed); } else { if (is_numeric($feed) && $feed > 0) { $ssth = $pdo->prepare("SELECT title,site_url,last_error,last_updated @@ -1678,7 +1664,7 @@ class Feeds extends Handler_Protected { $last_error = $row["last_error"]; $last_updated = $row["last_updated"]; } else { - $feed_title = Feeds::getFeedTitle($feed); + $feed_title = self::getFeedTitle($feed); } } } @@ -1702,7 +1688,7 @@ class Feeds extends Handler_Protected { // proper override_order applied above if ($vfeed_query_part && !$ignore_vfeed_group && get_pref('VFEED_GROUP_BY_FEED', $owner_uid)) { - if (!(in_array($feed, Feeds::NEVER_GROUP_BY_DATE) && !$cat_view)) { + if (!(in_array($feed, self::NEVER_GROUP_BY_DATE) && !$cat_view)) { $yyiw_desc = $order_by == "date_reverse" ? "" : "desc"; $yyiw_order_qpart = "yyiw $yyiw_desc, "; } else { @@ -1883,7 +1869,7 @@ class Feeds extends Handler_Protected { while ($line = $sth->fetch()) { array_push($rv, $line["parent_cat"]); - $rv = array_merge($rv, Feeds::getParentCategories($line["parent_cat"], $owner_uid)); + $rv = array_merge($rv, self::getParentCategories($line["parent_cat"], $owner_uid)); } return $rv; @@ -1900,7 +1886,7 @@ class Feeds extends Handler_Protected { while ($line = $sth->fetch()) { array_push($rv, $line["id"]); - $rv = array_merge($rv, Feeds::getChildCategories($line["id"], $owner_uid)); + $rv = array_merge($rv, self::getChildCategories($line["id"], $owner_uid)); } return $rv; @@ -1938,7 +1924,7 @@ class Feeds extends Handler_Protected { } static function get_feeds_from_html($url, $content) { - $url = Feeds::fix_url($url); + $url = UrlHelper::validate($url); $baseUrl = substr($url, 0, strrpos($url, '/') + 1); $feedUrls = []; @@ -1969,56 +1955,6 @@ class Feeds extends Handler_Protected { return preg_match("/<html|DOCTYPE html/i", substr($content, 0, 8192)) !== 0; } - static function validate_feed_url($url) { - $parts = parse_url($url); - - return ($parts['scheme'] == 'http' || $parts['scheme'] == 'feed' || $parts['scheme'] == 'https'); - } - - /** - * Fixes incomplete URLs by prepending "http://". - * Also replaces feed:// with http://, and - * prepends a trailing slash if the url is a domain name only. - * - * @param string $url Possibly incomplete URL - * - * @return string Fixed URL. - */ - static function fix_url($url) { - - // support schema-less urls - if (strpos($url, '//') === 0) { - $url = 'https:' . $url; - } - - if (strpos($url, '://') === false) { - $url = 'http://' . $url; - } else if (substr($url, 0, 5) == 'feed:') { - $url = 'http:' . substr($url, 5); - } - - //prepend slash if the URL has no slash in it - // "http://www.example" -> "http://www.example/" - if (strpos($url, '/', strpos($url, ':') + 3) === false) { - $url .= '/'; - } - - //convert IDNA hostname to punycode if possible - if (function_exists("idn_to_ascii")) { - $parts = parse_url($url); - if (mb_detect_encoding($parts['host']) != 'ASCII') - { - $parts['host'] = idn_to_ascii($parts['host']); - $url = build_url($parts); - } - } - - if ($url != "http:///") - return $url; - else - return ''; - } - static function add_feed_category($feed_cat, $parent_cat_id = false, $order_id = 0) { if (!$feed_cat) return false; @@ -2096,7 +2032,7 @@ class Feeds extends Handler_Protected { */ static function purge_feed($feed_id, $purge_interval) { - if (!$purge_interval) $purge_interval = Feeds::feed_purge_interval($feed_id); + if (!$purge_interval) $purge_interval = self::feed_purge_interval($feed_id); $pdo = Db::pdo(); @@ -2161,7 +2097,7 @@ class Feeds extends Handler_Protected { static function feed_purge_interval($feed_id) { - $pdo = DB::pdo(); + $pdo = Db::pdo(); $sth = $pdo->prepare("SELECT purge_interval, owner_uid FROM ttrss_feeds WHERE id = ?"); @@ -2181,7 +2117,7 @@ class Feeds extends Handler_Protected { } } - static function search_to_sql($search, $search_language) { + static function search_to_sql($search, $search_language, $owner_uid) { $keywords = str_getcsv(trim($search), " "); $query_keywords = array(); @@ -2193,7 +2129,7 @@ class Feeds extends Handler_Protected { if ($search_language) $search_language = $pdo->quote(mb_strtolower($search_language)); else - $search_language = $pdo->quote("english"); + $search_language = $pdo->quote(mb_strtolower(get_pref('DEFAULT_SEARCH_LANGUAGE', $owner_uid))); foreach ($keywords as $k) { if (strpos($k, "-") === 0) { @@ -2267,6 +2203,24 @@ class Feeds extends Handler_Protected { if (!$not) array_push($search_words, $k); } break; + case "label": + if ($commandpair[1]) { + $label_id = Labels::find_id($commandpair[1], $_SESSION["uid"]); + + if ($label_id) { + array_push($query_keywords, "($not + (ttrss_entries.id IN ( + SELECT article_id FROM ttrss_user_labels2 WHERE + label_id = ".$pdo->quote($label_id).")))"); + } else { + array_push($query_keywords, "(false)"); + } + } else { + array_push($query_keywords, "(UPPER(ttrss_entries.title) $not LIKE UPPER(".$pdo->quote("%$k%").") + OR UPPER(ttrss_entries.content) $not LIKE UPPER(".$pdo->quote("%$k%")."))"); + if (!$not) array_push($search_words, $k); + } + break; case "unread": if ($commandpair[1]) { if ($commandpair[1] == "true") @@ -2285,7 +2239,7 @@ class Feeds extends Handler_Protected { $user_tz_string = get_pref('USER_TIMEZONE', $_SESSION['uid']); $orig_ts = strtotime(substr($k, 1)); - $k = date("Y-m-d", convert_timestamp($orig_ts, $user_tz_string, 'UTC')); + $k = date("Y-m-d", TimeHelper::convert_timestamp($orig_ts, $user_tz_string, 'UTC')); //$k = date("Y-m-d", strtotime(substr($k, 1))); @@ -2323,9 +2277,38 @@ class Feeds extends Handler_Protected { } - $search_query_part = implode("AND", $query_keywords); + if (count($query_keywords) > 0) + $search_query_part = implode("AND", $query_keywords); + else + $search_query_part = "false"; return array($search_query_part, $search_words); } + + static function order_to_override_query($order) { + $query = ""; + $skip_first_id = false; + + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE) as $p) { + list ($query, $skip_first_id) = $p->hook_headlines_custom_sort_override($order); + + if ($query) return [$query, $skip_first_id]; + } + + switch ($order) { + case "title": + $query = "ttrss_entries.title, date_entered, updated"; + break; + case "date_reverse": + $query = "updated"; + $skip_first_id = true; + break; + case "feed_dates": + $query = "updated DESC"; + break; + } + + return [$query, $skip_first_id]; + } } diff --git a/classes/handler.php b/classes/handler.php index 5b1109492..09557c284 100644 --- a/classes/handler.php +++ b/classes/handler.php @@ -9,7 +9,7 @@ class Handler implements IHandler { } function csrf_ignore($method) { - return true; + return false; } function before($method) { @@ -20,4 +20,4 @@ class Handler implements IHandler { return true; } -}
\ No newline at end of file +} diff --git a/classes/handler/public.php b/classes/handler/public.php index 8c2700012..4bd9c06f9 100755 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -5,8 +5,6 @@ class Handler_Public extends Handler { $limit, $offset, $search, $view_mode = false, $format = 'atom', $order = false, $orig_guid = false, $start_ts = false) { - require_once "lib/MiniTemplator.class.php"; - $note_style = "background-color : #fff7d5; border-width : 1px; ". "padding : 5px; border-style : dashed; border-color : #e7d796;". @@ -14,24 +12,16 @@ class Handler_Public extends Handler { if (!$limit) $limit = 60; - $date_sort_field = "date_entered DESC, updated DESC"; + list($override_order, $skip_first_id_check) = Feeds::order_to_override_query($order); - if ($feed == -2 && !$is_cat) { - $date_sort_field = "last_published DESC"; - } else if ($feed == -1 && !$is_cat) { - $date_sort_field = "last_marked DESC"; - } + if (!$override_order) { + $override_order = "date_entered DESC, updated DESC"; - switch ($order) { - case "title": - $date_sort_field = "ttrss_entries.title, date_entered, updated"; - break; - case "date_reverse": - $date_sort_field = "date_entered, updated"; - break; - case "feed_dates": - $date_sort_field = "updated DESC"; - break; + if ($feed == -2 && !$is_cat) { + $override_order = "last_published DESC"; + } else if ($feed == -1 && !$is_cat) { + $override_order = "last_marked DESC"; + } } $params = array( @@ -41,7 +31,7 @@ class Handler_Public extends Handler { "view_mode" => $view_mode, "cat_view" => $is_cat, "search" => $search, - "override_order" => $date_sort_field, + "override_order" => $override_order, "include_children" => true, "ignore_vfeed_group" => true, "offset" => $offset, @@ -80,9 +70,9 @@ class Handler_Public extends Handler { if (!$feed_site_url) $feed_site_url = get_self_url_prefix(); if ($format == 'atom') { - $tpl = new MiniTemplator; + $tpl = new Templator(); - $tpl->readTemplateFromFile("templates/generated_feed.txt"); + $tpl->readTemplateFromFile("generated_feed.txt"); $tpl->setVariable('FEED_TITLE', $feed_title, true); $tpl->setVariable('VERSION', get_version(), true); @@ -91,7 +81,7 @@ class Handler_Public extends Handler { $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true); while ($line = $result->fetch()) { - $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content"]), 100, '...')); + $line["content_preview"] = Sanitizer::sanitize(truncate_string(strip_tags($line["content"]), 100, '...')); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line); @@ -108,7 +98,7 @@ class Handler_Public extends Handler { $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true); $tpl->setVariable('ARTICLE_EXCERPT', $line["content_preview"], true); - $content = sanitize($line["content"], false, $owner_uid, + $content = Sanitizer::sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]); $content = DiskCache::rewriteUrls($content); @@ -190,7 +180,7 @@ class Handler_Public extends Handler { while ($line = $result->fetch()) { - $line["content_preview"] = sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...')); + $line["content_preview"] = Sanitizer::sanitize(truncate_string(strip_tags($line["content_preview"]), 100, '...')); foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) { $line = $p->hook_query_headlines($line, 100); @@ -206,7 +196,7 @@ class Handler_Public extends Handler { $article['link'] = $line['link']; $article['title'] = $line['title']; $article['excerpt'] = $line["content_preview"]; - $article['content'] = sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]); + $article['content'] = Sanitizer::sanitize($line["content"], false, $owner_uid, $feed_site_url, false, $line["id"]); $article['updated'] = date('c', strtotime($line["updated"])); if ($line['note']) $article['note'] = $line['note']; @@ -293,15 +283,20 @@ class Handler_Public extends Handler { } function logout() { - logout_user(); - header("Location: index.php"); + if (validate_csrf($_POST["csrf_token"])) { + Pref_Users::logout_user(); + header("Location: index.php"); + } else { + header("Content-Type: text/json"); + print error_json(6); + } } function share() { $uuid = clean($_REQUEST["key"]); if ($uuid) { - $sth = $this->pdo->prepare("SELECT ref_id, owner_uid + $sth = $this->pdo->prepare("SELECT ref_id, owner_uid FROM ttrss_user_entries WHERE uuid = ?"); $sth->execute([$uuid]); @@ -348,7 +343,7 @@ class Handler_Public extends Handler { $line["tags"] = Article::get_article_tags($id, $owner_uid, $line["tag_cache"]); unset($line["tag_cache"]); - $line["content"] = sanitize($line["content"], + $line["content"] = Sanitizer::sanitize($line["content"], $line['hide_images'], $owner_uid, $line["site_url"], false, $line["id"]); @@ -376,7 +371,7 @@ class Handler_Public extends Handler { } body.css_loading * { display : none; - } + } </style> <link rel='shortcut icon' type='image/png' href='images/favicon.png'> <link rel='icon' type='image/png' sizes='72x72' href='images/favicon-72px.png'>"; @@ -419,7 +414,7 @@ class Handler_Public extends Handler { $rv .= "<div class='row'>"; # row //$entry_author = $line["author"] ? " - " . $line["author"] : ""; - $parsed_updated = make_local_datetime($line["updated"], true, + $parsed_updated = TimeHelper::make_local_datetime($line["updated"], true, $owner_uid, true); $rv .= "<div>".$line['author']."</div>"; @@ -475,7 +470,7 @@ class Handler_Public extends Handler { if (!$format) $format = 'atom'; if (SINGLE_USER_MODE) { - authenticate_user("admin", null); + UserHelper::authenticate("admin", null); } $owner_id = false; @@ -513,7 +508,7 @@ class Handler_Public extends Handler { function sharepopup() { if (SINGLE_USER_MODE) { - login_sequence(); + UserHelper::login_sequence(); } header('Content-Type: text/html; charset=utf-8'); @@ -678,14 +673,15 @@ class Handler_Public extends Handler { $login = clean($_POST["login"]); $password = clean($_POST["password"]); $remember_me = clean($_POST["remember_me"]); + $safe_mode = checkbox_to_sql_bool(clean($_POST["safe_mode"])); if ($remember_me) { - session_set_cookie_params(SESSION_COOKIE_LIFETIME); + @session_set_cookie_params(SESSION_COOKIE_LIFETIME); } else { - session_set_cookie_params(0); + @session_set_cookie_params(0); } - if (authenticate_user($login, $password)) { + if (UserHelper::authenticate($login, $password)) { $_POST["password"] = ""; if (get_schema_version() >= 120) { @@ -694,6 +690,7 @@ class Handler_Public extends Handler { $_SESSION["ref_schema_version"] = get_schema_version(true); $_SESSION["bw_limit"] = !!clean($_POST["bw_limit"]); + $_SESSION["safe_mode"] = $safe_mode; if (clean($_POST["profile"])) { @@ -732,12 +729,13 @@ class Handler_Public extends Handler { function subscribe() { if (SINGLE_USER_MODE) { - login_sequence(); + UserHelper::login_sequence(); } if ($_SESSION["uid"]) { $feed_url = trim(clean($_REQUEST["feed_url"])); + $csrf_token = clean($_POST["csrf_token"]); header('Content-Type: text/html; charset=utf-8'); ?> @@ -784,13 +782,14 @@ class Handler_Public extends Handler { <div class='content'> <?php - if (!$feed_url) { + if (!$feed_url || !validate_csrf($csrf_token)) { ?> <form method="post"> <input type="hidden" name="op" value="subscribe"> + <?php print_hidden("csrf_token", $_SESSION["csrf_token"]) ?> <fieldset> <label>Feed or site URL:</label> - <input style="width: 300px" dojoType="dijit.form.ValidationTextBox" required="1" name="feed_url"> + <input style="width: 300px" dojoType="dijit.form.ValidationTextBox" required="1" name="feed_url" value="<?php echo htmlspecialchars($feed_url) ?>"> </fieldset> <button class="alt-primary" dojoType="dijit.form.Button" type="submit"> @@ -830,6 +829,7 @@ class Handler_Public extends Handler { print "<form action='public.php'>"; print "<input type='hidden' name='op' value='subscribe'>"; + print_hidden("csrf_token", $_SESSION["csrf_token"]); print "<fieldset>"; print "<label style='display : inline'>" . __("Multiple feed URLs found:") . "</label>"; @@ -878,7 +878,7 @@ class Handler_Public extends Handler { print "</div></div></body></html>"; } else { - render_login_form(); + $this->render_login_form(); } } @@ -942,7 +942,7 @@ class Handler_Public extends Handler { if ($timestamp && $resetpass_token && $timestamp >= time() - 15*60*60 && - $resetpass_token == $hash) { + $resetpass_token === $hash) { $sth = $this->pdo->prepare("UPDATE ttrss_users SET resetpass_token = NULL WHERE id = ?"); @@ -1030,11 +1030,9 @@ class Handler_Public extends Handler { $resetpass_link = get_self_url_prefix() . "/public.php?op=forgotpass&hash=" . $resetpass_token . "&login=" . urlencode($login); - require_once "lib/MiniTemplator.class.php"; - - $tpl = new MiniTemplator; + $tpl = new Templator(); - $tpl->readTemplateFromFile("templates/resetpass_link_template.txt"); + $tpl->readTemplateFromFile("resetpass_link_template.txt"); $tpl->setVariable('LOGIN', $login); $tpl->setVariable('RESETPASS_LINK', $resetpass_link); @@ -1094,7 +1092,7 @@ class Handler_Public extends Handler { if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) { $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script."); - render_login_form(); + $this->render_login_form(); exit; } @@ -1246,7 +1244,7 @@ class Handler_Public extends Handler { public function pluginhandler() { $host = new PluginHost(); - $plugin_name = clean_filename($_REQUEST["plugin"]); + $plugin_name = basename(clean($_REQUEST["plugin"])); $method = clean($_REQUEST["pmethod"]); $host->load($plugin_name, PluginHost::KIND_USER, 0); @@ -1274,5 +1272,13 @@ class Handler_Public extends Handler { print error_json(14); } } + + static function render_login_form() { + header('Cache-Control: public'); + + require_once "login_form.php"; + exit; + } + } ?> diff --git a/classes/labels.php b/classes/labels.php index 19d060617..1f27ee25c 100644 --- a/classes/labels.php +++ b/classes/labels.php @@ -12,7 +12,7 @@ class Labels static function find_id($label, $owner_uid) { $pdo = Db::pdo(); - $sth = $pdo->prepare("SELECT id FROM ttrss_labels2 WHERE caption = ? + $sth = $pdo->prepare("SELECT id FROM ttrss_labels2 WHERE LOWER(caption) = LOWER(?) AND owner_uid = ? LIMIT 1"); $sth->execute([$label, $owner_uid]); @@ -57,7 +57,7 @@ class Labels $pdo = Db::pdo(); if ($force) - Labels::clear_cache($id); + self::clear_cache($id); if (!$labels) $labels = Article::get_article_labels($id); @@ -82,7 +82,7 @@ class Labels static function remove_article($id, $label, $owner_uid) { - $label_id = Labels::find_id($label, $owner_uid); + $label_id = self::find_id($label, $owner_uid); if (!$label_id) return; @@ -95,12 +95,12 @@ class Labels $sth->execute([$label_id, $id]); - Labels::clear_cache($id); + self::clear_cache($id); } static function add_article($id, $label, $owner_uid) { - $label_id = Labels::find_id($label, $owner_uid); + $label_id = self::find_id($label, $owner_uid); if (!$label_id) return; @@ -123,7 +123,7 @@ class Labels $sth->execute([$label_id, $id]); } - Labels::clear_cache($id); + self::clear_cache($id); } @@ -186,7 +186,7 @@ class Labels } $sth = $pdo->prepare("SELECT id FROM ttrss_labels2 - WHERE caption = ? AND owner_uid = ?"); + WHERE LOWER(caption) = LOWER(?) AND owner_uid = ?"); $sth->execute([$caption, $owner_uid]); if (!$sth->fetch()) { @@ -202,4 +202,4 @@ class Labels return $result; } -}
\ No newline at end of file +} diff --git a/classes/logger.php b/classes/logger.php index 732f1fd5d..cdc6b240a 100755 --- a/classes/logger.php +++ b/classes/logger.php @@ -30,9 +30,9 @@ class Logger { return false; } - function log($string, $context = "") { + function log($errno, $errstr, $context = "") { if ($this->adapter) - return $this->adapter->log_error(E_USER_NOTICE, $string, '', 0, $context); + return $this->adapter->log_error($errno, $errstr, '', 0, $context); else return false; } diff --git a/classes/mailer.php b/classes/mailer.php index 2919eec79..16be16523 100644 --- a/classes/mailer.php +++ b/classes/mailer.php @@ -20,7 +20,7 @@ class Mailer { $to_combined = $to_name ? "$to_name <$to_address>" : $to_address; if (defined('_LOG_SENT_MAIL') && _LOG_SENT_MAIL) - Logger::get()->log("Sending mail from $from_combined to $to_combined [$subject]: $message"); + Logger::get()->log(E_USER_NOTICE, "Sending mail from $from_combined to $to_combined [$subject]: $message"); // HOOK_SEND_MAIL plugin instructions: // 1. return 1 or true if mail is handled diff --git a/classes/opml.php b/classes/opml.php index 48db9a8a3..37e653a39 100644 --- a/classes/opml.php +++ b/classes/opml.php @@ -8,7 +8,7 @@ class Opml extends Handler_Protected { } function export() { - $output_name = "tt-rss_".date("Y-m-d").".opml"; + $output_name = sprintf("tt-rss_%s_%s.opml", $_SESSION["name"], date("Y-m-d")); $include_settings = $_REQUEST["include_settings"] == "1"; $owner_uid = $_SESSION["uid"]; @@ -62,7 +62,7 @@ class Opml extends Handler_Protected { $ttrss_specific_qpart = ""; if ($cat_id) { - $sth = $this->pdo->prepare("SELECT title,order_id + $sth = $this->pdo->prepare("SELECT title,order_id FROM ttrss_feed_categories WHERE id = ? AND owner_uid = ?"); $sth->execute([$cat_id, $owner_uid]); @@ -90,7 +90,7 @@ class Opml extends Handler_Protected { $out .= $this->opml_export_category($owner_uid, $line["id"], $hide_private_feeds, $include_settings); } - $fsth = $this->pdo->prepare("select title, feed_url, site_url, update_interval, order_id + $fsth = $this->pdo->prepare("select title, feed_url, site_url, update_interval, order_id, purge_interval FROM ttrss_feeds WHERE (cat_id = :cat OR (:cat = 0 AND cat_id IS NULL)) AND owner_uid = :uid AND $hide_qpart ORDER BY order_id, title"); @@ -105,8 +105,9 @@ class Opml extends Handler_Protected { if ($include_settings) { $update_interval = (int)$fline["update_interval"]; $order_id = (int)$fline["order_id"]; + $purge_interval = (int)$fline["purge_interval"]; - $ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\" ttrssUpdateInterval=\"$update_interval\""; + $ttrss_specific_qpart = "ttrssSortOrder=\"$order_id\" ttrssPurgeInterval=\"$purge_interval\" ttrssUpdateInterval=\"$update_interval\""; } else { $ttrss_specific_qpart = ""; } @@ -125,15 +126,16 @@ class Opml extends Handler_Protected { return $out; } - function opml_export($name, $owner_uid, $hide_private_feeds = false, $include_settings = true) { + function opml_export($filename, $owner_uid, $hide_private_feeds = false, $include_settings = true, $file_output = false) { if (!$owner_uid) return; - if (!isset($_REQUEST["debug"])) { - header("Content-type: application/xml+opml"); - header("Content-Disposition: attachment; filename=" . $name ); - } else { - header("Content-type: text/xml"); - } + if (!$file_output) + if (!isset($_REQUEST["debug"])) { + header("Content-type: application/xml+opml"); + header("Content-Disposition: attachment; filename=$filename"); + } else { + header("Content-type: text/xml"); + } $out = "<?xml version=\"1.0\" encoding=\"utf-8\"?".">"; @@ -288,7 +290,10 @@ class Opml extends Handler_Protected { 'return str_repeat("\t", intval(strlen($matches[0])/2));'), $res); */ - print $res; + if ($file_output) + return file_put_contents($filename, $res) > 0; + else + print $res; } // Import @@ -323,11 +328,14 @@ class Opml extends Handler_Protected { $order_id = (int) $attrs->getNamedItem('ttrssSortOrder')->nodeValue; if (!$order_id) $order_id = 0; + $purge_interval = (int) $attrs->getNamedItem('ttrssPurgeInterval')->nodeValue; + if (!$purge_interval) $purge_interval = 0; + $sth = $this->pdo->prepare("INSERT INTO ttrss_feeds - (title, feed_url, owner_uid, cat_id, site_url, order_id, update_interval) VALUES - (?, ?, ?, ?, ?, ?, ?)"); + (title, feed_url, owner_uid, cat_id, site_url, order_id, update_interval, purge_interval) VALUES + (?, ?, ?, ?, ?, ?, ?, ?)"); - $sth->execute([$feed_title, $feed_url, $owner_uid, $cat_id, $site_url, $order_id, $update_interval]); + $sth->execute([$feed_title, $feed_url, $owner_uid, $cat_id, $site_url, $order_id, $update_interval, $purge_interval]); } else { $this->opml_notice(T_sprintf("Duplicate feed: %s", $feed_title == '[Unknown]' ? $feed_url : $feed_title)); @@ -602,7 +610,7 @@ class Opml extends Handler_Protected { if (is_file($tmp_file)) { $doc = new DOMDocument(); libxml_disable_entity_loader(false); - $doc->load($tmp_file); + $loaded = $doc->load($tmp_file); libxml_disable_entity_loader(true); unlink($tmp_file); } else if (!$doc) { @@ -610,7 +618,7 @@ class Opml extends Handler_Protected { return; } - if ($doc) { + if ($loaded) { $this->pdo->beginTransaction(); $this->opml_import_category($doc, false, $owner_uid, false); $this->pdo->commit(); diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 6158880f2..3ff658918 100755 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -1,6 +1,9 @@ <?php class PluginHost { private $pdo; + /* separate handle for plugin data so transaction while saving wouldn't clash with possible main + tt-rss code transactions; only initialized when first needed */ + private $pdo_data; private $hooks = array(); private $plugins = array(); private $handlers = array(); @@ -62,6 +65,9 @@ class PluginHost { const HOOK_ARTICLE_IMAGE = 42; const HOOK_FEED_TREE = 43; const HOOK_IFRAME_WHITELISTED = 44; + const HOOK_ENCLOSURE_IMPORTED = 45; + const HOOK_HEADLINES_CUSTOM_SORT_MAP = 46; + const HOOK_HEADLINES_CUSTOM_SORT_OVERRIDE = 47; const KIND_ALL = 1; const KIND_SYSTEM = 2; @@ -73,7 +79,6 @@ class PluginHost { function __construct() { $this->pdo = Db::pdo(); - $this->storage = array(); } @@ -150,7 +155,7 @@ class PluginHost { foreach (array_keys($this->hooks[$type]) as $prio) { $key = array_search($sender, $this->hooks[$type][$prio]); - if ($key !== FALSE) { + if ($key !== false) { unset($this->hooks[$type][$prio][$key]); } } @@ -188,7 +193,7 @@ class PluginHost { foreach ($plugins as $class) { $class = trim($class); - $class_file = strtolower(clean_filename($class)); + $class_file = strtolower(basename(clean($class))); if (!is_dir(__DIR__."/../plugins/$class_file") && !is_dir(__DIR__."/../plugins.local/$class_file")) continue; @@ -213,7 +218,7 @@ class PluginHost { if (file_exists($vendor_dir)) { spl_autoload_register(function($class) use ($vendor_dir) { - if (strpos($class, '\\') !== FALSE) { + if (strpos($class, '\\') !== false) { list ($namespace, $class_name) = explode('\\', $class, 2); if ($namespace && $class_name) { @@ -230,8 +235,8 @@ class PluginHost { $plugin_api = $plugin->api_version(); - if ($plugin_api < PluginHost::API_VERSION) { - user_error("Plugin $class is not compatible with current API version (need: " . PluginHost::API_VERSION . ", got: $plugin_api)", E_USER_WARNING); + if ($plugin_api < self::API_VERSION) { + user_error("Plugin $class is not compatible with current API version (need: " . self::API_VERSION . ", got: $plugin_api)", E_USER_WARNING); continue; } @@ -361,9 +366,13 @@ class PluginHost { private function save_data($plugin) { if ($this->owner_uid) { - $this->pdo->beginTransaction(); - $sth = $this->pdo->prepare("SELECT id FROM ttrss_plugin_storage WHERE + if (!$this->pdo_data) + $this->pdo_data = Db::instance()->pdo_connect(); + + $this->pdo_data->beginTransaction(); + + $sth = $this->pdo_data->prepare("SELECT id FROM ttrss_plugin_storage WHERE owner_uid= ? AND name = ?"); $sth->execute([$this->owner_uid, $plugin]); @@ -373,18 +382,18 @@ class PluginHost { $content = serialize($this->storage[$plugin]); if ($sth->fetch()) { - $sth = $this->pdo->prepare("UPDATE ttrss_plugin_storage SET content = ? + $sth = $this->pdo_data->prepare("UPDATE ttrss_plugin_storage SET content = ? WHERE owner_uid= ? AND name = ?"); $sth->execute([(string)$content, $this->owner_uid, $plugin]); } else { - $sth = $this->pdo->prepare("INSERT INTO ttrss_plugin_storage + $sth = $this->pdo_data->prepare("INSERT INTO ttrss_plugin_storage (name,owner_uid,content) VALUES (?, ?, ?)"); $sth->execute([$plugin, $this->owner_uid, (string)$content]); } - $this->pdo->commit(); + $this->pdo_data->commit(); } } diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index 6d7295beb..8b9099007 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -101,7 +101,7 @@ class Pref_Feeds extends Handler_Protected { $feed['unread'] = -1; $feed['error'] = $feed_line['last_error']; $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); - $feed['param'] = make_local_datetime( + $feed['param'] = TimeHelper::make_local_datetime( $feed_line['last_updated'], true); $feed['updates_disabled'] = (int)($feed_line['update_interval'] < 0); @@ -268,7 +268,7 @@ class Pref_Feeds extends Handler_Protected { $feed['checkbox'] = false; $feed['error'] = $feed_line['last_error']; $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); - $feed['param'] = make_local_datetime( + $feed['param'] = TimeHelper::make_local_datetime( $feed_line['last_updated'], true); $feed['unread'] = -1; $feed['type'] = 'feed'; @@ -303,7 +303,7 @@ class Pref_Feeds extends Handler_Protected { $feed['checkbox'] = false; $feed['error'] = $feed_line['last_error']; $feed['icon'] = Feeds::getFeedIcon($feed_line['id']); - $feed['param'] = make_local_datetime( + $feed['param'] = TimeHelper::make_local_datetime( $feed_line['last_updated'], true); $feed['unread'] = -1; $feed['type'] = 'feed'; @@ -449,7 +449,7 @@ class Pref_Feeds extends Handler_Protected { if ($row = $sth->fetch()) { @unlink(ICONS_DIR . "/$feed_id.ico"); - $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET favicon_avg_color = NULL + $sth = $this->pdo->prepare("UPDATE ttrss_feeds SET favicon_avg_color = NULL, favicon_last_checked = '1970-01-01' where id = ?"); $sth->execute([$feed_id]); } @@ -554,7 +554,7 @@ class Pref_Feeds extends Handler_Protected { $last_error = $row["last_error"]; if ($last_error) { - print " <i class=\"material-icons\" + print " <i class=\"material-icons\" title=\"".htmlspecialchars($last_error)."\">error</i>"; } @@ -676,7 +676,7 @@ class Pref_Feeds extends Handler_Protected { $auth_checked = $auth_enabled ? 'checked' : ''; print "<label class='checkbox'> <input type='checkbox' $auth_checked name='need_auth' dojoType='dijit.form.CheckBox' id='feedEditDlg_loginCheck' - onclick='displayIfChecked(this, \"feedEditDlg_loginContainer\")'> + onclick='App.displayIfChecked(this, \"feedEditDlg_loginContainer\")'> ".__('This feed requires authentication.')."</label>"; print '</div><div dojoType="dijit.layout.ContentPane" title="'.__('Options').'">'; @@ -772,6 +772,7 @@ class Pref_Feeds extends Handler_Protected { <input style='display: none' id='icon_file' size='10' name='icon_file' type='file'> </label> <input type='hidden' name='op' value='pref-feeds'> + <input type='hidden' name='csrf_token' value='".$_SESSION['csrf_token']."'> <input type='hidden' name='feed_id' value='$feed_id'> <input type='hidden' name='method' value='uploadicon'> <button dojoType='dijit.form.Button' onclick=\"return CommonDialogs.uploadFeedIcon();\" @@ -1150,7 +1151,7 @@ class Pref_Feeds extends Handler_Protected { $ids = explode(",", clean($_REQUEST["ids"])); foreach ($ids as $id) { - Pref_Feeds::remove_feed($id, $_SESSION["uid"]); + self::remove_feed($id, $_SESSION["uid"]); } return; @@ -1172,7 +1173,7 @@ class Pref_Feeds extends Handler_Protected { function index() { print "<div dojoType='dijit.layout.AccordionContainer' region='center'>"; - print "<div style='padding : 0px' dojoType='dijit.layout.AccordionPane' + print "<div style='padding : 0px' dojoType='dijit.layout.AccordionPane' title=\"<i class='material-icons'>rss_feed</i> ".__('Feeds')."\">"; $sth = $this->pdo->prepare("SELECT COUNT(id) AS num_errors @@ -1307,7 +1308,7 @@ class Pref_Feeds extends Handler_Protected { print "</div>"; # feeds pane - print "<div dojoType='dijit.layout.AccordionPane' + print "<div dojoType='dijit.layout.AccordionPane' title='<i class=\"material-icons\">import_export</i> ".__('OPML')."'>"; print "<h3>" . __("Using OPML you can export and import your feeds, filters, labels and Tiny Tiny RSS settings.") . "</h3>"; @@ -1325,6 +1326,7 @@ class Pref_Feeds extends Handler_Protected { <input style='display : none' id='opml_file' name='opml_file' type='file'> </label> <input type='hidden' name='op' value='dlg'> + <input type='hidden' name='csrf_token' value='".$_SESSION['csrf_token']."'> <input type='hidden' name='method' value='importOpml'> <button dojoType='dijit.form.Button' class='alt-primary' onclick=\"return Helpers.OPML.import();\" type=\"submit\">" . __('Import OPML') . "</button>"; @@ -1360,7 +1362,7 @@ class Pref_Feeds extends Handler_Protected { print "</div>"; # pane - print "<div dojoType=\"dijit.layout.AccordionPane\" + print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"<i class='material-icons'>share</i> ".__('Published & shared articles / Generated feeds')."\">"; print "<h3>" . __('Published articles can be subscribed by anyone who knows the following URL:') . "</h3>"; @@ -1476,7 +1478,7 @@ class Pref_Feeds extends Handler_Protected { htmlspecialchars($line["title"])."</a>"; print "</td><td class='text-muted' align='right'>"; - print make_local_datetime($line['last_article'], false); + print TimeHelper::make_local_datetime($line['last_article'], false); print "</td>"; print "</tr>"; @@ -1637,6 +1639,8 @@ class Pref_Feeds extends Handler_Protected { } function batchSubscribe() { + print "<form onsubmit='return false'>"; + print_hidden("op", "pref-feeds"); print_hidden("method", "batchaddfeeds"); @@ -1645,7 +1649,7 @@ class Pref_Feeds extends Handler_Protected { print "<textarea style='font-size : 12px; width : 98%; height: 200px;' - dojoType='dijit.form.SimpleTextarea' name='feeds'></textarea>"; + dojoType='fox.form.ValidationTextArea' required='1' name='feeds'></textarea>"; if (get_pref('ENABLE_FEED_CATS')) { print "<fieldset>"; @@ -1670,14 +1674,17 @@ class Pref_Feeds extends Handler_Protected { print "<fieldset class='narrow'> <label class='checkbox'><input type='checkbox' name='need_auth' dojoType='dijit.form.CheckBox' - onclick='displayIfChecked(this, \"feedDlg_loginContainer\")'> ". + onclick='App.displayIfChecked(this, \"feedDlg_loginContainer\")'> ". __('Feeds require authentication.')."</label></div>"; print "</fieldset>"; print "<footer> - <button dojoType='dijit.form.Button' type='submit' class='alt-primary'>".__('Subscribe')."</button> + <button dojoType='dijit.form.Button' onclick=\"return dijit.byId('batchSubDlg').execute()\" type='submit' class='alt-primary'>". + __('Subscribe')."</button> <button dojoType='dijit.form.Button' onclick=\"return dijit.byId('batchSubDlg').hide()\">".__('Cancel')."</button> </footer>"; + + print "</form>"; } function batchAddFeeds() { @@ -1696,7 +1703,7 @@ class Pref_Feeds extends Handler_Protected { foreach ($feeds as $feed) { $feed = trim($feed); - if (Feeds::validate_feed_url($feed)) { + if (UrlHelper::validate($feed)) { $this->pdo->beginTransaction(); diff --git a/classes/pref/filters.php b/classes/pref/filters.php index a3a0ce77f..1113f251e 100755 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -3,7 +3,7 @@ class Pref_Filters extends Handler_Protected { function csrf_ignore($method) { $csrf_ignored = array("index", "getfiltertree", "edit", "newfilter", "newrule", - "newaction", "savefilterorder"); + "newaction", "savefilterorder", "testfilterdlg"); return array_search($method, $csrf_ignored) !== false; } @@ -159,22 +159,19 @@ class Pref_Filters extends Handler_Protected { print json_encode($rv); } - function testFilter() { + function testFilterDlg() { + ?> + <div> + <img id='prefFilterLoadingIndicator' src='images/indicator_tiny.gif'> + <span id='prefFilterProgressMsg'>Looking for articles...</span> + </div> - if (isset($_REQUEST["offset"])) return $this->testFilterDo(); - - //print __("Articles matching this filter:"); - - print "<div><img id='prefFilterLoadingIndicator' src='images/indicator_tiny.gif'> <span id='prefFilterProgressMsg'>Looking for articles...</span></div>"; - - print "<ul class='panel panel-scrollable list list-unstyled' id='prefFilterTestResultList'>"; - print "</ul>"; - - print "<footer class='text-center'>"; - print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('filterTestDlg').hide()\">". - __('Close this window')."</button>"; - print "</footer>"; + <ul class='panel panel-scrollable list list-unstyled' id='prefFilterTestResultList'></ul> + <footer class='text-center'> + <button dojoType='dijit.form.Button' onclick="dijit.byId('filterTestDlg').hide()"><?php echo __('Close this window') ?></button> + </footer> + <?php } private function getfilterrules_list($filter_id) { @@ -241,6 +238,7 @@ class Pref_Filters extends Handler_Protected { $root = array(); $root['id'] = 'root'; $root['name'] = __('Filters'); + $root['enabled'] = true; $root['items'] = array(); $filter_search = $_SESSION["prefs_filter_search"]; @@ -304,8 +302,8 @@ class Pref_Filters extends Handler_Protected { $filter['name'] = $name[0]; $filter['param'] = $name[1]; $filter['checkbox'] = false; - $filter['last_triggered'] = $line["last_triggered"] ? make_local_datetime($line["last_triggered"], false) : null; - $filter['enabled'] = $line["enabled"]; + $filter['last_triggered'] = $line["last_triggered"] ? TimeHelper::make_local_datetime($line["last_triggered"], false) : null; + $filter['enabled'] = sql_bool_to_bool($line["enabled"]); $filter['rules'] = $this->getfilterrules_list($line['id']); if (!$filter_search || $match_ok) { @@ -600,10 +598,6 @@ class Pref_Filters extends Handler_Protected { } function editSave() { - if (clean($_REQUEST["savemode"] && $_REQUEST["savemode"]) == "test") { - return $this->testFilter(); - } - $filter_id = clean($_REQUEST["id"]); $enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"])); $match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"])); @@ -714,10 +708,6 @@ class Pref_Filters extends Handler_Protected { } function add() { - if (clean($_REQUEST["savemode"] && $_REQUEST["savemode"]) == "test") { - return $this->testFilter(); - } - $enabled = checkbox_to_sql_bool(clean($_REQUEST["enabled"])); $match_any_rule = checkbox_to_sql_bool(clean($_REQUEST["match_any_rule"])); $title = clean($_REQUEST["title"]); @@ -975,19 +965,18 @@ class Pref_Filters extends Handler_Protected { print "<section>"; - print "<input dojoType=\"dijit.form.ValidationTextBox\" - required=\"true\" id=\"filterDlg_regExp\" - onchange='Filters.filterDlgCheckRegExp(this)' - onblur='Filters.filterDlgCheckRegExp(this)' - onfocus='Filters.filterDlgCheckRegExp(this)' - style=\"font-size : 16px; width : 500px\" - name=\"reg_exp\" value=\"$reg_exp\"/>"; + print "<textarea dojoType='fox.form.ValidationTextArea' + required='true' id='filterDlg_regExp' + ValidRegExp='true' + rows='4' + style='font-size : 14px; width : 490px; word-break: break-all' + name='reg_exp'>$reg_exp</textarea>"; print "<div dojoType='dijit.Tooltip' id='filterDlg_regExp_tip' connectId='filterDlg_regExp' position='below'></div>"; print "<fieldset>"; - print "<label class='checkbox'><input id=\"filterDlg_inverse\" dojoType=\"dijit.form.CheckBox\" - name=\"inverse\" $inverse_checked/> ". + print "<label class='checkbox'><input id='filterDlg_inverse' dojoType='dijit.form.CheckBox' + name='inverse' $inverse_checked/> ". __("Inverse regular expression matching")."</label>"; print "</fieldset>"; diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index ac16b5971..d7b486cbb 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -8,7 +8,7 @@ class Pref_Prefs extends Handler_Protected { private $profile_blacklist = []; function csrf_ignore($method) { - $csrf_ignored = array("index", "updateself", "customizecss", "editprefprofiles"); + $csrf_ignored = array("index", "updateself", "customizecss", "editprefprofiles", "otpqrcode"); return array_search($method, $csrf_ignored) !== false; } @@ -125,8 +125,14 @@ class Pref_Prefs extends Handler_Protected { $old_pw = clean($_POST["old_password"]); $new_pw = clean($_POST["new_password"]); + $new_unclean_pw = $_POST["new_password"]; $con_pw = clean($_POST["confirm_password"]); + if ($new_unclean_pw != $new_pw) { + print "ERROR: ".format_error("New password contains disallowed characters."); + return; + } + if ($old_pw == $new_pw) { print "ERROR: ".format_error("New password must be different from the old one."); return; @@ -213,11 +219,9 @@ class Pref_Prefs extends Handler_Protected { if ($old_email != $email) { $mailer = new Mailer(); - require_once "lib/MiniTemplator.class.php"; + $tpl = new Templator(); - $tpl = new MiniTemplator; - - $tpl->readTemplateFromFile("templates/mail_change_template.txt"); + $tpl->readTemplateFromFile("mail_change_template.txt"); $tpl->setVariable('LOGIN', $row["login"]); $tpl->setVariable('NEWMAIL', $email); @@ -253,7 +257,7 @@ class Pref_Prefs extends Handler_Protected { AND owner_uid = :uid"); $sth->execute([":profile" => $_SESSION['profile'], ":uid" => $_SESSION['uid']]); - initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]); + $this->initialize_user_prefs($_SESSION["uid"], $_SESSION["profile"]); echo __("Your preferences are now set to default values."); } @@ -382,12 +386,12 @@ class Pref_Prefs extends Handler_Protected { print "<fieldset>"; print "<label>" . __("New password:") . "</label>"; - print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='new_password'>"; + print "<input dojoType='dijit.form.ValidationTextBox' type='password' regexp='^[^<>]+' required='1' name='new_password'>"; print "</fieldset>"; print "<fieldset>"; print "<label>" . __("Confirm password:") . "</label>"; - print "<input dojoType='dijit.form.ValidationTextBox' type='password' required='1' name='confirm_password'>"; + print "<input dojoType='dijit.form.ValidationTextBox' type='password' regexp='^[^<>]+' required='1' name='confirm_password'>"; print "</fieldset>"; print_hidden("op", "pref-prefs"); @@ -479,8 +483,8 @@ class Pref_Prefs extends Handler_Protected { if (function_exists("imagecreatefromstring")) { print "<h3>" . __("Scan the following code by the Authenticator application or copy the key manually") . "</h3>"; - $csrf_token = $_SESSION["csrf_token"]; - print "<img alt='otp qr-code' src='backend.php?op=pref-prefs&method=otpqrcode&csrf_token=$csrf_token'>"; + $csrf_token_hash = sha1($_SESSION["csrf_token"]); + print "<img alt='otp qr-code' src='backend.php?op=pref-prefs&method=otpqrcode&csrf_token_hash=$csrf_token_hash'>"; } else { print_error("PHP GD functions are required to generate QR codes."); print "<h3>" . __("Use the following OTP key with a compatible Authenticator application") . "</h3>"; @@ -586,9 +590,9 @@ class Pref_Prefs extends Handler_Protected { if ($profile) { print_notice(__("Some preferences are only available in default profile.")); - initialize_user_prefs($_SESSION["uid"], $profile); + $this->initialize_user_prefs($_SESSION["uid"], $profile); } else { - initialize_user_prefs($_SESSION["uid"]); + $this->initialize_user_prefs($_SESSION["uid"]); } $prefs_available = []; @@ -854,6 +858,10 @@ class Pref_Prefs extends Handler_Protected { print_warning("Your PHP configuration has open_basedir restrictions enabled. Some plugins relying on CURL for functionality may not work correctly."); } + if ($_SESSION["safe_mode"]) { + print_error("You have logged in using safe mode, no user plugins will be actually enabled until you login again."); + } + $feed_handler_whitelist = [ "Af_Comics" ]; $feed_handlers = array_merge( @@ -862,7 +870,7 @@ class Pref_Prefs extends Handler_Protected { PluginHost::getInstance()->get_hooks(PluginHost::HOOK_FETCH_FEED)); $feed_handlers = array_filter($feed_handlers, function($plugin) use ($feed_handler_whitelist) { - return in_array(get_class($plugin), $feed_handler_whitelist) === FALSE; }); + return in_array(get_class($plugin), $feed_handler_whitelist) === false; }); if (count($feed_handlers) > 0) { print_error( @@ -1006,21 +1014,28 @@ class Pref_Prefs extends Handler_Protected { } function otpqrcode() { - require_once "lib/phpqrcode/phpqrcode.php"; + $csrf_token_hash = clean($_REQUEST["csrf_token_hash"]); - $sth = $this->pdo->prepare("SELECT login - FROM ttrss_users - WHERE id = ?"); - $sth->execute([$_SESSION['uid']]); + if (sha1($_SESSION["csrf_token"]) === $csrf_token_hash) { + require_once "lib/phpqrcode/phpqrcode.php"; - if ($row = $sth->fetch()) { - $secret = $this->otpsecret(); - $login = $row['login']; + $sth = $this->pdo->prepare("SELECT login + FROM ttrss_users + WHERE id = ?"); + $sth->execute([$_SESSION['uid']]); - if ($secret) { - QRcode::png("otpauth://totp/".urlencode($login). - "?secret=$secret&issuer=".urlencode("Tiny Tiny RSS")); + if ($row = $sth->fetch()) { + $secret = $this->otpsecret(); + $login = $row['login']; + + if ($secret) { + QRcode::png("otpauth://totp/".urlencode($login). + "?secret=$secret&issuer=".urlencode("Tiny Tiny RSS")); + } } + } else { + header("Content-Type: text/json"); + print error_json(6); } } @@ -1087,11 +1102,9 @@ class Pref_Prefs extends Handler_Protected { if ($row = $sth->fetch()) { $mailer = new Mailer(); - require_once "lib/MiniTemplator.class.php"; - - $tpl = new MiniTemplator; + $tpl = new Templator(); - $tpl->readTemplateFromFile("templates/otp_disabled_template.txt"); + $tpl->readTemplateFromFile("otp_disabled_template.txt"); $tpl->setVariable('LOGIN', $row["login"]); $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); @@ -1307,11 +1320,11 @@ class Pref_Prefs extends Handler_Protected { print "<td>" . htmlspecialchars($row["title"]) . "</td>"; print "<td align='right' class='text-muted'>"; - print make_local_datetime($row['created'], false); + print TimeHelper::make_local_datetime($row['created'], false); print "</td>"; print "<td align='right' class='text-muted'>"; - print make_local_datetime($row['last_used'], false); + print TimeHelper::make_local_datetime($row['last_used'], false); print "</td>"; print "</tr>"; @@ -1353,4 +1366,57 @@ class Pref_Prefs extends Handler_Protected { $this->appPasswordList(); } + + static function initialize_user_prefs($uid, $profile = false) { + + if (get_schema_version() < 63) $profile_qpart = ""; + + $pdo = Db::pdo(); + $in_nested_tr = false; + + try { + $pdo->beginTransaction(); + } catch (Exception $e) { + $in_nested_tr = true; + } + + $sth = $pdo->query("SELECT pref_name,def_value FROM ttrss_prefs"); + + if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; + + $u_sth = $pdo->prepare("SELECT pref_name + FROM ttrss_user_prefs WHERE owner_uid = :uid AND + (profile = :profile OR (:profile IS NULL AND profile IS NULL))"); + $u_sth->execute([':uid' => $uid, ':profile' => $profile]); + + $active_prefs = array(); + + while ($line = $u_sth->fetch()) { + array_push($active_prefs, $line["pref_name"]); + } + + while ($line = $sth->fetch()) { + if (array_search($line["pref_name"], $active_prefs) === false) { +// print "adding " . $line["pref_name"] . "<br>"; + + if (get_schema_version() < 63) { + $i_sth = $pdo->prepare("INSERT INTO ttrss_user_prefs + (owner_uid,pref_name,value) VALUES + (?, ?, ?)"); + $i_sth->execute([$uid, $line["pref_name"], $line["def_value"]]); + + } else { + $i_sth = $pdo->prepare("INSERT INTO ttrss_user_prefs + (owner_uid,pref_name,value, profile) VALUES + (?, ?, ?, ?)"); + $i_sth->execute([$uid, $line["pref_name"], $line["def_value"], $profile]); + } + + } + } + + if (!$in_nested_tr) $pdo->commit(); + + } + } diff --git a/classes/pref/system.php b/classes/pref/system.php index d0f8a8273..7e9aa44a1 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -26,7 +26,7 @@ class Pref_System extends Handler_Protected { function index() { print "<div dojoType=\"dijit.layout.AccordionContainer\" region=\"center\">"; - print "<div dojoType=\"dijit.layout.AccordionPane\" + print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"<i class='material-icons'>report</i> ".__('Event Log')."\">"; if (LOG_DESTINATION == "sql") { @@ -66,8 +66,7 @@ class Pref_System extends Handler_Protected { print "<td class='login'>" . $line["login"] . "</td>"; print "<td class='timestamp'>" . - make_local_datetime( - $line["created_at"], false) . "</td>"; + TimeHelper::make_local_datetime($line["created_at"], false) . "</td>"; print "</tr>"; } @@ -81,7 +80,7 @@ class Pref_System extends Handler_Protected { print "</div>"; - print "<div dojoType=\"dijit.layout.AccordionPane\" + print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"<i class='material-icons'>info</i> ".__('PHP Information')."\">"; ob_start(); diff --git a/classes/pref/users.php b/classes/pref/users.php index 851d4fa9e..5ec7aa2e6 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -137,10 +137,10 @@ class Pref_Users extends Handler_Protected { if ($row = $sth->fetch()) { print "<table width='100%'>"; - $last_login = make_local_datetime( + $last_login = TimeHelper::make_local_datetime( $row["last_login"], true); - $created = make_local_datetime( + $created = TimeHelper::make_local_datetime( $row["created"], true); $stored_articles = $row["stored_articles"]; @@ -259,7 +259,7 @@ class Pref_Users extends Handler_Protected { print T_sprintf("Added user %s with password %s", $login, $tmp_user_pwd); - initialize_user($new_uid); + $this->initialize_user($new_uid); } else { @@ -304,7 +304,7 @@ class Pref_Users extends Handler_Protected { function resetPass() { $uid = clean($_REQUEST["id"]); - Pref_Users::resetUserPassword($uid); + self::resetUserPassword($uid); } function index() { @@ -399,8 +399,8 @@ class Pref_Users extends Handler_Protected { print "<tr data-row-id='$uid' onclick='Users.edit($uid)'>"; $line["login"] = htmlspecialchars($line["login"]); - $line["created"] = make_local_datetime($line["created"], false); - $line["last_login"] = make_local_datetime($line["last_login"], false); + $line["created"] = TimeHelper::make_local_datetime($line["created"], false); + $line["last_login"] = TimeHelper::make_local_datetime($line["last_login"], false); print "<td align='center'><input onclick='Tables.onRowChecked(this); event.stopPropagation();' dojoType='dijit.form.CheckBox' type='checkbox'></td>"; @@ -443,4 +443,25 @@ class Pref_Users extends Handler_Protected { return $default; } + // this is called after user is created to initialize default feeds, labels + // or whatever else + // user preferences are checked on every login, not here + static function initialize_user($uid) { + + $pdo = Db::pdo(); + + $sth = $pdo->prepare("insert into ttrss_feeds (owner_uid,title,feed_url) + values (?, 'Tiny Tiny RSS: Forum', + 'https://tt-rss.org/forum/rss.php')"); + $sth->execute([$uid]); + } + + static function logout_user() { + @session_destroy(); + if (isset($_COOKIE[session_name()])) { + setcookie(session_name(), '', time()-42000, '/'); + } + session_commit(); + } + } diff --git a/classes/rpc.php b/classes/rpc.php index 208551075..6b41a51b8 100755 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -2,7 +2,7 @@ class RPC extends Handler_Protected { function csrf_ignore($method) { - $csrf_ignored = array("sanitycheck", "completelabels", "saveprofile"); + $csrf_ignored = array("completelabels", "saveprofile"); return array_search($method, $csrf_ignored) !== false; } @@ -52,7 +52,7 @@ class RPC extends Handler_Protected { $profile_id = $row['id']; if ($profile_id) { - initialize_user_prefs($_SESSION["uid"], $profile_id); + Pref_Prefs::initialize_user_prefs($_SESSION["uid"], $profile_id); } } } @@ -279,7 +279,7 @@ class RPC extends Handler_Protected { ]; if ($seq % 2 == 0) - $reply['runtime-info'] = make_runtime_info(); + $reply['runtime-info'] = $this->make_runtime_info(); print json_encode($reply); } @@ -323,8 +323,8 @@ class RPC extends Handler_Protected { $reply['error'] = sanity_check(); if ($reply['error']['code'] == 0) { - $reply['init-params'] = make_init_params(); - $reply['runtime-info'] = make_runtime_info(); + $reply['init-params'] = $this->make_init_params(); + $reply['runtime-info'] = $this->make_runtime_info(); } print json_encode($reply); @@ -435,8 +435,10 @@ class RPC extends Handler_Protected { ) OR ( ttrss_feeds.update_interval > 0 AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_feeds.update_interval || ' minutes') AS INTERVAL) - ) OR ttrss_feeds.last_updated IS NULL - OR last_updated = '1970-01-01 00:00:00')"; + ) OR ( + ttrss_feeds.update_interval >= 0 + AND (last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL) + ))"; } else { $update_limit_qpart = "AND (( ttrss_feeds.update_interval = 0 @@ -444,8 +446,10 @@ class RPC extends Handler_Protected { ) OR ( ttrss_feeds.update_interval > 0 AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL ttrss_feeds.update_interval MINUTE) - ) OR ttrss_feeds.last_updated IS NULL - OR last_updated = '1970-01-01 00:00:00')"; + ) OR ( + ttrss_feeds.update_interval >= 0 + AND (last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL) + ))"; } // Test if feed is currently being updated by another process. @@ -455,7 +459,7 @@ class RPC extends Handler_Protected { $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 5 MINUTE))"; } - $random_qpart = sql_random_function(); + $random_qpart = Db::sql_random_function(); $pdo = Db::pdo(); @@ -508,7 +512,7 @@ class RPC extends Handler_Protected { } function updaterandomfeed() { - RPC::updaterandomfeed_real(); + self::updaterandomfeed_real(); } private function markArticlesById($ids, $cmode) { @@ -572,7 +576,7 @@ class RPC extends Handler_Protected { function log() { $msg = clean($_REQUEST['msg']); - $file = clean_filename($_REQUEST['file']); + $file = basename(clean($_REQUEST['file'])); $line = (int) clean($_REQUEST['line']); $context = clean($_REQUEST['context']); @@ -596,7 +600,7 @@ class RPC extends Handler_Protected { get_version($git_commit, $git_timestamp); if (defined('CHECK_FOR_UPDATES') && CHECK_FOR_UPDATES && $_SESSION["access_level"] >= 10 && $git_timestamp) { - $content = @fetch_file_contents(["url" => "https://srv.tt-rss.org/version.json"]); + $content = @UrlHelper::fetch(["url" => "https://tt-rss.org/version.json"]); if ($content) { $content = json_decode($content, true); @@ -614,4 +618,290 @@ class RPC extends Handler_Protected { print json_encode($rv); } + private function make_init_params() { + $params = array(); + + foreach (array("ON_CATCHUP_SHOW_NEXT_FEED", "HIDE_READ_FEEDS", + "ENABLE_FEED_CATS", "FEEDS_SORT_BY_UNREAD", "CONFIRM_FEED_CATCHUP", + "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE", + "HIDE_READ_SHOWS_SPECIAL", "COMBINED_DISPLAY_MODE") as $param) { + + $params[strtolower($param)] = (int) get_pref($param); + } + + $params["check_for_updates"] = CHECK_FOR_UPDATES; + $params["icons_url"] = ICONS_URL; + $params["cookie_lifetime"] = SESSION_COOKIE_LIFETIME; + $params["default_view_mode"] = get_pref("_DEFAULT_VIEW_MODE"); + $params["default_view_limit"] = (int) get_pref("_DEFAULT_VIEW_LIMIT"); + $params["default_view_order_by"] = get_pref("_DEFAULT_VIEW_ORDER_BY"); + $params["bw_limit"] = (int) $_SESSION["bw_limit"]; + $params["is_default_pw"] = Pref_Prefs::isdefaultpassword(); + $params["label_base_index"] = (int) LABEL_BASE_INDEX; + + $theme = get_pref( "USER_CSS_THEME", false, false); + $params["theme"] = theme_exists($theme) ? $theme : ""; + + $params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names()); + + $params["php_platform"] = PHP_OS; + $params["php_version"] = PHP_VERSION; + + $pdo = Db::pdo(); + + $sth = $pdo->prepare("SELECT MAX(id) AS mid, COUNT(*) AS nf FROM + ttrss_feeds WHERE owner_uid = ?"); + $sth->execute([$_SESSION['uid']]); + $row = $sth->fetch(); + + $max_feed_id = $row["mid"]; + $num_feeds = $row["nf"]; + + $params["self_url_prefix"] = get_self_url_prefix(); + $params["max_feed_id"] = (int) $max_feed_id; + $params["num_feeds"] = (int) $num_feeds; + + $params["hotkeys"] = $this->get_hotkeys_map(); + + $params["widescreen"] = (int) $_COOKIE["ttrss_widescreen"]; + + $params['simple_update'] = defined('SIMPLE_UPDATE_MODE') && SIMPLE_UPDATE_MODE; + + $params["icon_indicator_white"] = $this->image_to_base64("images/indicator_white.gif"); + + $params["labels"] = Labels::get_all_labels($_SESSION["uid"]); + + return $params; + } + + private function image_to_base64($filename) { + if (file_exists($filename)) { + $ext = pathinfo($filename, PATHINFO_EXTENSION); + + return "data:image/$ext;base64," . base64_encode(file_get_contents($filename)); + } else { + return ""; + } + } + + static function make_runtime_info() { + $data = array(); + + $pdo = Db::pdo(); + + $sth = $pdo->prepare("SELECT MAX(id) AS mid, COUNT(*) AS nf FROM + ttrss_feeds WHERE owner_uid = ?"); + $sth->execute([$_SESSION['uid']]); + $row = $sth->fetch(); + + $max_feed_id = $row['mid']; + $num_feeds = $row['nf']; + + $data["max_feed_id"] = (int) $max_feed_id; + $data["num_feeds"] = (int) $num_feeds; + $data['cdm_expanded'] = get_pref('CDM_EXPANDED'); + $data["labels"] = Labels::get_all_labels($_SESSION["uid"]); + + if (LOG_DESTINATION == 'sql' && $_SESSION['access_level'] >= 10) { + if (DB_TYPE == 'pgsql') { + $log_interval = "created_at > NOW() - interval '1 hour'"; + } else { + $log_interval = "created_at > DATE_SUB(NOW(), INTERVAL 1 HOUR)"; + } + + $sth = $pdo->prepare("SELECT COUNT(id) AS cid FROM ttrss_error_log WHERE errno != 1024 AND $log_interval"); + $sth->execute(); + + if ($row = $sth->fetch()) { + $data['recent_log_events'] = $row['cid']; + } + } + + if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) { + + $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock"); + + if (time() - $_SESSION["daemon_stamp_check"] > 30) { + + $stamp = (int) @file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); + + if ($stamp) { + $stamp_delta = time() - $stamp; + + if ($stamp_delta > 1800) { + $stamp_check = 0; + } else { + $stamp_check = 1; + $_SESSION["daemon_stamp_check"] = time(); + } + + $data['daemon_stamp_ok'] = $stamp_check; + + $stamp_fmt = date("Y.m.d, G:i", $stamp); + + $data['daemon_stamp'] = $stamp_fmt; + } + } + } + + return $data; + } + + static function get_hotkeys_info() { + $hotkeys = array( + __("Navigation") => array( + "next_feed" => __("Open next feed"), + "prev_feed" => __("Open previous feed"), + "next_article_or_scroll" => __("Open next article (in combined mode, scroll down)"), + "prev_article_or_scroll" => __("Open previous article (in combined mode, scroll up)"), + "next_headlines_page" => __("Scroll headlines by one page down"), + "prev_headlines_page" => __("Scroll headlines by one page up"), + "next_article_noscroll" => __("Open next article"), + "prev_article_noscroll" => __("Open previous article"), + "next_article_noexpand" => __("Move to next article (don't expand)"), + "prev_article_noexpand" => __("Move to previous article (don't expand)"), + "search_dialog" => __("Show search dialog"), + "cancel_search" => __("Cancel active search")), + __("Article") => array( + "toggle_mark" => __("Toggle starred"), + "toggle_publ" => __("Toggle published"), + "toggle_unread" => __("Toggle unread"), + "edit_tags" => __("Edit tags"), + "open_in_new_window" => __("Open in new window"), + "catchup_below" => __("Mark below as read"), + "catchup_above" => __("Mark above as read"), + "article_scroll_down" => __("Scroll down"), + "article_scroll_up" => __("Scroll up"), + "article_page_down" => __("Scroll down page"), + "article_page_up" => __("Scroll up page"), + "select_article_cursor" => __("Select article under cursor"), + "email_article" => __("Email article"), + "close_article" => __("Close/collapse article"), + "toggle_expand" => __("Toggle article expansion (combined mode)"), + "toggle_widescreen" => __("Toggle widescreen mode"), + "toggle_full_text" => __("Toggle full article text via Readability")), + __("Article selection") => array( + "select_all" => __("Select all articles"), + "select_unread" => __("Select unread"), + "select_marked" => __("Select starred"), + "select_published" => __("Select published"), + "select_invert" => __("Invert selection"), + "select_none" => __("Deselect everything")), + __("Feed") => array( + "feed_refresh" => __("Refresh current feed"), + "feed_unhide_read" => __("Un/hide read feeds"), + "feed_subscribe" => __("Subscribe to feed"), + "feed_edit" => __("Edit feed"), + "feed_catchup" => __("Mark as read"), + "feed_reverse" => __("Reverse headlines"), + "feed_toggle_vgroup" => __("Toggle headline grouping"), + "feed_debug_update" => __("Debug feed update"), + "feed_debug_viewfeed" => __("Debug viewfeed()"), + "catchup_all" => __("Mark all feeds as read"), + "cat_toggle_collapse" => __("Un/collapse current category"), + "toggle_cdm_expanded" => __("Toggle auto expand in combined mode"), + "toggle_combined_mode" => __("Toggle combined mode")), + __("Go to") => array( + "goto_all" => __("All articles"), + "goto_fresh" => __("Fresh"), + "goto_marked" => __("Starred"), + "goto_published" => __("Published"), + "goto_read" => __("Recently read"), + "goto_tagcloud" => __("Tag cloud"), + "goto_prefs" => __("Preferences")), + __("Other") => array( + "create_label" => __("Create label"), + "create_filter" => __("Create filter"), + "collapse_sidebar" => __("Un/collapse sidebar"), + "help_dialog" => __("Show help dialog")) + ); + + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HOTKEY_INFO) as $plugin) { + $hotkeys = $plugin->hook_hotkey_info($hotkeys); + } + + return $hotkeys; + } + + // {3} - 3 panel mode only + // {C} - combined mode only + static function get_hotkeys_map() { + $hotkeys = array( + "k" => "next_feed", + "j" => "prev_feed", + "n" => "next_article_noscroll", + "p" => "prev_article_noscroll", + "N" => "article_page_down", + "P" => "article_page_up", + "*(33)|Shift+PgUp" => "article_page_up", + "*(34)|Shift+PgDn" => "article_page_down", + "{3}(38)|Up" => "prev_article_or_scroll", + "{3}(40)|Down" => "next_article_or_scroll", + "*(38)|Shift+Up" => "article_scroll_up", + "*(40)|Shift+Down" => "article_scroll_down", + "^(38)|Ctrl+Up" => "prev_article_noscroll", + "^(40)|Ctrl+Down" => "next_article_noscroll", + "/" => "search_dialog", + "\\" => "cancel_search", + "s" => "toggle_mark", + "S" => "toggle_publ", + "u" => "toggle_unread", + "T" => "edit_tags", + "o" => "open_in_new_window", + "c p" => "catchup_below", + "c n" => "catchup_above", + "a W" => "toggle_widescreen", + "a e" => "toggle_full_text", + "e" => "email_article", + "a q" => "close_article", + "a a" => "select_all", + "a u" => "select_unread", + "a U" => "select_marked", + "a p" => "select_published", + "a i" => "select_invert", + "a n" => "select_none", + "f r" => "feed_refresh", + "f a" => "feed_unhide_read", + "f s" => "feed_subscribe", + "f e" => "feed_edit", + "f q" => "feed_catchup", + "f x" => "feed_reverse", + "f g" => "feed_toggle_vgroup", + "f D" => "feed_debug_update", + "f G" => "feed_debug_viewfeed", + "f C" => "toggle_combined_mode", + "f c" => "toggle_cdm_expanded", + "Q" => "catchup_all", + "x" => "cat_toggle_collapse", + "g a" => "goto_all", + "g f" => "goto_fresh", + "g s" => "goto_marked", + "g p" => "goto_published", + "g r" => "goto_read", + "g t" => "goto_tagcloud", + "g P" => "goto_prefs", + "r" => "select_article_cursor", + "c l" => "create_label", + "c f" => "create_filter", + "c s" => "collapse_sidebar", + "?" => "help_dialog", + ); + + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HOTKEY_MAP) as $plugin) { + $hotkeys = $plugin->hook_hotkey_map($hotkeys); + } + + $prefixes = array(); + + foreach (array_keys($hotkeys) as $hotkey) { + $pair = explode(" ", $hotkey, 2); + + if (count($pair) > 1 && !in_array($pair[0], $prefixes)) { + array_push($prefixes, $pair[0]); + } + } + + return array($prefixes, $hotkeys); + } + } diff --git a/classes/rssutils.php b/classes/rssutils.php index 831ac1baf..2ec24d9be 100755 --- a/classes/rssutils.php +++ b/classes/rssutils.php @@ -3,7 +3,12 @@ class RSSUtils { static function calculate_article_hash($article, $pluginhost) { $tmp = ""; + $ignored_fields = [ "feed", "guid", "guid_hashed", "owner_uid", "force_catchup" ]; + foreach ($article as $k => $v) { + if (in_array($k, $ignored_fields)) + continue; + if ($k != "feed" && isset($v)) { $x = strip_tags(is_array($v) ? implode(",", $v) : $v); @@ -24,7 +29,29 @@ class RSSUtils { $pdo->query("DELETE FROM ttrss_feedbrowser_cache"); } - static function update_daemon_common($limit = DAEMON_FEED_LIMIT) { + static function cleanup_feed_icons() { + $pdo = Db::pdo(); + $sth = $pdo->prepare("SELECT id FROM ttrss_feeds WHERE id = ?"); + + // check icon files once every CACHE_MAX_DAYS days + $icon_files = array_filter(glob(ICONS_DIR . "/*.ico"), + function($f) { return filemtime($f) < time() - 86400*CACHE_MAX_DAYS; }); + + foreach ($icon_files as $icon) { + $feed_id = basename($icon, ".ico"); + + $sth->execute([$feed_id]); + + if ($sth->fetch()) { + @touch($icon); + } else { + Debug::log("Removing orphaned feed icon: $icon"); + unlink($icon); + } + } + } + + static function update_daemon_common($limit = DAEMON_FEED_LIMIT, $options = []) { $schema_version = get_schema_version(); if ($schema_version != SCHEMA_VERSION) { @@ -47,33 +74,31 @@ class RSSUtils { $update_limit_qpart = "AND (( ttrss_feeds.update_interval = 0 AND ttrss_user_prefs.value != '-1' - AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_user_prefs.value || ' minutes') AS INTERVAL) + AND last_updated < NOW() - CAST((ttrss_user_prefs.value || ' minutes') AS INTERVAL) ) OR ( ttrss_feeds.update_interval > 0 - AND ttrss_feeds.last_updated < NOW() - CAST((ttrss_feeds.update_interval || ' minutes') AS INTERVAL) - ) OR (ttrss_feeds.last_updated IS NULL - AND ttrss_user_prefs.value != '-1') - OR (last_updated = '1970-01-01 00:00:00' + AND last_updated < NOW() - CAST((ttrss_feeds.update_interval || ' minutes') AS INTERVAL) + ) OR ((last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL) + AND ttrss_feeds.update_interval >= 0 AND ttrss_user_prefs.value != '-1'))"; } else { $update_limit_qpart = "AND (( ttrss_feeds.update_interval = 0 AND ttrss_user_prefs.value != '-1' - AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL CONVERT(ttrss_user_prefs.value, SIGNED INTEGER) MINUTE) + AND last_updated < DATE_SUB(NOW(), INTERVAL CONVERT(ttrss_user_prefs.value, SIGNED INTEGER) MINUTE) ) OR ( ttrss_feeds.update_interval > 0 - AND ttrss_feeds.last_updated < DATE_SUB(NOW(), INTERVAL ttrss_feeds.update_interval MINUTE) - ) OR (ttrss_feeds.last_updated IS NULL - AND ttrss_user_prefs.value != '-1') - OR (last_updated = '1970-01-01 00:00:00' + AND last_updated < DATE_SUB(NOW(), INTERVAL ttrss_feeds.update_interval MINUTE) + ) OR ((last_updated = '1970-01-01 00:00:00' OR last_updated IS NULL) + AND ttrss_feeds.update_interval >= 0 AND ttrss_user_prefs.value != '-1'))"; } // Test if feed is currently being updated by another process. if (DB_TYPE == "pgsql") { - $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < NOW() - INTERVAL '10 minutes')"; + $updstart_thresh_qpart = "AND (last_update_started IS NULL OR last_update_started < NOW() - INTERVAL '10 minutes')"; } else { - $updstart_thresh_qpart = "AND (ttrss_feeds.last_update_started IS NULL OR ttrss_feeds.last_update_started < DATE_SUB(NOW(), INTERVAL 10 MINUTE))"; + $updstart_thresh_qpart = "AND (last_update_started IS NULL OR last_update_started < DATE_SUB(NOW(), INTERVAL 10 MINUTE))"; } $query_limit = $limit ? sprintf("LIMIT %d", $limit) : ""; @@ -119,7 +144,11 @@ class RSSUtils { $batch_owners = array(); // since we have the data cached, we can deal with other feeds with the same url - $usth = $pdo->prepare("SELECT DISTINCT ttrss_feeds.id,last_updated,ttrss_feeds.owner_uid + $usth = $pdo->prepare("SELECT + DISTINCT ttrss_feeds.id, + last_updated, + ttrss_feeds.owner_uid, + ttrss_feeds.title FROM ttrss_feeds, ttrss_users, ttrss_user_prefs WHERE ttrss_user_prefs.owner_uid = ttrss_feeds.owner_uid AND ttrss_users.id = ttrss_user_prefs.owner_uid AND @@ -134,31 +163,70 @@ class RSSUtils { Debug::log("Base feed: $feed"); $usth->execute([$feed]); - //update_rss_feed($line["id"], true); if ($tline = $usth->fetch()) { - Debug::log(" => " . $tline["last_updated"] . ", " . $tline["id"] . " " . $tline["owner_uid"]); + Debug::log(sprintf("=> %s (ID: %d, UID: %d), last updated: %s", $tline["title"], $tline["id"], $tline["owner_uid"], + $tline["last_updated"] ? $tline["last_updated"] : "never")); - if (array_search($tline["owner_uid"], $batch_owners) === FALSE) + if (array_search($tline["owner_uid"], $batch_owners) === false) array_push($batch_owners, $tline["owner_uid"]); $fstarted = microtime(true); - try { - RSSUtils::update_rss_feed($tline["id"], true, false); - } catch (PDOException $e) { - Logger::get()->log_error(E_USER_NOTICE, $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString()); + $quiet = (isset($options["quiet"])) ? "--quiet" : ""; + $log = function_exists("flock") && isset($options['log']) ? '--log '.$options['log'] : ''; + $log_level = isset($options['log-level']) ? '--log-level '.$options['log-level'] : ''; + + /* shared hosting may have this disabled and it's not strictly required */ + if (self::function_enabled('passthru')) { + $exit_code = 0; + + passthru(PHP_EXECUTABLE . " update.php --update-feed " . $tline["id"] . " --pidlock feed-" . $tline["id"] . " $quiet $log $log_level", $exit_code); + + Debug::log(sprintf("<= %.4f (sec) exit code: %d", microtime(true) - $fstarted, $exit_code)); + + // -1 can be caused by a SIGCHLD handler which daemon master process installs (not every setup, apparently) + if ($exit_code != 0 && $exit_code != -1) { + $esth = $pdo->prepare("SELECT last_error FROM ttrss_feeds WHERE id = ?"); + $esth->execute([$tline["id"]]); + + if ($erow = $esth->fetch()) { + $error_message = $erow["last_error"]; + } else { + $error_message = "N/A"; + } + + Debug::log("!! Last error: $error_message"); + + Logger::get()->log(E_USER_NOTICE, + sprintf("Update process for feed %d (%s, owner UID: %d) failed with exit code: %d (%s).", + $tline["id"], clean($tline["title"]), $tline["owner_uid"], $exit_code, clean($error_message))); + } + } else { try { - $pdo->rollback(); + if (!self::update_rss_feed($tline["id"], true)) { + global $fetch_last_error; + + Logger::get()->log(E_USER_NOTICE, + sprintf("Update request for feed %d (%s, owner UID: %d) failed: %s.", + $tline["id"], clean($tline["title"]), $tline["owner_uid"], clean($fetch_last_error))); + } + + Debug::log(sprintf("<= %.4f (sec) (not using a separate process)", microtime(true) - $fstarted)); + } catch (PDOException $e) { - // it doesn't matter if there wasn't actually anything to rollback, PDO Exception can be - // thrown outside of an active transaction during feed update + Logger::get()->log_error(E_USER_WARNING, $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString()); + + try { + $pdo->rollback(); + } catch (PDOException $e) { + // it doesn't matter if there wasn't actually anything to rollback, PDO Exception can be + // thrown outside of an active transaction during feed update + } } } - Debug::log(sprintf(" %.4f (sec)", microtime(true) - $fstarted)); - ++$nf; } } @@ -171,7 +239,7 @@ class RSSUtils { foreach ($batch_owners as $owner_uid) { Debug::log("Running housekeeping tasks for user $owner_uid..."); - RSSUtils::housekeeping_user($owner_uid); + self::housekeeping_user($owner_uid); } // Send feed digests by email if needed. @@ -209,7 +277,7 @@ class RSSUtils { } if (!$basic_info) { - $feed_data = fetch_file_contents($fetch_url, false, + $feed_data = UrlHelper::fetch($fetch_url, false, $auth_login, $auth_pass, false, FEED_FETCH_TIMEOUT, 0); @@ -259,8 +327,6 @@ class RSSUtils { */ static function update_rss_feed($feed, $no_cache = false) { - reset_fetch_domain_quota(); - Debug::log("start", Debug::$LOG_VERBOSE); $pdo = Db::pdo(); @@ -281,7 +347,7 @@ class RSSUtils { // this is not optimal currently as it fetches stuff separately TODO: optimize if ($title == "[Unknown]" || !$title || !$site_url) { Debug::log("setting basic feed info for $feed [$title, $site_url]..."); - RSSUtils::set_basic_feed_info($feed); + self::set_basic_feed_info($feed); } $sth = $pdo->prepare("SELECT id,update_interval,auth_login, @@ -391,7 +457,7 @@ class RSSUtils { Debug::log("fetching [$fetch_url] (force_refetch: $force_refetch)...", Debug::$LOG_VERBOSE); - $feed_data = fetch_file_contents([ + $feed_data = UrlHelper::fetch([ "url" => $fetch_url, "login" => $auth_login, "pass" => $auth_pass, @@ -401,7 +467,11 @@ class RSSUtils { $feed_data = trim($feed_data); + global $fetch_effective_url; + global $fetch_effective_ip_addr; + Debug::log("fetch done.", Debug::$LOG_VERBOSE); + Debug::log("effective URL (after redirects): " . clean($fetch_effective_url) . " (IP: $fetch_effective_ip_addr)", Debug::$LOG_VERBOSE); Debug::log("source last modified: " . $fetch_last_modified, Debug::$LOG_VERBOSE); if ($feed_data && $fetch_last_modified != $stored_last_modified) { @@ -427,18 +497,24 @@ class RSSUtils { Debug::log("unable to fetch: $fetch_last_error [$fetch_last_error_code]", Debug::$LOG_VERBOSE); // If-Modified-Since - if ($fetch_last_error_code != 304) { - $error_message = $fetch_last_error; - } else { + if ($fetch_last_error_code == 304) { Debug::log("source claims data not modified, nothing to do.", Debug::$LOG_VERBOSE); $error_message = ""; - } - $sth = $pdo->prepare("UPDATE ttrss_feeds SET last_error = ?, + $sth = $pdo->prepare("UPDATE ttrss_feeds SET last_error = ?, + last_successful_update = NOW(), last_updated = NOW() WHERE id = ?"); + + } else { + $error_message = $fetch_last_error; + + $sth = $pdo->prepare("UPDATE ttrss_feeds SET last_error = ?, + last_updated = NOW() WHERE id = ?"); + } + $sth->execute([$error_message, $feed]); - return; + return $error_message == ""; } Debug::log("running HOOK_FEED_FETCHED handlers...", Debug::$LOG_VERBOSE); @@ -469,7 +545,7 @@ class RSSUtils { foreach ($pluginhost->get_hooks(PluginHost::HOOK_FEED_PARSED) as $plugin) { Debug::log("... " . get_class($plugin), Debug::$LOG_VERBOSE); $start = microtime(true); - $plugin->hook_feed_parsed($rss); + $plugin->hook_feed_parsed($rss, $feed); Debug::log(sprintf("=== %.4f (sec)", microtime(true) - $start), Debug::$LOG_VERBOSE); } @@ -511,7 +587,7 @@ class RSSUtils { Debug::log("checking favicon...", Debug::$LOG_VERBOSE); - RSSUtils::check_feed_favicon($site_url, $feed); + self::check_feed_favicon($site_url, $feed); $favicon_modified_new = @filemtime($favicon_file); if ($favicon_modified_new > $favicon_modified) @@ -540,7 +616,7 @@ class RSSUtils { Debug::log("loading filters & labels...", Debug::$LOG_VERBOSE); - $filters = RSSUtils::load_filters($feed, $owner_uid); + $filters = self::load_filters($feed, $owner_uid); if (Debug::get_loglevel() >= Debug::$LOG_EXTENDED) { print_r($filters); @@ -579,18 +655,18 @@ class RSSUtils { $entry_guid = strip_tags($item->get_id()); if (!$entry_guid) $entry_guid = strip_tags($item->get_link()); - if (!$entry_guid) $entry_guid = RSSUtils::make_guid_from_title($item->get_title()); + if (!$entry_guid) $entry_guid = self::make_guid_from_title($item->get_title()); if (!$entry_guid) { $pdo->commit(); continue; } + $entry_guid_hashed_compat = 'SHA1:' . sha1("$owner_uid,$entry_guid"); + $entry_guid_hashed = json_encode(["ver" => 2, "uid" => $owner_uid, "hash" => 'SHA1:' . sha1($entry_guid)]); $entry_guid = "$owner_uid,$entry_guid"; - $entry_guid_hashed = 'SHA1:' . sha1($entry_guid); - - Debug::log("guid $entry_guid / $entry_guid_hashed", Debug::$LOG_VERBOSE); + Debug::log("guid $entry_guid (hash: $entry_guid_hashed compat: $entry_guid_hashed_compat)", Debug::$LOG_VERBOSE); $entry_timestamp = (int)$item->get_date(); @@ -632,8 +708,8 @@ class RSSUtils { Debug::log("done collecting data.", Debug::$LOG_VERBOSE); $sth = $pdo->prepare("SELECT id, content_hash, lang FROM ttrss_entries - WHERE guid = ? OR guid = ?"); - $sth->execute([$entry_guid, $entry_guid_hashed]); + WHERE guid IN (?, ?, ?)"); + $sth->execute([$entry_guid, $entry_guid_hashed, $entry_guid_hashed_compat]); if ($row = $sth->fetch()) { $base_entry_id = $row["id"]; @@ -648,6 +724,38 @@ class RSSUtils { $article_labels = array(); } + Debug::log("looking for enclosures...", Debug::$LOG_VERBOSE); + + // enclosures + + $enclosures = array(); + + $encs = $item->get_enclosures(); + + if (is_array($encs)) { + foreach ($encs as $e) { + + foreach ($pluginhost->get_hooks(PluginHost::HOOK_ENCLOSURE_IMPORTED) as $plugin) { + $e = $plugin->hook_enclosure_imported($e, $feed); + } + + $e_item = array( + rewrite_relative_url($site_url, $e->link), + $e->type, $e->length, $e->title, $e->width, $e->height); + + // Yet another episode of "mysql utf8_general_ci is gimped" + if (DB_TYPE == "mysql" && MYSQL_CHARSET != "UTF8MB4") { + for ($i = 0; $i < count($e_item); $i++) { + if (is_string($e_item[$i])) { + $e_item[$i] = self::strip_utf8mb4($e_item[$i]); + } + } + } + + array_push($enclosures, $e_item); + } + } + $article = array("owner_uid" => $owner_uid, // read only "guid" => $entry_guid, // read only "guid_hashed" => $entry_guid_hashed, // read only @@ -662,6 +770,7 @@ class RSSUtils { "language" => $entry_language, "timestamp" => $entry_timestamp, "num_comments" => $num_comments, + "enclosures" => $enclosures, "feed" => array("id" => $feed, "fetch_url" => $fetch_url, "site_url" => $site_url, @@ -669,7 +778,7 @@ class RSSUtils { ); $entry_plugin_data = ""; - $entry_current_hash = RSSUtils::calculate_article_hash($article, $pluginhost); + $entry_current_hash = self::calculate_article_hash($article, $pluginhost); Debug::log("article hash: $entry_current_hash [stored=$entry_stored_hash]", Debug::$LOG_VERBOSE); @@ -715,7 +824,7 @@ class RSSUtils { foreach ($article as $k => $v) { // i guess we'll have to take the risk of 4byte unicode labels & tags here if (is_string($article[$k])) { - $article[$k] = RSSUtils::strip_utf8mb4($v); + $article[$k] = self::strip_utf8mb4($v); } } } @@ -725,7 +834,7 @@ class RSSUtils { $matched_rules = []; $matched_filters = []; - $article_filters = RSSUtils::get_article_filters($filters, $article["title"], + $article_filters = self::get_article_filters($filters, $article["title"], $article["content"], $article["link"], $article["author"], $article["tags"], $matched_rules, $matched_filters); @@ -765,7 +874,7 @@ class RSSUtils { } } - $plugin_filter_names = RSSUtils::find_article_filters($article_filters, "plugin"); + $plugin_filter_names = self::find_article_filters($article_filters, "plugin"); $plugin_filter_actions = $pluginhost->get_filter_actions(); if (count($plugin_filter_names) > 0) { @@ -804,6 +913,7 @@ class RSSUtils { $entry_language = $article["language"]; $entry_timestamp = $article["timestamp"]; $num_comments = $article["num_comments"]; + $enclosures = $article["enclosures"]; if ($entry_timestamp == -1 || !$entry_timestamp || $entry_timestamp > time()) { $entry_timestamp = time(); @@ -825,11 +935,11 @@ class RSSUtils { Debug::log("force catchup: $entry_force_catchup", Debug::$LOG_VERBOSE); if ($cache_images) - RSSUtils::cache_media($entry_content, $site_url); + self::cache_media($entry_content, $site_url); $csth = $pdo->prepare("SELECT id FROM ttrss_entries - WHERE guid = ? OR guid = ?"); - $csth->execute([$entry_guid, $entry_guid_hashed]); + WHERE guid IN (?, ?, ?)"); + $csth->execute([$entry_guid, $entry_guid_hashed, $entry_guid_hashed_compat]); if (!$row = $csth->fetch()) { @@ -874,7 +984,7 @@ class RSSUtils { } - $csth->execute([$entry_guid, $entry_guid_hashed]); + $csth->execute([$entry_guid, $entry_guid_hashed, $entry_guid_hashed_compat]); $entry_ref_id = 0; $entry_int_id = 0; @@ -886,13 +996,13 @@ class RSSUtils { $ref_id = $row['id']; $entry_ref_id = $ref_id; - if (RSSUtils::find_article_filter($article_filters, "filter")) { + if (self::find_article_filter($article_filters, "filter")) { Debug::log("article is filtered out, nothing to do.", Debug::$LOG_VERBOSE); $pdo->commit(); continue; } - $score = RSSUtils::calculate_article_score($article_filters) + $entry_score_modifier; + $score = self::calculate_article_score($article_filters) + $entry_score_modifier; Debug::log("initial score: $score [including plugin modifier: $entry_score_modifier]", Debug::$LOG_VERBOSE); @@ -912,7 +1022,7 @@ class RSSUtils { Debug::log("user record not found, creating...", Debug::$LOG_VERBOSE); - if ($score >= -500 && !RSSUtils::find_article_filter($article_filters, 'catchup') && !$entry_force_catchup) { + if ($score >= -500 && !self::find_article_filter($article_filters, 'catchup') && !$entry_force_catchup) { $unread = 1; $last_read_qpart = null; } else { @@ -920,13 +1030,13 @@ class RSSUtils { $last_read_qpart = date("Y-m-d H:i"); // we can't use NOW() here because it gets quoted } - if (RSSUtils::find_article_filter($article_filters, 'mark') || $score > 1000) { + if (self::find_article_filter($article_filters, 'mark') || $score > 1000) { $marked = 1; } else { $marked = 0; } - if (RSSUtils::find_article_filter($article_filters, 'publish')) { + if (self::find_article_filter($article_filters, 'publish')) { $published = 1; } else { $published = 0; @@ -999,7 +1109,7 @@ class RSSUtils { if ($mark_unread_on_update && !$entry_force_catchup && - !RSSUtils::find_article_filter($article_filters, 'catchup')) { + !self::find_article_filter($article_filters, 'catchup')) { Debug::log("article updated, marking unread as requested.", Debug::$LOG_VERBOSE); @@ -1019,38 +1129,11 @@ class RSSUtils { Debug::log("assigning labels [filters]...", Debug::$LOG_VERBOSE); - RSSUtils::assign_article_to_label_filters($entry_ref_id, $article_filters, + self::assign_article_to_label_filters($entry_ref_id, $article_filters, $owner_uid, $article_labels); - Debug::log("looking for enclosures...", Debug::$LOG_VERBOSE); - - // enclosures - - $enclosures = array(); - - $encs = $item->get_enclosures(); - - if (is_array($encs)) { - foreach ($encs as $e) { - $e_item = array( - rewrite_relative_url($site_url, $e->link), - $e->type, $e->length, $e->title, $e->width, $e->height); - - // Yet another episode of "mysql utf8_general_ci is gimped" - if (DB_TYPE == "mysql" && MYSQL_CHARSET != "UTF8MB4") { - for ($i = 0; $i < count($e_item); $i++) { - if (is_string($e_item[$i])) { - $e_item[$i] = RSSUtils::strip_utf8mb4($e_item[$i]); - } - } - } - - array_push($enclosures, $e_item); - } - } - if ($cache_images) - RSSUtils::cache_enclosures($enclosures, $site_url); + self::cache_enclosures($enclosures, $site_url); if (Debug::get_loglevel() >= Debug::$LOG_EXTENDED) { Debug::log("article enclosures:", Debug::$LOG_VERBOSE); @@ -1155,8 +1238,11 @@ class RSSUtils { Feeds::purge_feed($feed, 0); - $sth = $pdo->prepare("UPDATE ttrss_feeds - SET last_updated = NOW(), last_unconditional = NOW(), last_error = '' WHERE id = ?"); + $sth = $pdo->prepare("UPDATE ttrss_feeds SET + last_updated = NOW(), + last_unconditional = NOW(), + last_successful_update = NOW(), + last_error = '' WHERE id = ?"); $sth->execute([$feed]); } else { @@ -1171,8 +1257,10 @@ class RSSUtils { } } - $sth = $pdo->prepare("UPDATE ttrss_feeds SET last_error = ?, - last_updated = NOW(), last_unconditional = NOW() WHERE id = ?"); + $sth = $pdo->prepare("UPDATE ttrss_feeds SET + last_error = ?, + last_updated = NOW(), + last_unconditional = NOW() WHERE id = ?"); $sth->execute([$error_msg, $feed]); unset($rss); @@ -1186,6 +1274,7 @@ class RSSUtils { return true; } + /* TODO: move to DiskCache? */ static function cache_enclosures($enclosures, $site_url) { $cache = new DiskCache("images"); @@ -1204,7 +1293,7 @@ class RSSUtils { global $fetch_last_error_code; global $fetch_last_error; - $file_content = fetch_file_contents(array("url" => $src, + $file_content = UrlHelper::fetch(array("url" => $src, "http_referrer" => $src, "max_size" => MAX_CACHE_FILE_SIZE)); @@ -1221,6 +1310,34 @@ class RSSUtils { } } + /* TODO: move to DiskCache? */ + static function cache_media_url($cache, $url, $site_url) { + $url = rewrite_relative_url($site_url, $url); + $local_filename = sha1($url); + + Debug::log("cache_media: checking $url", Debug::$LOG_VERBOSE); + + if (!$cache->exists($local_filename)) { + Debug::log("cache_media: downloading: $url to $local_filename", Debug::$LOG_VERBOSE); + + global $fetch_last_error_code; + global $fetch_last_error; + + $file_content = UrlHelper::fetch(array("url" => $url, + "http_referrer" => $url, + "max_size" => MAX_CACHE_FILE_SIZE)); + + if ($file_content) { + $cache->put($local_filename, $file_content); + } else { + Debug::log("cache_media: failed with $fetch_last_error_code: $fetch_last_error"); + } + } else if ($cache->isWritable($local_filename)) { + $cache->touch($local_filename); + } + } + + /* TODO: move to DiskCache? */ static function cache_media($html, $site_url) { $cache = new DiskCache("images"); @@ -1229,33 +1346,20 @@ class RSSUtils { if ($doc->loadHTML($html)) { $xpath = new DOMXPath($doc); - $entries = $xpath->query('(//img[@src])|(//video/source[@src])|(//audio/source[@src])'); + $entries = $xpath->query('(//img[@src]|//source[@src|@srcset]|//video[@poster|@src])'); foreach ($entries as $entry) { - if ($entry->hasAttribute('src') && strpos($entry->getAttribute('src'), "data:") !== 0) { - $src = rewrite_relative_url($site_url, $entry->getAttribute('src')); - - $local_filename = sha1($src); - - Debug::log("cache_media: checking $src", Debug::$LOG_VERBOSE); - - if (!$cache->exists($local_filename)) { - Debug::log("cache_media: downloading: $src to $local_filename", Debug::$LOG_VERBOSE); - - global $fetch_last_error_code; - global $fetch_last_error; + foreach (array('src', 'poster') as $attr) { + if ($entry->hasAttribute($attr) && strpos($entry->getAttribute($attr), "data:") !== 0) { + self::cache_media_url($cache, $entry->getAttribute($attr), $site_url); + } + } - $file_content = fetch_file_contents(array("url" => $src, - "http_referrer" => $src, - "max_size" => MAX_CACHE_FILE_SIZE)); + if ($entry->hasAttribute("srcset")) { + $matches = self::decode_srcset($entry->getAttribute('srcset')); - if ($file_content) { - $cache->put($local_filename, $file_content); - } else { - Debug::log("cache_media: failed with $fetch_last_error_code: $fetch_last_error"); - } - } else if ($cache->isWritable($local_filename)) { - $cache->touch($local_filename); + for ($i = 0; $i < count($matches); $i++) { + self::cache_media_url($cache, $matches[$i]["url"], $site_url); } } } @@ -1343,6 +1447,7 @@ class RSSUtils { foreach ($filter["rules"] as $rule) { $match = false; $reg_exp = str_replace('/', '\/', $rule["reg_exp"]); + $reg_exp = str_replace("\n", "", $reg_exp); // reg_exp may be formatted with CRs now because of textarea, we need to strip those $rule_inverse = $rule["inverse"]; if (!$reg_exp) @@ -1457,7 +1562,7 @@ class RSSUtils { static function assign_article_to_label_filters($id, $filters, $owner_uid, $article_labels) { foreach ($filters as $f) { if ($f["type"] == "label") { - if (!RSSUtils::labels_contains_caption($article_labels, $f["param"])) { + if (!self::labels_contains_caption($article_labels, $f["param"])) { Labels::add_article($id, $f["param"], $owner_uid); } } @@ -1477,10 +1582,47 @@ class RSSUtils { $pdo->query("DELETE FROM ttrss_cat_counters_cache"); } + static function disable_failed_feeds() { + if (defined('DAEMON_UNSUCCESSFUL_DAYS_LIMIT') && DAEMON_UNSUCCESSFUL_DAYS_LIMIT > 0) { + + $pdo = Db::pdo(); + + $pdo->beginTransaction(); + + $days = (int) DAEMON_UNSUCCESSFUL_DAYS_LIMIT; + + if (DB_TYPE == "pgsql") { + $interval_query = "last_successful_update < NOW() - INTERVAL '$days days'"; + } else if (DB_TYPE == "mysql") { + $interval_query = "last_successful_update < DATE_SUB(NOW(), INTERVAL $days DAY)"; + } + + $sth = $pdo->prepare("SELECT id, title, owner_uid + FROM ttrss_feeds + WHERE update_interval != -1 AND last_successful_update IS NOT NULL AND $interval_query"); + + $sth->execute(); + + while ($row = $sth->fetch()) { + Logger::get()->log(E_USER_NOTICE, + sprintf("Auto disabling feed %d (%s, UID: %d) because it failed to update for %d days.", + $row["id"], clean($row["title"]), $row["owner_uid"], DAEMON_UNSUCCESSFUL_DAYS_LIMIT)); + + Debug::log(sprintf("Auto-disabling feed %d (failed to update for %d days).", $row["id"], DAEMON_UNSUCCESSFUL_DAYS_LIMIT)); + } + + $sth = $pdo->prepare("UPDATE ttrss_feeds SET update_interval = -1 WHERE + update_interval != -1 AND last_successful_update IS NOT NULL AND $interval_query"); + $sth->execute(); + + $pdo->commit(); + } + } + static function housekeeping_user($owner_uid) { $tmph = new PluginHost(); - load_user_plugins($owner_uid, $tmph); + UserHelper::load_user_plugins($owner_uid, $tmph); $tmph->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", ""); } @@ -1488,13 +1630,15 @@ class RSSUtils { static function housekeeping_common() { DiskCache::expire(); - RSSUtils::expire_lock_files(); - RSSUtils::expire_error_log(); - RSSUtils::expire_feed_archive(); - RSSUtils::cleanup_feed_browser(); + self::expire_lock_files(); + self::expire_error_log(); + self::expire_feed_archive(); + self::cleanup_feed_browser(); + self::cleanup_feed_icons(); + self::disable_failed_feeds(); Article::purge_orphans(); - RSSUtils::cleanup_counters_cache(); + self::cleanup_counters_cache(); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_HOUSE_KEEPING, "hook_house_keeping", ""); } @@ -1505,11 +1649,11 @@ class RSSUtils { $icon_file = ICONS_DIR . "/$feed.ico"; if (!file_exists($icon_file)) { - $favicon_url = RSSUtils::get_favicon_url($site_url); + $favicon_url = self::get_favicon_url($site_url); if ($favicon_url) { // Limiting to "image" type misses those served with text/plain - $contents = fetch_file_contents($favicon_url); // , "image"); + $contents = UrlHelper::fetch($favicon_url); // , "image"); if ($contents) { // Crude image type matching. @@ -1682,7 +1826,7 @@ class RSSUtils { $favicon_url = false; - if ($html = @fetch_file_contents($url)) { + if ($html = @UrlHelper::fetch($url)) { $doc = new DOMDocument(); if ($doc->loadHTML($html)) { @@ -1710,4 +1854,37 @@ class RSSUtils { return $favicon_url; } + // https://community.tt-rss.org/t/problem-with-img-srcset/3519 + static function decode_srcset($srcset) { + $matches = []; + + preg_match_all( + '/(?:\A|,)\s*(?P<url>(?!,)\S+(?<!,))\s*(?P<size>\s\d+w|\s\d+(?:\.\d+)?(?:[eE][+-]?\d+)?x|)\s*(?=,|\Z)/', + $srcset, $matches, PREG_SET_ORDER + ); + + foreach ($matches as $m) { + array_push($matches, [ + "url" => trim($m["url"]), + "size" => trim($m["size"]) + ]); + } + + return $matches; + } + + static function encode_srcset($matches) { + $tokens = []; + + foreach ($matches as $m) { + array_push($tokens, trim($m["url"]) . " " . trim($m["size"])); + } + + return implode(",", $tokens); + } + + static function function_enabled($func) { + return !in_array($func, + explode(',', (string)ini_get('disable_functions'))); + } } diff --git a/classes/sanitizer.php b/classes/sanitizer.php new file mode 100644 index 000000000..9f3bfada0 --- /dev/null +++ b/classes/sanitizer.php @@ -0,0 +1,217 @@ +<?php +class Sanitizer { + private static function strip_harmful_tags($doc, $allowed_elements, $disallowed_attributes) { + $xpath = new DOMXPath($doc); + $entries = $xpath->query('//*'); + + foreach ($entries as $entry) { + if (!in_array($entry->nodeName, $allowed_elements)) { + $entry->parentNode->removeChild($entry); + } + + if ($entry->hasAttributes()) { + $attrs_to_remove = array(); + + foreach ($entry->attributes as $attr) { + + if (strpos($attr->nodeName, 'on') === 0) { + array_push($attrs_to_remove, $attr); + } + + if (strpos($attr->nodeName, "data-") === 0) { + array_push($attrs_to_remove, $attr); + } + + if ($attr->nodeName == 'href' && stripos($attr->value, 'javascript:') === 0) { + array_push($attrs_to_remove, $attr); + } + + if (in_array($attr->nodeName, $disallowed_attributes)) { + array_push($attrs_to_remove, $attr); + } + } + + foreach ($attrs_to_remove as $attr) { + $entry->removeAttributeNode($attr); + } + } + } + + return $doc; + } + + public static function iframe_whitelisted($entry) { + @$src = parse_url($entry->getAttribute("src"), PHP_URL_HOST); + + if ($src) { + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_IFRAME_WHITELISTED) as $plugin) { + if ($plugin->hook_iframe_whitelisted($src)) + return true; + } + } + + return false; + } + + public static function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) { + if (!$owner) $owner = $_SESSION["uid"]; + + $res = trim($str); if (!$res) return ''; + + $doc = new DOMDocument(); + $doc->loadHTML('<?xml encoding="UTF-8">' . $res); + $xpath = new DOMXPath($doc); + + $rewrite_base_url = $site_url ? $site_url : get_self_url_prefix(); + + $entries = $xpath->query('(//a[@href]|//img[@src]|//source[@srcset|@src])'); + + foreach ($entries as $entry) { + + if ($entry->hasAttribute('href')) { + $entry->setAttribute('href', + rewrite_relative_url($rewrite_base_url, $entry->getAttribute('href'))); + + $entry->setAttribute('rel', 'noopener noreferrer'); + $entry->setAttribute("target", "_blank"); + } + + if ($entry->hasAttribute('src')) { + $entry->setAttribute('src', + rewrite_relative_url($rewrite_base_url, $entry->getAttribute('src'))); + } + + if ($entry->nodeName == 'img') { + $entry->setAttribute('referrerpolicy', 'no-referrer'); + $entry->setAttribute('loading', 'lazy'); + } + + if ($entry->hasAttribute('srcset')) { + $matches = RSSUtils::decode_srcset($entry->getAttribute('srcset')); + + for ($i = 0; $i < count($matches); $i++) { + $matches[$i]["url"] = rewrite_relative_url($rewrite_base_url, $matches[$i]["url"]); + } + + $entry->setAttribute("srcset", RSSUtils::encode_srcset($matches)); + } + + if ($entry->hasAttribute('src') && + ($owner && get_pref("STRIP_IMAGES", $owner)) || $force_remove_images || $_SESSION["bw_limit"]) { + + $p = $doc->createElement('p'); + + $a = $doc->createElement('a'); + $a->setAttribute('href', $entry->getAttribute('src')); + + $a->appendChild(new DOMText($entry->getAttribute('src'))); + $a->setAttribute('target', '_blank'); + $a->setAttribute('rel', 'noopener noreferrer'); + + $p->appendChild($a); + + if ($entry->nodeName == 'source') { + + if ($entry->parentNode && $entry->parentNode->parentNode) + $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode); + + } else if ($entry->nodeName == 'img') { + if ($entry->parentNode) + $entry->parentNode->replaceChild($p, $entry); + } + } + } + + $entries = $xpath->query('//iframe'); + foreach ($entries as $entry) { + if (!self::iframe_whitelisted($entry)) { + $entry->setAttribute('sandbox', 'allow-scripts'); + } else { + if (is_prefix_https()) { + $entry->setAttribute("src", + str_replace("http://", "https://", + $entry->getAttribute("src"))); + } + } + } + + $allowed_elements = array('a', 'abbr', 'address', 'acronym', 'audio', 'article', 'aside', + 'b', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', + 'caption', 'cite', 'center', 'code', 'col', 'colgroup', + 'data', 'dd', 'del', 'details', 'description', 'dfn', 'div', 'dl', 'font', + 'dt', 'em', 'footer', 'figure', 'figcaption', + 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'html', 'i', + 'img', 'ins', 'kbd', 'li', 'main', 'mark', 'nav', 'noscript', + 'ol', 'p', 'picture', 'pre', 'q', 'ruby', 'rp', 'rt', 's', 'samp', 'section', + 'small', 'source', 'span', 'strike', 'strong', 'sub', 'summary', + 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', + 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' ); + + if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe'; + + $disallowed_attributes = array('id', 'style', 'class', 'width', 'height', 'allow'); + + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SANITIZE) as $plugin) { + $retval = $plugin->hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id); + if (is_array($retval)) { + $doc = $retval[0]; + $allowed_elements = $retval[1]; + $disallowed_attributes = $retval[2]; + } else { + $doc = $retval; + } + } + + $doc->removeChild($doc->firstChild); //remove doctype + $doc = self::strip_harmful_tags($doc, $allowed_elements, $disallowed_attributes); + + $entries = $xpath->query('//iframe'); + foreach ($entries as $entry) { + $div = $doc->createElement('div'); + $div->setAttribute('class', 'embed-responsive'); + $entry->parentNode->replaceChild($div, $entry); + $div->appendChild($entry); + } + + if ($highlight_words && is_array($highlight_words)) { + foreach ($highlight_words as $word) { + + // http://stackoverflow.com/questions/4081372/highlight-keywords-in-a-paragraph + + $elements = $xpath->query("//*/text()"); + + foreach ($elements as $child) { + + $fragment = $doc->createDocumentFragment(); + $text = $child->textContent; + + while (($pos = mb_stripos($text, $word)) !== false) { + $fragment->appendChild(new DomText(mb_substr($text, 0, $pos))); + $word = mb_substr($text, $pos, mb_strlen($word)); + $highlight = $doc->createElement('span'); + $highlight->appendChild(new DomText($word)); + $highlight->setAttribute('class', 'highlight'); + $fragment->appendChild($highlight); + $text = mb_substr($text, $pos + mb_strlen($word)); + } + + if (!empty($text)) $fragment->appendChild(new DomText($text)); + + $child->parentNode->replaceChild($fragment, $child); + } + } + } + + $res = $doc->saveHTML(); + + /* strip everything outside of <body>...</body> */ + + $res_frag = array(); + if (preg_match('/<body>(.*)<\/body>/is', $res, $res_frag)) { + return $res_frag[1]; + } else { + return $res; + } + } + +} diff --git a/classes/templator.php b/classes/templator.php new file mode 100644 index 000000000..b682f8b82 --- /dev/null +++ b/classes/templator.php @@ -0,0 +1,21 @@ +<?php +require_once "lib/MiniTemplator.class.php"; + +class Templator extends MiniTemplator { + + /* this reads tt-rss template from templates.local/ or templates/ if only base filename is given */ + function readTemplateFromFile ($fileName) { + if (strpos($fileName, "/") === false) { + + $fileName = basename($fileName); + + if (file_exists("templates.local/$fileName")) + return parent::readTemplateFromFile("templates.local/$fileName"); + else + return parent::readTemplateFromFile("templates/$fileName"); + + } else { + return parent::readTemplateFromFile($fileName); + } + } +} diff --git a/classes/timehelper.php b/classes/timehelper.php new file mode 100644 index 000000000..ce9e35f3e --- /dev/null +++ b/classes/timehelper.php @@ -0,0 +1,88 @@ +<?php +class TimeHelper { + + static function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) { + if (!$owner_uid) $owner_uid = $_SESSION['uid']; + + if ($eta_min && time() + $tz_offset - $timestamp < 3600) { + return T_sprintf("%d min", date("i", time() + $tz_offset - $timestamp)); + } else if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) { + $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); + if (strpos((strtolower($format)), "a") === false) + return date("G:i", $timestamp); + else + return date("g:i a", $timestamp); + } else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) { + $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); + return date($format, $timestamp); + } else { + $format = get_pref('LONG_DATE_FORMAT', $owner_uid); + return date($format, $timestamp); + } + } + + static function make_local_datetime($timestamp, $long, $owner_uid = false, + $no_smart_dt = false, $eta_min = false) { + + if (!$owner_uid) $owner_uid = $_SESSION['uid']; + if (!$timestamp) $timestamp = '1970-01-01 0:00'; + + global $utc_tz; + global $user_tz; + + if (!$utc_tz) $utc_tz = new DateTimeZone('UTC'); + + $timestamp = substr($timestamp, 0, 19); + + # We store date in UTC internally + $dt = new DateTime($timestamp, $utc_tz); + + $user_tz_string = get_pref('USER_TIMEZONE', $owner_uid); + + if ($user_tz_string != 'Automatic') { + + try { + if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string); + } catch (Exception $e) { + $user_tz = $utc_tz; + } + + $tz_offset = $user_tz->getOffset($dt); + } else { + $tz_offset = (int) -$_SESSION["clientTzOffset"]; + } + + $user_timestamp = $dt->format('U') + $tz_offset; + + if (!$no_smart_dt) { + return self::smart_date_time($user_timestamp, + $tz_offset, $owner_uid, $eta_min); + } else { + if ($long) + $format = get_pref('LONG_DATE_FORMAT', $owner_uid); + else + $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); + + return date($format, $user_timestamp); + } + } + + static function convert_timestamp($timestamp, $source_tz, $dest_tz) { + + try { + $source_tz = new DateTimeZone($source_tz); + } catch (Exception $e) { + $source_tz = new DateTimeZone('UTC'); + } + + try { + $dest_tz = new DateTimeZone($dest_tz); + } catch (Exception $e) { + $dest_tz = new DateTimeZone('UTC'); + } + + $dt = new DateTime(date('Y-m-d H:i:s', $timestamp), $source_tz); + return $dt->format('U') + $dest_tz->getOffset($dt); + } + +} diff --git a/classes/urlhelper.php b/classes/urlhelper.php new file mode 100644 index 000000000..d7b7d004a --- /dev/null +++ b/classes/urlhelper.php @@ -0,0 +1,489 @@ +<?php +class UrlHelper { + static function build_url($parts) { + $tmp = $parts['scheme'] . "://" . $parts['host'] . $parts['path']; + + if (isset($parts['query'])) $tmp .= '?' . $parts['query']; + if (isset($parts['fragment'])) $tmp .= '#' . $parts['fragment']; + + return $tmp; + } + + /** + * Converts a (possibly) relative URL to a absolute one. + * + * @param string $url Base URL (i.e. from where the document is) + * @param string $rel_url Possibly relative URL in the document + * + * @return string Absolute URL + */ + public static function rewrite_relative($url, $rel_url) { + + $rel_parts = parse_url($rel_url); + + if ($rel_parts['host'] && $rel_parts['scheme']) { + return self::validate($rel_url); + } else if (strpos($rel_url, "//") === 0) { + # protocol-relative URL (rare but they exist) + return self::validate("https:" . $rel_url); + } else if (strpos($rel_url, "magnet:") === 0) { + # allow magnet links + return $rel_url; + } else { + $parts = parse_url($url); + + $rel_parts['host'] = $parts['host']; + $rel_parts['scheme'] = $parts['scheme']; + + if (strpos($rel_parts['path'], '/') !== 0) + $rel_parts['path'] = '/' . $rel_parts['path']; + + $rel_parts['path'] = str_replace("/./", "/", $rel_parts['path']); + $rel_parts['path'] = str_replace("//", "/", $rel_parts['path']); + + return self::validate(self::build_url($rel_parts)); + } + } + + // extended filtering involves validation for safe ports and loopback + static function validate($url, $extended_filtering = false) { + + $url = clean($url); + + # fix protocol-relative URLs + if (strpos($url, "//") === 0) + $url = "https:" . $url; + + $tokens = parse_url($url); + + // this isn't really necessary because filter_var(... FILTER_VALIDATE_URL) requires host and scheme + // as per https://php.watch/versions/7.3/filter-var-flag-deprecation but it might save time + if (!$tokens['host']) + return false; + + if (!in_array(strtolower($tokens['scheme']), ['http', 'https'])) + return false; + + //convert IDNA hostname to punycode if possible + if (function_exists("idn_to_ascii")) { + if (mb_detect_encoding($tokens['host']) != 'ASCII') { + $tokens['host'] = idn_to_ascii($tokens['host']); + } + } + + // separate set of tokens with urlencoded 'path' because filter_var() rightfully fails on non-latin characters + // (used for validation only, we actually request the original URL, in case of urlencode breaking it) + $tokens_filter_var = $tokens; + + if ($tokens['path']) { + $tokens_filter_var['path'] = implode("/", + array_map("rawurlencode", + array_map("rawurldecode", + explode("/", $tokens['path'])))); + } + + $url = self::build_url($tokens); + $url_filter_var = self::build_url($tokens_filter_var); + + if (filter_var($url_filter_var, FILTER_VALIDATE_URL) === false) + return false; + + if ($extended_filtering) { + if (!in_array($tokens['port'], [80, 443, ''])) + return false; + + if (strtolower($tokens['host']) == 'localhost' || $tokens['host'] == '::1' || strpos($tokens['host'], '127.') === 0) + return false; + } + + return $url; + } + + static function resolve_redirects($url, $timeout, $nest = 0) { + + // too many redirects + if ($nest > 10) + return false; + + if (version_compare(PHP_VERSION, '7.1.0', '>=')) { + $context_options = array( + 'http' => array( + 'header' => array( + 'Connection: close' + ), + 'method' => 'HEAD', + 'timeout' => $timeout, + 'protocol_version'=> 1.1) + ); + + if (defined('_HTTP_PROXY')) { + $context_options['http']['request_fulluri'] = true; + $context_options['http']['proxy'] = _HTTP_PROXY; + } + + $context = stream_context_create($context_options); + + $headers = get_headers($url, 0, $context); + } else { + $headers = get_headers($url, 0); + } + + if (is_array($headers)) { + $headers = array_reverse($headers); // last one is the correct one + + foreach($headers as $header) { + if (stripos($header, 'Location:') === 0) { + $url = self::rewrite_relative($url, trim(substr($header, strlen('Location:')))); + + return self::resolve_redirects($url, $timeout, $nest + 1); + } + } + + return $url; + } + + // request failed? + return false; + } + + // TODO: max_size currently only works for CURL transfers + // TODO: multiple-argument way is deprecated, first parameter is a hash now + public static function fetch($options /* previously: 0: $url , 1: $type = false, 2: $login = false, 3: $pass = false, + 4: $post_query = false, 5: $timeout = false, 6: $timestamp = 0, 7: $useragent = false*/) { + + global $fetch_last_error; + global $fetch_last_error_code; + global $fetch_last_error_content; + global $fetch_last_content_type; + global $fetch_last_modified; + global $fetch_effective_url; + global $fetch_effective_ip_addr; + global $fetch_curl_used; + global $fetch_domain_hits; + + $fetch_last_error = false; + $fetch_last_error_code = -1; + $fetch_last_error_content = ""; + $fetch_last_content_type = ""; + $fetch_curl_used = false; + $fetch_last_modified = ""; + $fetch_effective_url = ""; + $fetch_effective_ip_addr = ""; + + if (!is_array($fetch_domain_hits)) + $fetch_domain_hits = []; + + if (!is_array($options)) { + + // falling back on compatibility shim + $option_names = [ "url", "type", "login", "pass", "post_query", "timeout", "last_modified", "useragent" ]; + $tmp = []; + + for ($i = 0; $i < func_num_args(); $i++) { + $tmp[$option_names[$i]] = func_get_arg($i); + } + + $options = $tmp; + + /*$options = array( + "url" => func_get_arg(0), + "type" => @func_get_arg(1), + "login" => @func_get_arg(2), + "pass" => @func_get_arg(3), + "post_query" => @func_get_arg(4), + "timeout" => @func_get_arg(5), + "timestamp" => @func_get_arg(6), + "useragent" => @func_get_arg(7) + ); */ + } + + $url = $options["url"]; + $type = isset($options["type"]) ? $options["type"] : false; + $login = isset($options["login"]) ? $options["login"] : false; + $pass = isset($options["pass"]) ? $options["pass"] : false; + $post_query = isset($options["post_query"]) ? $options["post_query"] : false; + $timeout = isset($options["timeout"]) ? $options["timeout"] : false; + $last_modified = isset($options["last_modified"]) ? $options["last_modified"] : ""; + $useragent = isset($options["useragent"]) ? $options["useragent"] : false; + $followlocation = isset($options["followlocation"]) ? $options["followlocation"] : true; + $max_size = isset($options["max_size"]) ? $options["max_size"] : MAX_DOWNLOAD_FILE_SIZE; // in bytes + $http_accept = isset($options["http_accept"]) ? $options["http_accept"] : false; + $http_referrer = isset($options["http_referrer"]) ? $options["http_referrer"] : false; + + $url = ltrim($url, ' '); + $url = str_replace(' ', '%20', $url); + + $url = self::validate($url, true); + + if (!$url) { + $fetch_last_error = "Requested URL failed extended validation."; + return false; + } + + $url_host = parse_url($url, PHP_URL_HOST); + $ip_addr = gethostbyname($url_host); + + if (!$ip_addr || strpos($ip_addr, "127.") === 0) { + $fetch_last_error = "URL hostname failed to resolve or resolved to a loopback address ($ip_addr)"; + return false; + } + + $fetch_domain_hits[$url_host] += 1; + + /*if ($fetch_domain_hits[$url_host] > MAX_FETCH_REQUESTS_PER_HOST) { + user_error("Exceeded fetch request quota for $url_host: " . $fetch_domain_hits[$url_host], E_USER_WARNING); + #return false; + }*/ + + if (!defined('NO_CURL') && function_exists('curl_init') && !ini_get("open_basedir")) { + + $fetch_curl_used = true; + + $ch = curl_init($url); + + $curl_http_headers = []; + + if ($last_modified && !$post_query) + array_push($curl_http_headers, "If-Modified-Since: $last_modified"); + + if ($http_accept) + array_push($curl_http_headers, "Accept: " . $http_accept); + + if (count($curl_http_headers) > 0) + curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); + + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT); + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir") && $followlocation); + curl_setopt($ch, CURLOPT_MAXREDIRS, 20); + curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HEADER, true); + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); + curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : + SELF_USER_AGENT); + curl_setopt($ch, CURLOPT_ENCODING, ""); + + if ($http_referrer) + curl_setopt($ch, CURLOPT_REFERER, $http_referrer); + + if ($max_size) { + curl_setopt($ch, CURLOPT_NOPROGRESS, false); + curl_setopt($ch, CURLOPT_BUFFERSIZE, 16384); // needed to get 5 arguments in progress function? + + // holy shit closures in php + // download & upload are *expected* sizes respectively, could be zero + curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curl_handle, $download_size, $downloaded, $upload_size, $uploaded) use( &$max_size) { + Debug::log("[curl progressfunction] $downloaded $max_size", Debug::$LOG_EXTENDED); + + return ($downloaded > $max_size) ? 1 : 0; // if max size is set, abort when exceeding it + }); + + } + + if (!ini_get("open_basedir")) { + curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null"); + } + + if (defined('_HTTP_PROXY')) { + curl_setopt($ch, CURLOPT_PROXY, _HTTP_PROXY); + } + + if ($post_query) { + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post_query); + } + + if ($login && $pass) + curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass"); + + $ret = @curl_exec($ch); + + $headers_length = curl_getinfo($ch, CURLINFO_HEADER_SIZE); + $headers = explode("\r\n", substr($ret, 0, $headers_length)); + $contents = substr($ret, $headers_length); + + foreach ($headers as $header) { + if (strstr($header, ": ") !== false) { + list ($key, $value) = explode(": ", $header); + + if (strtolower($key) == "last-modified") { + $fetch_last_modified = $value; + } + } + + if (substr(strtolower($header), 0, 7) == 'http/1.') { + $fetch_last_error_code = (int) substr($header, 9, 3); + $fetch_last_error = $header; + } + } + + if (curl_errno($ch) === 23 || curl_errno($ch) === 61) { + curl_setopt($ch, CURLOPT_ENCODING, 'none'); + $contents = @curl_exec($ch); + } + + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $fetch_last_content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); + + $fetch_effective_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); + + if (!self::validate($fetch_effective_url, true)) { + $fetch_last_error = "URL received after redirection failed extended validation."; + + return false; + } + + $fetch_effective_ip_addr = gethostbyname(parse_url($fetch_effective_url, PHP_URL_HOST)); + + if (!$fetch_effective_ip_addr || strpos($fetch_effective_ip_addr, "127.") === 0) { + $fetch_last_error = "URL hostname received after redirection failed to resolve or resolved to a loopback address ($fetch_effective_ip_addr)"; + + return false; + } + + $fetch_last_error_code = $http_code; + + if ($http_code != 200 || $type && strpos($fetch_last_content_type, "$type") === false) { + + if (curl_errno($ch) != 0) { + $fetch_last_error .= "; " . curl_errno($ch) . " " . curl_error($ch); + } + + $fetch_last_error_content = $contents; + curl_close($ch); + return false; + } + + if (!$contents) { + $fetch_last_error = curl_errno($ch) . " " . curl_error($ch); + curl_close($ch); + return false; + } + + curl_close($ch); + + $is_gzipped = RSSUtils::is_gzipped($contents); + + if ($is_gzipped) { + $tmp = @gzdecode($contents); + + if ($tmp) $contents = $tmp; + } + + return $contents; + } else { + + $fetch_curl_used = false; + + if ($login && $pass){ + $url_parts = array(); + + preg_match("/(^[^:]*):\/\/(.*)/", $url, $url_parts); + + $pass = urlencode($pass); + + if ($url_parts[1] && $url_parts[2]) { + $url = $url_parts[1] . "://$login:$pass@" . $url_parts[2]; + } + } + + // TODO: should this support POST requests or not? idk + + $context_options = array( + 'http' => array( + 'header' => array( + 'Connection: close' + ), + 'method' => 'GET', + 'ignore_errors' => true, + 'timeout' => $timeout ? $timeout : FILE_FETCH_TIMEOUT, + 'protocol_version'=> 1.1) + ); + + if (!$post_query && $last_modified) + array_push($context_options['http']['header'], "If-Modified-Since: $last_modified"); + + if ($http_accept) + array_push($context_options['http']['header'], "Accept: $http_accept"); + + if ($http_referrer) + array_push($context_options['http']['header'], "Referer: $http_referrer"); + + if (defined('_HTTP_PROXY')) { + $context_options['http']['request_fulluri'] = true; + $context_options['http']['proxy'] = _HTTP_PROXY; + } + + $context = stream_context_create($context_options); + + $old_error = error_get_last(); + + $fetch_effective_url = self::resolve_redirects($url, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT); + + if (!self::validate($fetch_effective_url, true)) { + $fetch_last_error = "URL received after redirection failed extended validation."; + + return false; + } + + $fetch_effective_ip_addr = gethostbyname(parse_url($fetch_effective_url, PHP_URL_HOST)); + + if (!$fetch_effective_ip_addr || strpos($fetch_effective_ip_addr, "127.") === 0) { + $fetch_last_error = "URL hostname received after redirection failed to resolve or resolved to a loopback address ($fetch_effective_ip_addr)"; + + return false; + } + + $data = @file_get_contents($url, false, $context); + + if (isset($http_response_header) && is_array($http_response_header)) { + foreach ($http_response_header as $header) { + if (strstr($header, ": ") !== false) { + list ($key, $value) = explode(": ", $header); + + $key = strtolower($key); + + if ($key == 'content-type') { + $fetch_last_content_type = $value; + // don't abort here b/c there might be more than one + // e.g. if we were being redirected -- last one is the right one + } else if ($key == 'last-modified') { + $fetch_last_modified = $value; + } else if ($key == 'location') { + $fetch_effective_url = $value; + } + } + + if (substr(strtolower($header), 0, 7) == 'http/1.') { + $fetch_last_error_code = (int) substr($header, 9, 3); + $fetch_last_error = $header; + } + } + } + + if ($fetch_last_error_code != 200) { + $error = error_get_last(); + + if ($error['message'] != $old_error['message']) { + $fetch_last_error .= "; " . $error["message"]; + } + + $fetch_last_error_content = $data; + + return false; + } + + $is_gzipped = RSSUtils::is_gzipped($data); + + if ($is_gzipped) { + $tmp = @gzdecode($data); + + if ($tmp) $data = $tmp; + } + + return $data; + } + } + +} diff --git a/classes/userhelper.php b/classes/userhelper.php new file mode 100644 index 000000000..fd0b0ac57 --- /dev/null +++ b/classes/userhelper.php @@ -0,0 +1,141 @@ +<?php +class UserHelper { + + static function authenticate($login, $password, $check_only = false, $service = false) { + + if (!SINGLE_USER_MODE) { + $user_id = false; + $auth_module = false; + + foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_AUTH_USER) as $plugin) { + + $user_id = (int) $plugin->authenticate($login, $password, $service); + + if ($user_id) { + $auth_module = strtolower(get_class($plugin)); + break; + } + } + + if ($user_id && !$check_only) { + + session_start(); + session_regenerate_id(true); + + $_SESSION["uid"] = $user_id; + $_SESSION["auth_module"] = $auth_module; + + $pdo = Db::pdo(); + $sth = $pdo->prepare("SELECT login,access_level,pwd_hash FROM ttrss_users + WHERE id = ?"); + $sth->execute([$user_id]); + $row = $sth->fetch(); + + $_SESSION["name"] = $row["login"]; + $_SESSION["access_level"] = $row["access_level"]; + $_SESSION["csrf_token"] = bin2hex(get_random_bytes(16)); + + $usth = $pdo->prepare("UPDATE ttrss_users SET last_login = NOW() WHERE id = ?"); + $usth->execute([$user_id]); + + $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"]; + $_SESSION["user_agent"] = sha1($_SERVER['HTTP_USER_AGENT']); + $_SESSION["pwd_hash"] = $row["pwd_hash"]; + + Pref_Prefs::initialize_user_prefs($_SESSION["uid"]); + + return true; + } + + return false; + + } else { + + $_SESSION["uid"] = 1; + $_SESSION["name"] = "admin"; + $_SESSION["access_level"] = 10; + + $_SESSION["hide_hello"] = true; + $_SESSION["hide_logout"] = true; + + $_SESSION["auth_module"] = false; + + if (!$_SESSION["csrf_token"]) + $_SESSION["csrf_token"] = bin2hex(get_random_bytes(16)); + + $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"]; + + Pref_Prefs::initialize_user_prefs($_SESSION["uid"]); + + return true; + } + } + + static function load_user_plugins($owner_uid, $pluginhost = false) { + + if (!$pluginhost) $pluginhost = PluginHost::getInstance(); + + if ($owner_uid && SCHEMA_VERSION >= 100 && !$_SESSION["safe_mode"]) { + $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); + + $pluginhost->load($plugins, PluginHost::KIND_USER, $owner_uid); + + if (get_schema_version() > 100) { + $pluginhost->load_data(); + } + } + } + + static function login_sequence() { + $pdo = Db::pdo(); + + if (SINGLE_USER_MODE) { + @session_start(); + self::authenticate("admin", null); + startup_gettext(); + self::load_user_plugins($_SESSION["uid"]); + } else { + if (!validate_session()) $_SESSION["uid"] = false; + + if (!$_SESSION["uid"]) { + + if (AUTH_AUTO_LOGIN && self::authenticate(null, null)) { + $_SESSION["ref_schema_version"] = get_schema_version(true); + } else { + self::authenticate(null, null, true); + } + + if (!$_SESSION["uid"]) { + Pref_Users::logout_user(); + + Handler_Public::render_login_form(); + exit; + } + + } else { + /* bump login timestamp */ + $sth = $pdo->prepare("UPDATE ttrss_users SET last_login = NOW() WHERE id = ?"); + $sth->execute([$_SESSION['uid']]); + + $_SESSION["last_login_update"] = time(); + } + + if ($_SESSION["uid"]) { + startup_gettext(); + self::load_user_plugins($_SESSION["uid"]); + } + } + } + + static function print_user_stylesheet() { + $value = get_pref('USER_STYLESHEET'); + + if ($value) { + print "<style type='text/css' id='user_css_style'>"; + print str_replace("<br/>", "\n", $value); + print "</style>"; + } + + } + +} diff --git a/config.php-dist b/config.php-dist index 244390b98..ae34b4f15 100755..100644 --- a/config.php-dist +++ b/config.php-dist @@ -3,12 +3,12 @@ // *** Database configuration (important!) *** // ******************************************* - define('DB_TYPE', "pgsql"); // or mysql - define('DB_HOST', "localhost"); - define('DB_USER', "fox"); - define('DB_NAME', "fox"); - define('DB_PASS', "XXXXXX"); - define('DB_PORT', ''); // usually 5432 for PostgreSQL, 3306 for MySQL + define('DB_TYPE', '%DB_TYPE'); // pgsql or mysql + define('DB_HOST', '%DB_HOST'); + define('DB_USER', '%DB_USER'); + define('DB_NAME', '%DB_NAME'); + define('DB_PASS', '%DB_PASS'); + define('DB_PORT', '%DB_PORT'); // usually 5432 for PostgreSQL, 3306 for MySQL define('MYSQL_CHARSET', 'UTF8'); // Connection charset for MySQL. If you have a legacy database and/or experience @@ -18,9 +18,9 @@ // *** Basic settings (important!) *** // *********************************** - define('SELF_URL_PATH', 'https://example.org/tt-rss/'); + define('SELF_URL_PATH', '%SELF_URL_PATH'); // This should be set to a fully qualified URL used to access - // your tt-rss instance over the net. + // your tt-rss instance over the net, such as: https://example.org/tt-rss/ // The value should be a constant string literal. Please don't use // PHP server variables here - you might introduce security // issues on your install and cause hard to debug problems. @@ -38,7 +38,7 @@ // background processes while not running tt-rss, this method is generally // viable to keep your feeds up to date. // Still, there are more robust (and recommended) updating methods - // available, you can read about them here: http://tt-rss.org/wiki/UpdatingFeeds + // available, you can read about them here: https://tt-rss.org/wiki/UpdatingFeeds // ***************************** // *** Files and directories *** diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 000000000..e04cc85d0 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,31 @@ +// Less configuration +const gulp = require('gulp'); +const less = require('gulp-less'); + +function swallowError(error) { + console.log(error.toString()) + + this.emit('end') +} + +gulp.task('less', function(cb) { + gulp + .src(['themes/compact.less', 'themes/compact_night.less', + 'themes/light.less', 'themes/night_blue.less', 'themes/night.less']) + .pipe(less()) + .on('error', swallowError) + .pipe( + gulp.dest(function(f) { + return f.base; + }) + ); + cb(); +}); + +gulp.task( + 'default', + gulp.series('less', function(cb) { + gulp.watch(['themes/*.less', 'themes/*/*.less'], gulp.series('less')); + cb(); + }) +); diff --git a/include/autoload.php b/include/autoload.php index 1f1dbe5e9..c02923dba 100644 --- a/include/autoload.php +++ b/include/autoload.php @@ -5,7 +5,7 @@ $namespace = ''; $class_name = $class; - if (strpos($class, '\\') !== FALSE) + if (strpos($class, '\\') !== false) list ($namespace, $class_name) = explode('\\', $class, 2); $root_dir = dirname(__DIR__); // we're in tt-rss/include diff --git a/include/controls.php b/include/controls.php index 8646ec15d..fdcaad287 100755 --- a/include/controls.php +++ b/include/controls.php @@ -74,7 +74,7 @@ function print_feed_multi_select($id, $default_ids = [], $attributes = "", $include_all_feeds = true, $root_id = null, $nest_level = 0) { - $pdo = DB::pdo(); + $pdo = Db::pdo(); print_r(in_array("CAT:6",$default_ids)); @@ -180,7 +180,7 @@ function print_feed_cat_select($id, $default_id, print "<select id=\"$id\" name=\"$id\" default=\"$default_id\" $attributes>"; } - $pdo = DB::pdo(); + $pdo = Db::pdo(); if (!$root_id) $root_id = null; @@ -244,7 +244,7 @@ function stylesheet_tag($filename, $id = false) { function javascript_tag($filename) { $query = ""; - if (!(strpos($filename, "?") === FALSE)) { + if (!(strpos($filename, "?") === false)) { $query = substr($filename, strpos($filename, "?")+1); $filename = substr($filename, 0, strpos($filename, "?")); } diff --git a/include/functions.php b/include/functions.php index 3e37d1d28..6a7ad671d 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1,6 +1,6 @@ <?php define('EXPECTED_CONFIG_VERSION', 26); - define('SCHEMA_VERSION', 139); + define('SCHEMA_VERSION', 140); define('LABEL_BASE_INDEX', -1024); define('PLUGIN_FEED_BASE_INDEX', -128); @@ -72,6 +72,9 @@ // this is used to not cause excessive load on the origin server on // e.g. feed subscription when all articles are being processes // (not implemented) + define_default('DAEMON_UNSUCCESSFUL_DAYS_LIMIT', 30); + // automatically disable updates for feeds which failed to + // update for this amount of days; 0 disables /* tunables end here */ @@ -122,7 +125,7 @@ } require_once "lib/accept-to-gettext.php"; - require_once "lib/gettext/gettext.inc"; + require_once "lib/gettext/gettext.inc.php"; function startup_gettext() { @@ -162,369 +165,54 @@ $schema_version = false; - // TODO: compat wrapper, remove at some point + /* compat shims */ + function _debug($msg) { Debug::log($msg); } - function reset_fetch_domain_quota() { - global $fetch_domain_hits; - - $fetch_domain_hits = []; + // @deprecated + function getFeedUnread($feed, $is_cat = false) { + return Feeds::getFeedArticles($feed, $is_cat, true, $_SESSION["uid"]); } - // TODO: max_size currently only works for CURL transfers - // TODO: multiple-argument way is deprecated, first parameter is a hash now - function fetch_file_contents($options /* previously: 0: $url , 1: $type = false, 2: $login = false, 3: $pass = false, - 4: $post_query = false, 5: $timeout = false, 6: $timestamp = 0, 7: $useragent = false*/) { - - global $fetch_last_error; - global $fetch_last_error_code; - global $fetch_last_error_content; - global $fetch_last_content_type; - global $fetch_last_modified; - global $fetch_effective_url; - global $fetch_curl_used; - global $fetch_domain_hits; - - $fetch_last_error = false; - $fetch_last_error_code = -1; - $fetch_last_error_content = ""; - $fetch_last_content_type = ""; - $fetch_curl_used = false; - $fetch_last_modified = ""; - $fetch_effective_url = ""; - - if (!is_array($fetch_domain_hits)) - $fetch_domain_hits = []; - - if (!is_array($options)) { - - // falling back on compatibility shim - $option_names = [ "url", "type", "login", "pass", "post_query", "timeout", "last_modified", "useragent" ]; - $tmp = []; - - for ($i = 0; $i < func_num_args(); $i++) { - $tmp[$option_names[$i]] = func_get_arg($i); - } - - $options = $tmp; - - /*$options = array( - "url" => func_get_arg(0), - "type" => @func_get_arg(1), - "login" => @func_get_arg(2), - "pass" => @func_get_arg(3), - "post_query" => @func_get_arg(4), - "timeout" => @func_get_arg(5), - "timestamp" => @func_get_arg(6), - "useragent" => @func_get_arg(7) - ); */ - } - - $url = $options["url"]; - $type = isset($options["type"]) ? $options["type"] : false; - $login = isset($options["login"]) ? $options["login"] : false; - $pass = isset($options["pass"]) ? $options["pass"] : false; - $post_query = isset($options["post_query"]) ? $options["post_query"] : false; - $timeout = isset($options["timeout"]) ? $options["timeout"] : false; - $last_modified = isset($options["last_modified"]) ? $options["last_modified"] : ""; - $useragent = isset($options["useragent"]) ? $options["useragent"] : false; - $followlocation = isset($options["followlocation"]) ? $options["followlocation"] : true; - $max_size = isset($options["max_size"]) ? $options["max_size"] : MAX_DOWNLOAD_FILE_SIZE; // in bytes - $http_accept = isset($options["http_accept"]) ? $options["http_accept"] : false; - $http_referrer = isset($options["http_referrer"]) ? $options["http_referrer"] : false; - - $url = ltrim($url, ' '); - $url = str_replace(' ', '%20', $url); - - if (strpos($url, "//") === 0) - $url = 'http:' . $url; - - $url_host = parse_url($url, PHP_URL_HOST); - $fetch_domain_hits[$url_host] += 1; - - /*if ($fetch_domain_hits[$url_host] > MAX_FETCH_REQUESTS_PER_HOST) { - user_error("Exceeded fetch request quota for $url_host: " . $fetch_domain_hits[$url_host], E_USER_WARNING); - #return false; - }*/ - - if (!defined('NO_CURL') && function_exists('curl_init') && !ini_get("open_basedir")) { - - $fetch_curl_used = true; - - $ch = curl_init($url); - - $curl_http_headers = []; - - if ($last_modified && !$post_query) - array_push($curl_http_headers, "If-Modified-Since: $last_modified"); - - if ($http_accept) - array_push($curl_http_headers, "Accept: " . $http_accept); - - if (count($curl_http_headers) > 0) - curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_http_headers); - - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : FILE_FETCH_CONNECT_TIMEOUT); - curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : FILE_FETCH_TIMEOUT); - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir") && $followlocation); - curl_setopt($ch, CURLOPT_MAXREDIRS, 20); - curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_HEADER, true); - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); - curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : - SELF_USER_AGENT); - curl_setopt($ch, CURLOPT_ENCODING, ""); - - if ($http_referrer) - curl_setopt($ch, CURLOPT_REFERER, $http_referrer); - - if ($max_size) { - curl_setopt($ch, CURLOPT_NOPROGRESS, false); - curl_setopt($ch, CURLOPT_BUFFERSIZE, 16384); // needed to get 5 arguments in progress function? - - // holy shit closures in php - // download & upload are *expected* sizes respectively, could be zero - curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, function($curl_handle, $download_size, $downloaded, $upload_size, $uploaded) use( &$max_size) { - Debug::log("[curl progressfunction] $downloaded $max_size", Debug::$LOG_EXTENDED); - - return ($downloaded > $max_size) ? 1 : 0; // if max size is set, abort when exceeding it - }); - - } - - if (!ini_get("open_basedir")) { - curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null"); - } - - if (defined('_HTTP_PROXY')) { - curl_setopt($ch, CURLOPT_PROXY, _HTTP_PROXY); - } - - if ($post_query) { - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $post_query); - } - - if ($login && $pass) - curl_setopt($ch, CURLOPT_USERPWD, "$login:$pass"); - - $ret = @curl_exec($ch); - - $headers_length = curl_getinfo($ch, CURLINFO_HEADER_SIZE); - $headers = explode("\r\n", substr($ret, 0, $headers_length)); - $contents = substr($ret, $headers_length); - - foreach ($headers as $header) { - if (strstr($header, ": ") !== FALSE) { - list ($key, $value) = explode(": ", $header); - - if (strtolower($key) == "last-modified") { - $fetch_last_modified = $value; - } - } - - if (substr(strtolower($header), 0, 7) == 'http/1.') { - $fetch_last_error_code = (int) substr($header, 9, 3); - $fetch_last_error = $header; - } - } - - if (curl_errno($ch) === 23 || curl_errno($ch) === 61) { - curl_setopt($ch, CURLOPT_ENCODING, 'none'); - $contents = @curl_exec($ch); - } - - $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); - $fetch_last_content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); - - $fetch_effective_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); - - $fetch_last_error_code = $http_code; - - if ($http_code != 200 || $type && strpos($fetch_last_content_type, "$type") === false) { - - if (curl_errno($ch) != 0) { - $fetch_last_error .= "; " . curl_errno($ch) . " " . curl_error($ch); - } - - $fetch_last_error_content = $contents; - curl_close($ch); - return false; - } - - if (!$contents) { - $fetch_last_error = curl_errno($ch) . " " . curl_error($ch); - curl_close($ch); - return false; - } - - curl_close($ch); - - $is_gzipped = RSSUtils::is_gzipped($contents); - - if ($is_gzipped) { - $tmp = @gzdecode($contents); - - if ($tmp) $contents = $tmp; - } - - return $contents; - } else { - - $fetch_curl_used = false; - - if ($login && $pass){ - $url_parts = array(); - - preg_match("/(^[^:]*):\/\/(.*)/", $url, $url_parts); - - $pass = urlencode($pass); - - if ($url_parts[1] && $url_parts[2]) { - $url = $url_parts[1] . "://$login:$pass@" . $url_parts[2]; - } - } - - // TODO: should this support POST requests or not? idk - - $context_options = array( - 'http' => array( - 'header' => array( - 'Connection: close' - ), - 'method' => 'GET', - 'ignore_errors' => true, - 'timeout' => $timeout ? $timeout : FILE_FETCH_TIMEOUT, - 'protocol_version'=> 1.1) - ); - - if (!$post_query && $last_modified) - array_push($context_options['http']['header'], "If-Modified-Since: $last_modified"); - - if ($http_accept) - array_push($context_options['http']['header'], "Accept: $http_accept"); - - if ($http_referrer) - array_push($context_options['http']['header'], "Referer: $http_referrer"); - - if (defined('_HTTP_PROXY')) { - $context_options['http']['request_fulluri'] = true; - $context_options['http']['proxy'] = _HTTP_PROXY; - } - - $context = stream_context_create($context_options); - - $old_error = error_get_last(); - - $fetch_effective_url = $url; - - $data = @file_get_contents($url, false, $context); - - if (isset($http_response_header) && is_array($http_response_header)) { - foreach ($http_response_header as $header) { - if (strstr($header, ": ") !== FALSE) { - list ($key, $value) = explode(": ", $header); - - $key = strtolower($key); - - if ($key == 'content-type') { - $fetch_last_content_type = $value; - // don't abort here b/c there might be more than one - // e.g. if we were being redirected -- last one is the right one - } else if ($key == 'last-modified') { - $fetch_last_modified = $value; - } else if ($key == 'location') { - $fetch_effective_url = $value; - } - } - - if (substr(strtolower($header), 0, 7) == 'http/1.') { - $fetch_last_error_code = (int) substr($header, 9, 3); - $fetch_last_error = $header; - } - } - } - - if ($fetch_last_error_code != 200) { - $error = error_get_last(); - - if ($error['message'] != $old_error['message']) { - $fetch_last_error .= "; " . $error["message"]; - } - - $fetch_last_error_content = $data; - - return false; - } - - $is_gzipped = RSSUtils::is_gzipped($data); - - if ($is_gzipped) { - $tmp = @gzdecode($data); - - if ($tmp) $data = $tmp; - } - - return $data; - } - + // @deprecated + function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) { + return Sanitizer::sanitize($str, $force_remove_images, $owner, $site_url, $highlight_words, $article_id); } - function initialize_user_prefs($uid, $profile = false) { - - if (get_schema_version() < 63) $profile_qpart = ""; - - $pdo = DB::pdo(); - $in_nested_tr = false; - - try { - $pdo->beginTransaction(); - } catch (Exception $e) { - $in_nested_tr = true; - } - - $sth = $pdo->query("SELECT pref_name,def_value FROM ttrss_prefs"); - - if (!is_numeric($profile) || !$profile || get_schema_version() < 63) $profile = null; - - $u_sth = $pdo->prepare("SELECT pref_name - FROM ttrss_user_prefs WHERE owner_uid = :uid AND - (profile = :profile OR (:profile IS NULL AND profile IS NULL))"); - $u_sth->execute([':uid' => $uid, ':profile' => $profile]); - - $active_prefs = array(); - - while ($line = $u_sth->fetch()) { - array_push($active_prefs, $line["pref_name"]); - } - - while ($line = $sth->fetch()) { - if (array_search($line["pref_name"], $active_prefs) === FALSE) { -// print "adding " . $line["pref_name"] . "<br>"; + // @deprecated + function fetch_file_contents($params) { + return UrlHelper::fetch($params); + } - if (get_schema_version() < 63) { - $i_sth = $pdo->prepare("INSERT INTO ttrss_user_prefs - (owner_uid,pref_name,value) VALUES - (?, ?, ?)"); - $i_sth->execute([$uid, $line["pref_name"], $line["def_value"]]); + // @deprecated + function rewrite_relative_url($url, $rel_url) { + return UrlHelper::rewrite_relative($url, $rel_url); + } - } else { - $i_sth = $pdo->prepare("INSERT INTO ttrss_user_prefs - (owner_uid,pref_name,value, profile) VALUES - (?, ?, ?, ?)"); - $i_sth->execute([$uid, $line["pref_name"], $line["def_value"], $profile]); - } + // @deprecated + function validate_url($url) { + return UrlHelper::validate($url); + } - } - } + // @deprecated + function authenticate_user($login, $password, $check_only = false, $service = false) { + return UserHelper::authenticate($login, $password, $check_only, $service); + } - if (!$in_nested_tr) $pdo->commit(); + // @deprecated + function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) { + return TimeHelper::smart_date_time($timestamp, $tz_offset, $owner_uid, $eta_min); + } + // @deprecated + function make_local_datetime($timestamp, $long, $owner_uid = false, $no_smart_dt = false, $eta_min = false) { + return TimeHelper::make_local_datetime($timestamp, $long, $owner_uid, $no_smart_dt, $eta_min); } + /* end compat shims */ + function get_ssl_certificate_id() { if ($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"]) { return sha1($_SERVER["REDIRECT_SSL_CLIENT_M_SERIAL"] . @@ -541,77 +229,6 @@ return ""; } - function authenticate_user($login, $password, $check_only = false, $service = false) { - - if (!SINGLE_USER_MODE) { - $user_id = false; - $auth_module = false; - - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_AUTH_USER) as $plugin) { - - $user_id = (int) $plugin->authenticate($login, $password, $service); - - if ($user_id) { - $auth_module = strtolower(get_class($plugin)); - break; - } - } - - if ($user_id && !$check_only) { - - session_start(); - session_regenerate_id(true); - - $_SESSION["uid"] = $user_id; - $_SESSION["auth_module"] = $auth_module; - - $pdo = DB::pdo(); - $sth = $pdo->prepare("SELECT login,access_level,pwd_hash FROM ttrss_users - WHERE id = ?"); - $sth->execute([$user_id]); - $row = $sth->fetch(); - - $_SESSION["name"] = $row["login"]; - $_SESSION["access_level"] = $row["access_level"]; - $_SESSION["csrf_token"] = uniqid_short(); - - $usth = $pdo->prepare("UPDATE ttrss_users SET last_login = NOW() WHERE id = ?"); - $usth->execute([$user_id]); - - $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"]; - $_SESSION["user_agent"] = sha1($_SERVER['HTTP_USER_AGENT']); - $_SESSION["pwd_hash"] = $row["pwd_hash"]; - - initialize_user_prefs($_SESSION["uid"]); - - return true; - } - - return false; - - } else { - - $_SESSION["uid"] = 1; - $_SESSION["name"] = "admin"; - $_SESSION["access_level"] = 10; - - $_SESSION["hide_hello"] = true; - $_SESSION["hide_logout"] = true; - - $_SESSION["auth_module"] = false; - - if (!$_SESSION["csrf_token"]) { - $_SESSION["csrf_token"] = uniqid_short(); - } - - $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"]; - - initialize_user_prefs($_SESSION["uid"]); - - return true; - } - } - // this is used for user http parameters unless HTML code is actually needed function clean($param) { if (is_array($param)) { @@ -623,10 +240,6 @@ } } - function clean_filename($filename) { - return basename(preg_replace("/\.\.|[\/\\\]/", "", clean($filename))); - } - function make_password($length = 12) { $password = ""; $possible = "0123456789abcdfghjkmnpqrstvwxyzABCDFGHJKMNPQRSTVWXYZ*%+^"; @@ -652,87 +265,8 @@ return $password; } - // this is called after user is created to initialize default feeds, labels - // or whatever else - - // user preferences are checked on every login, not here - - function initialize_user($uid) { - - $pdo = DB::pdo(); - - $sth = $pdo->prepare("insert into ttrss_feeds (owner_uid,title,feed_url) - values (?, 'Tiny Tiny RSS: Forum', - 'http://tt-rss.org/forum/rss.php')"); - $sth->execute([$uid]); - } - - function logout_user() { - @session_destroy(); - if (isset($_COOKIE[session_name()])) { - setcookie(session_name(), '', time()-42000, '/'); - } - session_commit(); - } - function validate_csrf($csrf_token) { - return $csrf_token == $_SESSION['csrf_token']; - } - - function load_user_plugins($owner_uid, $pluginhost = false) { - - if (!$pluginhost) $pluginhost = PluginHost::getInstance(); - - if ($owner_uid && SCHEMA_VERSION >= 100) { - $plugins = get_pref("_ENABLED_PLUGINS", $owner_uid); - - $pluginhost->load($plugins, PluginHost::KIND_USER, $owner_uid); - - if (get_schema_version() > 100) { - $pluginhost->load_data(); - } - } - } - - function login_sequence() { - $pdo = Db::pdo(); - - if (SINGLE_USER_MODE) { - @session_start(); - authenticate_user("admin", null); - startup_gettext(); - load_user_plugins($_SESSION["uid"]); - } else { - if (!validate_session()) $_SESSION["uid"] = false; - - if (!$_SESSION["uid"]) { - - if (AUTH_AUTO_LOGIN && authenticate_user(null, null)) { - $_SESSION["ref_schema_version"] = get_schema_version(true); - } else { - authenticate_user(null, null, true); - } - - if (!$_SESSION["uid"]) { - logout_user(); - - render_login_form(); - exit; - } - - } else { - /* bump login timestamp */ - $sth = $pdo->prepare("UPDATE ttrss_users SET last_login = NOW() WHERE id = ?"); - $sth->execute([$_SESSION['uid']]); - - $_SESSION["last_login_update"] = time(); - } - - if ($_SESSION["uid"]) { - startup_gettext(); - load_user_plugins($_SESSION["uid"]); - } - } + return isset($csrf_token) && hash_equals($_SESSION['csrf_token'], $csrf_token); } function truncate_string($str, $max_len, $suffix = '…') { @@ -760,90 +294,6 @@ } } - function convert_timestamp($timestamp, $source_tz, $dest_tz) { - - try { - $source_tz = new DateTimeZone($source_tz); - } catch (Exception $e) { - $source_tz = new DateTimeZone('UTC'); - } - - try { - $dest_tz = new DateTimeZone($dest_tz); - } catch (Exception $e) { - $dest_tz = new DateTimeZone('UTC'); - } - - $dt = new DateTime(date('Y-m-d H:i:s', $timestamp), $source_tz); - return $dt->format('U') + $dest_tz->getOffset($dt); - } - - function make_local_datetime($timestamp, $long, $owner_uid = false, - $no_smart_dt = false, $eta_min = false) { - - if (!$owner_uid) $owner_uid = $_SESSION['uid']; - if (!$timestamp) $timestamp = '1970-01-01 0:00'; - - global $utc_tz; - global $user_tz; - - if (!$utc_tz) $utc_tz = new DateTimeZone('UTC'); - - $timestamp = substr($timestamp, 0, 19); - - # We store date in UTC internally - $dt = new DateTime($timestamp, $utc_tz); - - $user_tz_string = get_pref('USER_TIMEZONE', $owner_uid); - - if ($user_tz_string != 'Automatic') { - - try { - if (!$user_tz) $user_tz = new DateTimeZone($user_tz_string); - } catch (Exception $e) { - $user_tz = $utc_tz; - } - - $tz_offset = $user_tz->getOffset($dt); - } else { - $tz_offset = (int) -$_SESSION["clientTzOffset"]; - } - - $user_timestamp = $dt->format('U') + $tz_offset; - - if (!$no_smart_dt) { - return smart_date_time($user_timestamp, - $tz_offset, $owner_uid, $eta_min); - } else { - if ($long) - $format = get_pref('LONG_DATE_FORMAT', $owner_uid); - else - $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); - - return date($format, $user_timestamp); - } - } - - function smart_date_time($timestamp, $tz_offset = 0, $owner_uid = false, $eta_min = false) { - if (!$owner_uid) $owner_uid = $_SESSION['uid']; - - if ($eta_min && time() + $tz_offset - $timestamp < 3600) { - return T_sprintf("%d min", date("i", time() + $tz_offset - $timestamp)); - } else if (date("Y.m.d", $timestamp) == date("Y.m.d", time() + $tz_offset)) { - $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); - if (strpos((strtolower($format)), "a") === false) - return date("G:i", $timestamp); - else - return date("g:i a", $timestamp); - } else if (date("Y", $timestamp) == date("Y", time() + $tz_offset)) { - $format = get_pref('SHORT_DATE_FORMAT', $owner_uid); - return date($format, $timestamp); - } else { - $format = get_pref('LONG_DATE_FORMAT', $owner_uid); - return date($format, $timestamp); - } - } - function sql_bool_to_bool($s) { return $s && ($s !== "f" && $s !== "false"); //no-op for PDO, backwards compat for legacy layer } @@ -858,7 +308,7 @@ function get_schema_version($nocache = false) { global $schema_version; - $pdo = DB::pdo(); + $pdo = Db::pdo(); if (!$schema_version && !$nocache) { $row = $pdo->query("SELECT schema_version FROM ttrss_version")->fetch(); @@ -906,7 +356,6 @@ } } - function make_lockfile($filename) { $fp = fopen(LOCK_DIRECTORY . "/$filename", "w"); @@ -931,31 +380,6 @@ } } - function make_stampfile($filename) { - $fp = fopen(LOCK_DIRECTORY . "/$filename", "w"); - - if (flock($fp, LOCK_EX | LOCK_NB)) { - fwrite($fp, time() . "\n"); - flock($fp, LOCK_UN); - fclose($fp); - return true; - } else { - return false; - } - } - - function sql_random_function() { - if (DB_TYPE == "mysql") { - return "RAND()"; - } else { - return "RANDOM()"; - } - } - - function getFeedUnread($feed, $is_cat = false) { - return Feeds::getFeedArticles($feed, $is_cat, true, $_SESSION["uid"]); - } - function checkbox_to_sql_bool($val) { return ($val == "on") ? 1 : 0; } @@ -964,526 +388,17 @@ return uniqid(base_convert(rand(), 10, 36)); } - function make_init_params() { - $params = array(); - - foreach (array("ON_CATCHUP_SHOW_NEXT_FEED", "HIDE_READ_FEEDS", - "ENABLE_FEED_CATS", "FEEDS_SORT_BY_UNREAD", "CONFIRM_FEED_CATCHUP", - "CDM_AUTO_CATCHUP", "FRESH_ARTICLE_MAX_AGE", - "HIDE_READ_SHOWS_SPECIAL", "COMBINED_DISPLAY_MODE") as $param) { - - $params[strtolower($param)] = (int) get_pref($param); - } - - $params["check_for_updates"] = CHECK_FOR_UPDATES; - $params["icons_url"] = ICONS_URL; - $params["cookie_lifetime"] = SESSION_COOKIE_LIFETIME; - $params["default_view_mode"] = get_pref("_DEFAULT_VIEW_MODE"); - $params["default_view_limit"] = (int) get_pref("_DEFAULT_VIEW_LIMIT"); - $params["default_view_order_by"] = get_pref("_DEFAULT_VIEW_ORDER_BY"); - $params["bw_limit"] = (int) $_SESSION["bw_limit"]; - $params["is_default_pw"] = Pref_Prefs::isdefaultpassword(); - $params["label_base_index"] = (int) LABEL_BASE_INDEX; - - $theme = get_pref( "USER_CSS_THEME", false, false); - $params["theme"] = theme_exists($theme) ? $theme : ""; - - $params["plugins"] = implode(", ", PluginHost::getInstance()->get_plugin_names()); - - $params["php_platform"] = PHP_OS; - $params["php_version"] = PHP_VERSION; - - $params["sanity_checksum"] = sha1(file_get_contents("include/sanity_check.php")); - - $pdo = Db::pdo(); - - $sth = $pdo->prepare("SELECT MAX(id) AS mid, COUNT(*) AS nf FROM - ttrss_feeds WHERE owner_uid = ?"); - $sth->execute([$_SESSION['uid']]); - $row = $sth->fetch(); - - $max_feed_id = $row["mid"]; - $num_feeds = $row["nf"]; - - $params["max_feed_id"] = (int) $max_feed_id; - $params["num_feeds"] = (int) $num_feeds; - - $params["hotkeys"] = get_hotkeys_map(); - - $params["csrf_token"] = $_SESSION["csrf_token"]; - $params["widescreen"] = (int) $_COOKIE["ttrss_widescreen"]; - - $params['simple_update'] = defined('SIMPLE_UPDATE_MODE') && SIMPLE_UPDATE_MODE; - - $params["icon_indicator_white"] = base64_img("images/indicator_white.gif"); - - $params["labels"] = Labels::get_all_labels($_SESSION["uid"]); - - return $params; - } - - function get_hotkeys_info() { - $hotkeys = array( - __("Navigation") => array( - "next_feed" => __("Open next feed"), - "prev_feed" => __("Open previous feed"), - "next_article_or_scroll" => __("Open next article (in combined mode, scroll down)"), - "prev_article_or_scroll" => __("Open previous article (in combined mode, scroll up)"), - "next_article_page" => __("Scroll article by one page down"), - "prev_article_page" => __("Scroll article by one page up"), - "next_article_noscroll" => __("Open next article"), - "prev_article_noscroll" => __("Open previous article"), - "next_article_noexpand" => __("Move to next article (don't expand or mark read)"), - "prev_article_noexpand" => __("Move to previous article (don't expand or mark read)"), - "search_dialog" => __("Show search dialog")), - __("Article") => array( - "toggle_mark" => __("Toggle starred"), - "toggle_publ" => __("Toggle published"), - "toggle_unread" => __("Toggle unread"), - "edit_tags" => __("Edit tags"), - "open_in_new_window" => __("Open in new window"), - "catchup_below" => __("Mark below as read"), - "catchup_above" => __("Mark above as read"), - "article_scroll_down" => __("Scroll down"), - "article_scroll_up" => __("Scroll up"), - "article_page_down" => __("Scroll down page"), - "article_page_up" => __("Scroll up page"), - "select_article_cursor" => __("Select article under cursor"), - "email_article" => __("Email article"), - "close_article" => __("Close/collapse article"), - "toggle_expand" => __("Toggle article expansion (combined mode)"), - "toggle_widescreen" => __("Toggle widescreen mode"), - "toggle_full_text" => __("Toggle full article text via Readability")), - __("Article selection") => array( - "select_all" => __("Select all articles"), - "select_unread" => __("Select unread"), - "select_marked" => __("Select starred"), - "select_published" => __("Select published"), - "select_invert" => __("Invert selection"), - "select_none" => __("Deselect everything")), - __("Feed") => array( - "feed_refresh" => __("Refresh current feed"), - "feed_unhide_read" => __("Un/hide read feeds"), - "feed_subscribe" => __("Subscribe to feed"), - "feed_edit" => __("Edit feed"), - "feed_catchup" => __("Mark as read"), - "feed_reverse" => __("Reverse headlines"), - "feed_toggle_vgroup" => __("Toggle headline grouping"), - "feed_debug_update" => __("Debug feed update"), - "feed_debug_viewfeed" => __("Debug viewfeed()"), - "catchup_all" => __("Mark all feeds as read"), - "cat_toggle_collapse" => __("Un/collapse current category"), - "toggle_cdm_expanded" => __("Toggle auto expand in combined mode"), - "toggle_combined_mode" => __("Toggle combined mode")), - __("Go to") => array( - "goto_all" => __("All articles"), - "goto_fresh" => __("Fresh"), - "goto_marked" => __("Starred"), - "goto_published" => __("Published"), - "goto_read" => __("Recently read"), - "goto_tagcloud" => __("Tag cloud"), - "goto_prefs" => __("Preferences")), - __("Other") => array( - "create_label" => __("Create label"), - "create_filter" => __("Create filter"), - "collapse_sidebar" => __("Un/collapse sidebar"), - "help_dialog" => __("Show help dialog")) - ); - - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HOTKEY_INFO) as $plugin) { - $hotkeys = $plugin->hook_hotkey_info($hotkeys); - } - - return $hotkeys; - } - - function get_hotkeys_map() { - $hotkeys = array( - "k" => "next_feed", - "j" => "prev_feed", - "n" => "next_article_noscroll", - "p" => "prev_article_noscroll", - //"(33)|PageUp" => "prev_article_page", - //"(34)|PageDown" => "next_article_page", - "*(33)|Shift+PgUp" => "article_page_up", - "*(34)|Shift+PgDn" => "article_page_down", - "(38)|Up" => "prev_article_or_scroll", - "(40)|Down" => "next_article_or_scroll", - "*(38)|Shift+Up" => "article_scroll_up", - "*(40)|Shift+Down" => "article_scroll_down", - "^(38)|Ctrl+Up" => "prev_article_noscroll", - "^(40)|Ctrl+Down" => "next_article_noscroll", - "/" => "search_dialog", - "s" => "toggle_mark", - "S" => "toggle_publ", - "u" => "toggle_unread", - "T" => "edit_tags", - "o" => "open_in_new_window", - "c p" => "catchup_below", - "c n" => "catchup_above", - "N" => "article_scroll_down", - "P" => "article_scroll_up", - "a W" => "toggle_widescreen", - "a e" => "toggle_full_text", - "e" => "email_article", - "a q" => "close_article", - "a a" => "select_all", - "a u" => "select_unread", - "a U" => "select_marked", - "a p" => "select_published", - "a i" => "select_invert", - "a n" => "select_none", - "f r" => "feed_refresh", - "f a" => "feed_unhide_read", - "f s" => "feed_subscribe", - "f e" => "feed_edit", - "f q" => "feed_catchup", - "f x" => "feed_reverse", - "f g" => "feed_toggle_vgroup", - "f D" => "feed_debug_update", - "f G" => "feed_debug_viewfeed", - "f C" => "toggle_combined_mode", - "f c" => "toggle_cdm_expanded", - "Q" => "catchup_all", - "x" => "cat_toggle_collapse", - "g a" => "goto_all", - "g f" => "goto_fresh", - "g s" => "goto_marked", - "g p" => "goto_published", - "g r" => "goto_read", - "g t" => "goto_tagcloud", - "g P" => "goto_prefs", - "r" => "select_article_cursor", - "c l" => "create_label", - "c f" => "create_filter", - "c s" => "collapse_sidebar", - "?" => "help_dialog", - ); - - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HOTKEY_MAP) as $plugin) { - $hotkeys = $plugin->hook_hotkey_map($hotkeys); - } - - $prefixes = array(); - - foreach (array_keys($hotkeys) as $hotkey) { - $pair = explode(" ", $hotkey, 2); - - if (count($pair) > 1 && !in_array($pair[0], $prefixes)) { - array_push($prefixes, $pair[0]); - } - } - - return array($prefixes, $hotkeys); - } - - function make_runtime_info() { - $data = array(); - - $pdo = Db::pdo(); - - $sth = $pdo->prepare("SELECT MAX(id) AS mid, COUNT(*) AS nf FROM - ttrss_feeds WHERE owner_uid = ?"); - $sth->execute([$_SESSION['uid']]); - $row = $sth->fetch(); - - $max_feed_id = $row['mid']; - $num_feeds = $row['nf']; - - $data["max_feed_id"] = (int) $max_feed_id; - $data["num_feeds"] = (int) $num_feeds; - $data['cdm_expanded'] = get_pref('CDM_EXPANDED'); - $data["labels"] = Labels::get_all_labels($_SESSION["uid"]); - - if (LOG_DESTINATION == 'sql' && $_SESSION['access_level'] >= 10) { - if (DB_TYPE == 'pgsql') { - $log_interval = "created_at > NOW() - interval '1 hour'"; - } else { - $log_interval = "created_at > DATE_SUB(NOW(), INTERVAL 1 HOUR)"; - } - - $sth = $pdo->prepare("SELECT COUNT(id) AS cid FROM ttrss_error_log WHERE $log_interval"); - $sth->execute(); - - if ($row = $sth->fetch()) { - $data['recent_log_events'] = $row['cid']; - } - } - - if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) { - - $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock"); - - if (time() - $_SESSION["daemon_stamp_check"] > 30) { - - $stamp = (int) @file_get_contents(LOCK_DIRECTORY . "/update_daemon.stamp"); - - if ($stamp) { - $stamp_delta = time() - $stamp; - - if ($stamp_delta > 1800) { - $stamp_check = 0; - } else { - $stamp_check = 1; - $_SESSION["daemon_stamp_check"] = time(); - } - - $data['daemon_stamp_ok'] = $stamp_check; - - $stamp_fmt = date("Y.m.d, G:i", $stamp); - - $data['daemon_stamp'] = $stamp_fmt; - } - } - } - - return $data; - } - - function iframe_whitelisted($entry) { - @$src = parse_url($entry->getAttribute("src"), PHP_URL_HOST); - - if ($src) { - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_IFRAME_WHITELISTED) as $plugin) { - if ($plugin->hook_iframe_whitelisted($src)) - return true; - } - } - - return false; - } - - function sanitize($str, $force_remove_images = false, $owner = false, $site_url = false, $highlight_words = false, $article_id = false) { - if (!$owner) $owner = $_SESSION["uid"]; - - $res = trim($str); if (!$res) return ''; - - $doc = new DOMDocument(); - $doc->loadHTML('<?xml encoding="UTF-8">' . $res); - $xpath = new DOMXPath($doc); - - $rewrite_base_url = $site_url ? $site_url : get_self_url_prefix(); - - $entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src]|//audio/source[@src]|//picture/source[@src])'); - - foreach ($entries as $entry) { - - if ($entry->hasAttribute('href')) { - $entry->setAttribute('href', - rewrite_relative_url($rewrite_base_url, $entry->getAttribute('href'))); - - $entry->setAttribute('rel', 'noopener noreferrer'); - } - - if ($entry->hasAttribute('src')) { - $src = rewrite_relative_url($rewrite_base_url, $entry->getAttribute('src')); - $entry->setAttribute('src', $src); - } - - if ($entry->nodeName == 'img') { - $entry->setAttribute('referrerpolicy', 'no-referrer'); - $entry->setAttribute('loading', 'lazy'); - - $entry->removeAttribute('width'); - $entry->removeAttribute('height'); - - if ($entry->hasAttribute('src')) { - $is_https_url = parse_url($entry->getAttribute('src'), PHP_URL_SCHEME) === 'https'; - - if (is_prefix_https() && !$is_https_url) { - - if ($entry->hasAttribute('srcset')) { - $entry->removeAttribute('srcset'); - } - - if ($entry->hasAttribute('sizes')) { - $entry->removeAttribute('sizes'); - } - } - } - } - - if ($entry->hasAttribute('src') && - ($owner && get_pref("STRIP_IMAGES", $owner)) || $force_remove_images || $_SESSION["bw_limit"]) { - - $p = $doc->createElement('p'); - - $a = $doc->createElement('a'); - $a->setAttribute('href', $entry->getAttribute('src')); - - $a->appendChild(new DOMText($entry->getAttribute('src'))); - $a->setAttribute('target', '_blank'); - $a->setAttribute('rel', 'noopener noreferrer'); - - $p->appendChild($a); - - if ($entry->nodeName == 'source') { - - if ($entry->parentNode && $entry->parentNode->parentNode) - $entry->parentNode->parentNode->replaceChild($p, $entry->parentNode); - - } else if ($entry->nodeName == 'img') { - - if ($entry->parentNode) - $entry->parentNode->replaceChild($p, $entry); - - } - } - - if (strtolower($entry->nodeName) == "a") { - $entry->setAttribute("target", "_blank"); - $entry->setAttribute("rel", "noopener noreferrer"); - } - } - - $entries = $xpath->query('//iframe'); - foreach ($entries as $entry) { - if (!iframe_whitelisted($entry)) { - $entry->setAttribute('sandbox', 'allow-scripts'); - } else { - if (is_prefix_https()) { - $entry->setAttribute("src", - str_replace("http://", "https://", - $entry->getAttribute("src"))); - } - } - } - - $allowed_elements = array('a', 'abbr', 'address', 'acronym', 'audio', 'article', 'aside', - 'b', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', - 'caption', 'cite', 'center', 'code', 'col', 'colgroup', - 'data', 'dd', 'del', 'details', 'description', 'dfn', 'div', 'dl', 'font', - 'dt', 'em', 'footer', 'figure', 'figcaption', - 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'html', 'i', - 'img', 'ins', 'kbd', 'li', 'main', 'mark', 'nav', 'noscript', - 'ol', 'p', 'picture', 'pre', 'q', 'ruby', 'rp', 'rt', 's', 'samp', 'section', - 'small', 'source', 'span', 'strike', 'strong', 'sub', 'summary', - 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', - 'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' ); - - if ($_SESSION['hasSandbox']) $allowed_elements[] = 'iframe'; - - $disallowed_attributes = array('id', 'style', 'class'); - - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_SANITIZE) as $plugin) { - $retval = $plugin->hook_sanitize($doc, $site_url, $allowed_elements, $disallowed_attributes, $article_id); - if (is_array($retval)) { - $doc = $retval[0]; - $allowed_elements = $retval[1]; - $disallowed_attributes = $retval[2]; - } else { - $doc = $retval; - } - } - - $doc->removeChild($doc->firstChild); //remove doctype - $doc = strip_harmful_tags($doc, $allowed_elements, $disallowed_attributes); - - if ($highlight_words) { - foreach ($highlight_words as $word) { - - // http://stackoverflow.com/questions/4081372/highlight-keywords-in-a-paragraph - - $elements = $xpath->query("//*/text()"); - - foreach ($elements as $child) { - - $fragment = $doc->createDocumentFragment(); - $text = $child->textContent; - - while (($pos = mb_stripos($text, $word)) !== false) { - $fragment->appendChild(new DomText(mb_substr($text, 0, $pos))); - $word = mb_substr($text, $pos, mb_strlen($word)); - $highlight = $doc->createElement('span'); - $highlight->appendChild(new DomText($word)); - $highlight->setAttribute('class', 'highlight'); - $fragment->appendChild($highlight); - $text = mb_substr($text, $pos + mb_strlen($word)); - } - - if (!empty($text)) $fragment->appendChild(new DomText($text)); - - $child->parentNode->replaceChild($fragment, $child); - } - } - } - - $res = $doc->saveHTML(); - - /* strip everything outside of <body>...</body> */ - - $res_frag = array(); - if (preg_match('/<body>(.*)<\/body>/is', $res, $res_frag)) { - return $res_frag[1]; - } else { - return $res; - } - } - - function strip_harmful_tags($doc, $allowed_elements, $disallowed_attributes) { - $xpath = new DOMXPath($doc); - $entries = $xpath->query('//*'); - - foreach ($entries as $entry) { - if (!in_array($entry->nodeName, $allowed_elements)) { - $entry->parentNode->removeChild($entry); - } - - if ($entry->hasAttributes()) { - $attrs_to_remove = array(); - - foreach ($entry->attributes as $attr) { - - if (strpos($attr->nodeName, 'on') === 0) { - array_push($attrs_to_remove, $attr); - } - - if (strpos($attr->nodeName, "data-") === 0) { - array_push($attrs_to_remove, $attr); - } - - if ($attr->nodeName == 'href' && stripos($attr->value, 'javascript:') === 0) { - array_push($attrs_to_remove, $attr); - } - - if (in_array($attr->nodeName, $disallowed_attributes)) { - array_push($attrs_to_remove, $attr); - } - } - - foreach ($attrs_to_remove as $attr) { - $entry->removeAttributeNode($attr); - } - } - } - - return $doc; - } - function trim_array($array) { $tmp = $array; array_walk($tmp, 'trim'); return $tmp; } - function render_login_form() { - header('Cache-Control: public'); - - require_once "login_form.php"; - exit; - } - function T_sprintf() { $args = func_get_args(); return vsprintf(__(array_shift($args)), $args); } - function print_checkpoint($n, $s) { - $ts = microtime(true); - echo sprintf("<!-- CP[$n] %.4f seconds -->\n", $ts - $s); - return $ts; - } - function is_server_https() { return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'; } @@ -1517,157 +432,6 @@ return true; } - function build_url($parts) { - return $parts['scheme'] . "://" . $parts['host'] . $parts['path']; - } - - function cleanup_url_path($path) { - $path = str_replace("/./", "/", $path); - $path = str_replace("//", "/", $path); - - return $path; - } - - /** - * Converts a (possibly) relative URL to a absolute one. - * - * @param string $url Base URL (i.e. from where the document is) - * @param string $rel_url Possibly relative URL in the document - * - * @return string Absolute URL - */ - function rewrite_relative_url($url, $rel_url) { - if (strpos($rel_url, "://") !== false) { - return $rel_url; - } else if (strpos($rel_url, "//") === 0) { - # protocol-relative URL (rare but they exist) - return $rel_url; - } else if (preg_match("/^[a-z]+:/i", $rel_url)) { - # magnet:, feed:, etc - return $rel_url; - } else if (strpos($rel_url, "/") === 0) { - $parts = parse_url($url); - $parts['path'] = $rel_url; - $parts['path'] = cleanup_url_path($parts['path']); - - return build_url($parts); - - } else { - $parts = parse_url($url); - if (!isset($parts['path'])) { - $parts['path'] = '/'; - } - $dir = $parts['path']; - if (substr($dir, -1) !== '/') { - $dir = dirname($parts['path']); - $dir !== '/' && $dir .= '/'; - } - $parts['path'] = $dir . $rel_url; - $parts['path'] = cleanup_url_path($parts['path']); - - return build_url($parts); - } - } - - function print_user_stylesheet() { - $value = get_pref('USER_STYLESHEET'); - - if ($value) { - print "<style type='text/css' id='user_css_style'>"; - print str_replace("<br/>", "\n", $value); - print "</style>"; - } - - } - - /* function filter_to_sql($filter, $owner_uid) { - $query = array(); - - $pdo = Db::pdo(); - - if (DB_TYPE == "pgsql") - $reg_qpart = "~"; - else - $reg_qpart = "REGEXP"; - - foreach ($filter["rules"] AS $rule) { - $rule['reg_exp'] = str_replace('/', '\/', $rule["reg_exp"]); - $regexp_valid = preg_match('/' . $rule['reg_exp'] . '/', - $rule['reg_exp']) !== FALSE; - - if ($regexp_valid) { - - $rule['reg_exp'] = $pdo->quote($rule['reg_exp']); - - switch ($rule["type"]) { - case "title": - $qpart = "LOWER(ttrss_entries.title) $reg_qpart LOWER('". - $rule['reg_exp'] . "')"; - break; - case "content": - $qpart = "LOWER(ttrss_entries.content) $reg_qpart LOWER('". - $rule['reg_exp'] . "')"; - break; - case "both": - $qpart = "LOWER(ttrss_entries.title) $reg_qpart LOWER('". - $rule['reg_exp'] . "') OR LOWER(" . - "ttrss_entries.content) $reg_qpart LOWER('" . $rule['reg_exp'] . "')"; - break; - case "tag": - $qpart = "LOWER(ttrss_user_entries.tag_cache) $reg_qpart LOWER('". - $rule['reg_exp'] . "')"; - break; - case "link": - $qpart = "LOWER(ttrss_entries.link) $reg_qpart LOWER('". - $rule['reg_exp'] . "')"; - break; - case "author": - $qpart = "LOWER(ttrss_entries.author) $reg_qpart LOWER('". - $rule['reg_exp'] . "')"; - break; - } - - if (isset($rule['inverse'])) $qpart = "NOT ($qpart)"; - - if (isset($rule["feed_id"]) && $rule["feed_id"] > 0) { - $qpart .= " AND feed_id = " . $pdo->quote($rule["feed_id"]); - } - - if (isset($rule["cat_id"])) { - - if ($rule["cat_id"] > 0) { - $children = Feeds::getChildCategories($rule["cat_id"], $owner_uid); - array_push($children, $rule["cat_id"]); - $children = array_map("intval", $children); - - $children = join(",", $children); - - $cat_qpart = "cat_id IN ($children)"; - } else { - $cat_qpart = "cat_id IS NULL"; - } - - $qpart .= " AND $cat_qpart"; - } - - $qpart .= " AND feed_id IS NOT NULL"; - - array_push($query, "($qpart)"); - - } - } - - if (count($query) > 0) { - $fullquery = "(" . join($filter["match_any_rule"] ? "OR" : "AND", $query) . ")"; - } else { - $fullquery = "(false)"; - } - - if ($filter['inverse']) $fullquery = "(NOT $fullquery)"; - - return $fullquery; - } */ - if (!function_exists('gzdecode')) { function gzdecode($string) { // no support for 2nd argument return file_get_contents('compress.zlib://data:who/cares;base64,'. @@ -1676,7 +440,9 @@ } function get_random_bytes($length) { - if (function_exists('openssl_random_pseudo_bytes')) { + if (function_exists('random_bytes')) { + return random_bytes($length); + } else if (function_exists('openssl_random_pseudo_bytes')) { return openssl_random_pseudo_bytes($length); } else { $output = ""; @@ -1739,7 +505,7 @@ for ($i = 0; $i < $l10n->total; $i++) { $orig = $l10n->get_original_string($i); - if(strpos($orig, "\000") !== FALSE) { // Plural forms + if(strpos($orig, "\000") !== false) { // Plural forms $key = explode(chr(0), $orig); print T_js_decl($key[0], _ngettext($key[0], $key[1], 1)); // Singular print T_js_decl($key[1], _ngettext($key[0], $key[1], 2)); // Plural @@ -1769,6 +535,7 @@ */ function error_json($code) { require_once "errors.php"; + global $ERRORS; @$message = $ERRORS[$code]; @@ -1777,80 +544,6 @@ } - /*function abs_to_rel_path($dir) { - $tmp = str_replace(dirname(__DIR__), "", $dir); - - if (strlen($tmp) > 0 && substr($tmp, 0, 1) == "/") $tmp = substr($tmp, 1); - - return $tmp; - }*/ - - function get_upload_error_message($code) { - - $errors = array( - 0 => __('There is no error, the file uploaded with success'), - 1 => __('The uploaded file exceeds the upload_max_filesize directive in php.ini'), - 2 => __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'), - 3 => __('The uploaded file was only partially uploaded'), - 4 => __('No file was uploaded'), - 6 => __('Missing a temporary folder'), - 7 => __('Failed to write file to disk.'), - 8 => __('A PHP extension stopped the file upload.'), - ); - - return $errors[$code]; - } - - function base64_img($filename) { - if (file_exists($filename)) { - $ext = pathinfo($filename, PATHINFO_EXTENSION); - - return "data:image/$ext;base64," . base64_encode(file_get_contents($filename)); - } else { - return ""; - } - } - - /* this is essentially a wrapper for readfile() which allows plugins to hook - output with httpd-specific "fast" implementation i.e. X-Sendfile or whatever else - - hook function should return true if request was handled (or at least attempted to) - - note that this can be called without user context so the plugin to handle this - should be loaded systemwide in config.php */ - function send_local_file($filename) { - if (file_exists($filename)) { - - if (is_writable($filename)) touch($filename); - - $tmppluginhost = new PluginHost(); - - $tmppluginhost->load(PLUGINS, PluginHost::KIND_SYSTEM); - $tmppluginhost->load_data(); - - foreach ($tmppluginhost->get_hooks(PluginHost::HOOK_SEND_LOCAL_FILE) as $plugin) { - if ($plugin->hook_send_local_file($filename)) return true; - } - - $mimetype = mime_content_type($filename); - - // this is hardly ideal but 1) only media is cached in images/ and 2) seemingly only mp4 - // video files are detected as octet-stream by mime_content_type() - - if ($mimetype == "application/octet-stream") - $mimetype = "video/mp4"; - - header("Content-type: $mimetype"); - - $stamp = gmdate("D, d M Y H:i:s", filemtime($filename)) . " GMT"; - header("Last-Modified: $stamp", true); - - return readfile($filename); - } else { - return false; - } - } - function arr_qmarks($arr) { return str_repeat('?,', count($arr) - 1) . '?'; } @@ -1889,9 +582,7 @@ date_default_timezone_set('UTC'); $root_dir = dirname(dirname(__FILE__)); - if ('\\' === DIRECTORY_SEPARATOR) { - $ttrss_version['version'] = "UNKNOWN (Unsupported, Windows)"; - } else if (PHP_OS === "Darwin") { + if (PHP_OS === "Darwin") { $ttrss_version['version'] = "UNKNOWN (Unsupported, Darwin)"; } else if (file_exists("$root_dir/version_static.txt")) { $ttrss_version['version'] = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)"; @@ -1902,7 +593,7 @@ $cwd = getcwd(); chdir($root_dir); - exec('git --no-pager log --pretty='.escapeshellarg('version: %ct %h').' -n1 HEAD 2>&1', $output, $rc); + exec('git --no-pager log --pretty="version: %ct %h" -n1 HEAD 2>&1', $output, $rc); chdir($cwd); if (is_array($output) && count($output) > 0) { diff --git a/include/login_form.php b/include/login_form.php index 74f85f314..d2688d0ec 100755 --- a/include/login_form.php +++ b/include/login_form.php @@ -120,7 +120,7 @@ onblur="UtilityApp.fetchProfiles()" value="<?php echo $_SESSION["fake_password"] ?>"/> </fieldset> - <?php if (strpos(PLUGINS, "auth_internal") !== FALSE) { ?> + <?php if (strpos(PLUGINS, "auth_internal") !== false) { ?> <fieldset class="align-right"> <a href="public.php?op=forgotpass"><?php echo __("I forgot my password") ?></a> </fieldset> @@ -146,6 +146,14 @@ <?php echo __("Does not display images in articles, reduces automatic refreshes."); ?> </div> + <fieldset class="narrow"> + <label> </label> + + <label ><input dojoType="dijit.form.CheckBox" name="safe_mode" id="safe_mode" + type="checkbox"> + <?php echo __("Safe mode (no plugins)") ?></label> + </fieldset> + <?php if (SESSION_COOKIE_LIFETIME > 0) { ?> <fieldset class="narrow"> diff --git a/include/sanity_check.php b/include/sanity_check.php index 3998416f5..86dc7a5f0 100755 --- a/include/sanity_check.php +++ b/include/sanity_check.php @@ -60,7 +60,7 @@ array_push($errors, "Please copy config.php-dist to config.php or run the installer in install/"); } - if (strpos(PLUGINS, "auth_") === FALSE) { + if (strpos(PLUGINS, "auth_") === false) { array_push($errors, "Please enable at least one authentication module via PLUGINS constant in config.php"); } @@ -105,7 +105,7 @@ } if (SINGLE_USER_MODE && class_exists("PDO")) { - $pdo = DB::pdo(); + $pdo = Db::pdo(); $res = $pdo->query("SELECT id FROM ttrss_users WHERE id = 1"); @@ -219,8 +219,8 @@ <?php foreach ($errors as $error) { echo format_error($error); } ?> - <p>You might want to check tt-rss <a href="http://tt-rss.org/wiki">wiki</a> or the - <a href="http://tt-rss.org/forum">forums</a> for more information. Please search the forums before creating new topic + <p>You might want to check tt-rss <a href="https://tt-rss.org/wiki.php">wiki</a> or the + <a href="https://community.tt-rss.org/">forums</a> for more information. Please search the forums before creating new topic for your question.</p> </div> diff --git a/include/sessions.php b/include/sessions.php index 73be1e403..75d4671e8 100644 --- a/include/sessions.php +++ b/include/sessions.php @@ -6,7 +6,7 @@ require_once "autoload.php"; require_once "errorhandler.php"; require_once "lib/accept-to-gettext.php"; - require_once "lib/gettext/gettext.inc"; + require_once "lib/gettext/gettext.inc.php"; $session_expire = min(2147483647 - time() - 1, max(SESSION_COOKIE_LIFETIME, 86400)); $session_name = (!defined('TTRSS_SESSION_NAME')) ? "ttrss_sid" : TTRSS_SESSION_NAME; @@ -19,7 +19,7 @@ ini_set("session.name", $session_name); ini_set("session.use_only_cookies", true); ini_set("session.gc_maxlifetime", $session_expire); - ini_set("session.cookie_lifetime", min(0, SESSION_COOKIE_LIFETIME)); + ini_set("session.cookie_lifetime", 0); function session_get_schema_version() { global $schema_version; @@ -28,7 +28,7 @@ if (!init_plugins()) return; - login_sequence(); + UserHelper::login_sequence(); header('Content-Type: text/html; charset=utf-8'); @@ -39,7 +39,7 @@ <title>Tiny Tiny RSS</title> <meta name="viewport" content="initial-scale=1,width=device-width" /> - <?php if ($_SESSION["uid"]) { + <?php if ($_SESSION["uid"] && !isset($_REQUEST["ignore-theme"])) { $theme = get_pref("USER_CSS_THEME", false, false); if ($theme && theme_exists("$theme")) { echo stylesheet_tag(get_theme_path($theme), 'theme_css'); @@ -47,7 +47,11 @@ } ?> - <?php print_user_stylesheet() ?> + <script type="text/javascript"> + const __csrf_token = "<?php echo $_SESSION["csrf_token"]; ?>"; + </script> + + <?php UserHelper::print_user_stylesheet() ?> <style type="text/css"> <?php @@ -198,6 +202,14 @@ <option value="feed_dates"><?php echo __('Newest first') ?></option> <option value="date_reverse"><?php echo __('Oldest first') ?></option> <option value="title"><?php echo __('Title') ?></option> + + <?php foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_HEADLINES_CUSTOM_SORT_MAP) as $p) { + $sort_map = $p->hook_headlines_custom_sort_map(); + + foreach ($sort_map as $sort_value => $sort_title) { + print "<option value=\"" . htmlspecialchars($sort_value) . "\">$sort_title</option>"; + } + } ?> </select> <div dojoType="fox.form.ComboButton" onclick="Feeds.catchupCurrent()"> @@ -256,7 +268,6 @@ </div> <!-- toolbar --> </div> <!-- toolbar pane --> <div id="headlines-wrap-inner" dojoType="dijit.layout.BorderContainer" region="center"> - <div id="floatingTitle" style="display : none"></div> <div id="headlines-frame" dojoType="dijit.layout.ContentPane" tabindex="0" region="center"> <div id="headlinesInnerContainer"> diff --git a/install/index.php b/install/index.php index e4728fa73..6ff8acfbc 100755..100644 --- a/install/index.php +++ b/install/index.php @@ -10,7 +10,7 @@ function javascript_tag($filename) { $query = ""; - if (!(strpos($filename, "?") === FALSE)) { + if (!(strpos($filename, "?") === false)) { $query = substr($filename, strpos($filename, "?")+1); $filename = substr($filename, 0, strpos($filename, "?")); } @@ -151,35 +151,21 @@ function make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, $DB_PORT, $SELF_URL_PATH) { - $data = explode("\n", file_get_contents("../config.php-dist")); - - $rv = ""; - - $finished = false; - - foreach ($data as $line) { - if (preg_match("/define\('DB_TYPE'/", $line)) { - $rv .= "\tdefine('DB_TYPE', '$DB_TYPE');\n"; - } else if (preg_match("/define\('DB_HOST'/", $line)) { - $rv .= "\tdefine('DB_HOST', '$DB_HOST');\n"; - } else if (preg_match("/define\('DB_USER'/", $line)) { - $rv .= "\tdefine('DB_USER', '$DB_USER');\n"; - } else if (preg_match("/define\('DB_NAME'/", $line)) { - $rv .= "\tdefine('DB_NAME', '$DB_NAME');\n"; - } else if (preg_match("/define\('DB_PASS'/", $line)) { - $rv .= "\tdefine('DB_PASS', '$DB_PASS');\n"; - } else if (preg_match("/define\('DB_PORT'/", $line)) { - $rv .= "\tdefine('DB_PORT', '$DB_PORT');\n"; - } else if (preg_match("/define\('SELF_URL_PATH'/", $line)) { - $rv .= "\tdefine('SELF_URL_PATH', '$SELF_URL_PATH');\n"; - } else if (!$finished) { - $rv .= "$line\n"; - } + $rv = file_get_contents("../config.php-dist"); - if (preg_match("/\?\>/", $line)) { - $finished = true; - } - } + $escape_chars = "\\'"; + + $settings = [ + "%DB_TYPE" => $DB_TYPE == 'pgsql' ? 'pgsql' : 'mysql', + "%DB_HOST" => addcslashes($DB_HOST, $escape_chars), + "%DB_USER" => addcslashes($DB_USER, $escape_chars), + "%DB_NAME" => addcslashes($DB_NAME, $escape_chars), + "%DB_PASS" => addcslashes($DB_PASS, $escape_chars), + "%DB_PORT" => $DB_PORT ? intval($DB_PORT) : '', + "%SELF_URL_PATH" => addcslashes($SELF_URL_PATH, $escape_chars) + ]; + + $rv = str_replace(array_keys($settings), array_values($settings), $rv); return $rv; } @@ -250,28 +236,28 @@ <fieldset> <label>Username:</label> - <input dojoType="dijit.form.TextBox" required name="DB_USER" size="20" value="<?php echo $DB_USER ?>"/> + <input dojoType="dijit.form.TextBox" required name="DB_USER" size="20" value="<?php echo htmlspecialchars($DB_USER) ?>"/> </fieldset> <fieldset> <label>Password:</label> - <input dojoType="dijit.form.TextBox" name="DB_PASS" size="20" type="password" value="<?php echo $DB_PASS ?>"/> + <input dojoType="dijit.form.TextBox" name="DB_PASS" size="20" type="password" value="<?php echo htmlspecialchars($DB_PASS) ?>"/> </fieldset> <fieldset> <label>Database name:</label> - <input dojoType="dijit.form.TextBox" required name="DB_NAME" size="20" value="<?php echo $DB_NAME ?>"/> + <input dojoType="dijit.form.TextBox" required name="DB_NAME" size="20" value="<?php echo htmlspecialchars($DB_NAME) ?>"/> </fieldset> <fieldset> <label>Host name:</label> - <input dojoType="dijit.form.TextBox" name="DB_HOST" size="20" value="<?php echo $DB_HOST ?>"/> + <input dojoType="dijit.form.TextBox" name="DB_HOST" size="20" value="<?php echo htmlspecialchars($DB_HOST) ?>"/> <span class="hint">If needed</span> </fieldset> <fieldset> <label>Port:</label> - <input dojoType="dijit.form.TextBox" name="DB_PORT" type="number" size="20" value="<?php echo $DB_PORT ?>"/> + <input dojoType="dijit.form.TextBox" name="DB_PORT" type="number" size="20" value="<?php echo htmlspecialchars($DB_PORT) ?>"/> <span class="hint">Usually 3306 for MySQL or 5432 for PostgreSQL</span> </fieldset> @@ -281,7 +267,7 @@ <fieldset> <label>Tiny Tiny RSS URL:</label> - <input dojoType="dijit.form.TextBox" type="url" name="SELF_URL_PATH" placeholder="<?php echo $SELF_URL_PATH; ?>" value="<?php echo $SELF_URL_PATH ?>"/> + <input dojoType="dijit.form.TextBox" type="url" name="SELF_URL_PATH" placeholder="<?php echo htmlspecialchars($SELF_URL_PATH); ?>" value="<?php echo htmlspecialchars($SELF_URL_PATH) ?>"/> </fieldset> <p><button type="submit" dojoType="dijit.form.Button" class="alt-primary">Test configuration</button></p> @@ -352,7 +338,7 @@ $pdo = pdo_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT); if (!$pdo) { - print_error("Unable to connect to database using specified parameters (driver: $DB_TYPE)."); + print_error("Unable to connect to database using specified parameters (driver: " . htmlspecialchars($DB_TYPE) . ")."); exit; } @@ -378,13 +364,13 @@ <form method="post"> <input type="hidden" name="op" value="installschema"> - <input type="hidden" name="DB_USER" value="<?php echo $DB_USER ?>"/> - <input type="hidden" name="DB_PASS" value="<?php echo $DB_PASS ?>"/> - <input type="hidden" name="DB_NAME" value="<?php echo $DB_NAME ?>"/> - <input type="hidden" name="DB_HOST" value="<?php echo $DB_HOST ?>"/> - <input type="hidden" name="DB_PORT" value="<?php echo $DB_PORT ?>"/> - <input type="hidden" name="DB_TYPE" value="<?php echo $DB_TYPE ?>"/> - <input type="hidden" name="SELF_URL_PATH" value="<?php echo $SELF_URL_PATH ?>"/> + <input type="hidden" name="DB_USER" value="<?php echo htmlspecialchars($DB_USER) ?>"/> + <input type="hidden" name="DB_PASS" value="<?php echo htmlspecialchars($DB_PASS) ?>"/> + <input type="hidden" name="DB_NAME" value="<?php echo htmlspecialchars($DB_NAME) ?>"/> + <input type="hidden" name="DB_HOST" value="<?php echo htmlspecialchars($DB_HOST) ?>"/> + <input type="hidden" name="DB_PORT" value="<?php echo htmlspecialchars($DB_PORT) ?>"/> + <input type="hidden" name="DB_TYPE" value="<?php echo htmlspecialchars($DB_TYPE) ?>"/> + <input type="hidden" name="SELF_URL_PATH" value="<?php echo htmlspecialchars($SELF_URL_PATH) ?>"/> <p> <?php if ($need_confirm) { ?> @@ -398,13 +384,13 @@ </td><td> <form method="post"> - <input type="hidden" name="DB_USER" value="<?php echo $DB_USER ?>"/> - <input type="hidden" name="DB_PASS" value="<?php echo $DB_PASS ?>"/> - <input type="hidden" name="DB_NAME" value="<?php echo $DB_NAME ?>"/> - <input type="hidden" name="DB_HOST" value="<?php echo $DB_HOST ?>"/> - <input type="hidden" name="DB_PORT" value="<?php echo $DB_PORT ?>"/> - <input type="hidden" name="DB_TYPE" value="<?php echo $DB_TYPE ?>"/> - <input type="hidden" name="SELF_URL_PATH" value="<?php echo $SELF_URL_PATH ?>"/> + <input type="hidden" name="DB_USER" value="<?php echo htmlspecialchars($DB_USER) ?>"/> + <input type="hidden" name="DB_PASS" value="<?php echo htmlspecialchars($DB_PASS) ?>"/> + <input type="hidden" name="DB_NAME" value="<?php echo htmlspecialchars($DB_NAME) ?>"/> + <input type="hidden" name="DB_HOST" value="<?php echo htmlspecialchars($DB_HOST) ?>"/> + <input type="hidden" name="DB_PORT" value="<?php echo htmlspecialchars($DB_PORT) ?>"/> + <input type="hidden" name="DB_TYPE" value="<?php echo htmlspecialchars($DB_TYPE) ?>"/> + <input type="hidden" name="SELF_URL_PATH" value="<?php echo htmlspecialchars($SELF_URL_PATH) ?>"/> <input type="hidden" name="op" value="skipschema"> @@ -456,16 +442,16 @@ <form action="" method="post"> <input type="hidden" name="op" value="saveconfig"> - <input type="hidden" name="DB_USER" value="<?php echo $DB_USER ?>"/> - <input type="hidden" name="DB_PASS" value="<?php echo $DB_PASS ?>"/> - <input type="hidden" name="DB_NAME" value="<?php echo $DB_NAME ?>"/> - <input type="hidden" name="DB_HOST" value="<?php echo $DB_HOST ?>"/> - <input type="hidden" name="DB_PORT" value="<?php echo $DB_PORT ?>"/> - <input type="hidden" name="DB_TYPE" value="<?php echo $DB_TYPE ?>"/> - <input type="hidden" name="SELF_URL_PATH" value="<?php echo $SELF_URL_PATH ?>"/> + <input type="hidden" name="DB_USER" value="<?php echo htmlspecialchars($DB_USER) ?>"/> + <input type="hidden" name="DB_PASS" value="<?php echo htmlspecialchars($DB_PASS) ?>"/> + <input type="hidden" name="DB_NAME" value="<?php echo htmlspecialchars($DB_NAME) ?>"/> + <input type="hidden" name="DB_HOST" value="<?php echo htmlspecialchars($DB_HOST) ?>"/> + <input type="hidden" name="DB_PORT" value="<?php echo htmlspecialchars($DB_PORT) ?>"/> + <input type="hidden" name="DB_TYPE" value="<?php echo htmlspecialchars($DB_TYPE) ?>"/> + <input type="hidden" name="SELF_URL_PATH" value="<?php echo htmlspecialchars($SELF_URL_PATH) ?>"/> <?php print "<textarea rows='20' style='width : 100%'>"; - echo make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, - $DB_PORT, $SELF_URL_PATH); + echo htmlspecialchars(make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, + $DB_PORT, $SELF_URL_PATH)); print "</textarea>"; ?> <hr/> diff --git a/js/App.js b/js/App.js new file mode 100644 index 000000000..03103845e --- /dev/null +++ b/js/App.js @@ -0,0 +1,1236 @@ +'use strict'; + +/* global __, Article, Ajax, Headlines, Filters */ +/* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Feeds, Cookie */ +/* global CommonDialogs, Plugins, Effect */ + +const App = { + _initParams: [], + _rpc_seq: 0, + hotkey_prefix: 0, + hotkey_prefix_pressed: false, + hotkey_prefix_timeout: 0, + global_unread: -1, + _widescreen_mode: false, + _loading_progress: 0, + hotkey_actions: {}, + is_prefs: false, + LABEL_BASE_INDEX: -1024, + Scrollable: { + scrollByPages: function (elem, page_offset) { + if (!elem) return; + + /* keep a line or so from the previous page */ + const offset = (elem.offsetHeight - (page_offset > 0 ? 50 : -50)) * page_offset; + + this.scroll(elem, offset); + }, + scroll: function(elem, offset) { + if (!elem) return; + + elem.scrollTop += offset; + }, + isChildVisible: function(elem, ctr) { + if (!elem) return; + + const ctop = ctr.scrollTop; + const cbottom = ctop + ctr.offsetHeight; + + const etop = elem.offsetTop; + const ebottom = etop + elem.offsetHeight; + + return etop >= ctop && ebottom <= cbottom || + etop < ctop && ebottom > ctop || ebottom > cbottom && etop < cbottom; + }, + fitsInContainer: function (elem, ctr) { + if (!elem) return; + + return elem.offsetTop + elem.offsetHeight <= ctr.scrollTop + ctr.offsetHeight && + elem.offsetTop >= ctr.scrollTop; + } + }, + label_to_feed_id: function(label) { + return this.LABEL_BASE_INDEX - 1 - Math.abs(label); + }, + feed_to_label_id: function(feed) { + return this.LABEL_BASE_INDEX - 1 + Math.abs(feed); + }, + getInitParam: function(k) { + return this._initParams[k]; + }, + setInitParam: function(k, v) { + this._initParams[k] = v; + }, + nightModeChanged: function(is_night, link) { + console.log("night mode changed to", is_night); + + if (link) { + const css_override = is_night ? "themes/night.css" : "themes/light.css"; + link.setAttribute("href", css_override + "?" + Date.now()); + } + }, + setupNightModeDetection: function(callback) { + if (!$("theme_css")) { + const mql = window.matchMedia('(prefers-color-scheme: dark)'); + + try { + mql.addEventListener("change", () => { + this.nightModeChanged(mql.matches, $("theme_auto_css")); + }); + } catch (e) { + console.warn("exception while trying to set MQL event listener"); + } + + const link = new Element("link", { + rel: "stylesheet", + id: "theme_auto_css" + }); + + if (callback) { + link.onload = function () { + document.querySelector("body").removeClassName("css_loading"); + callback(); + }; + + link.onerror = function(event) { + alert("Fatal error while loading application stylesheet: " + link.getAttribute("href")); + } + } + + this.nightModeChanged(mql.matches, link); + + document.querySelector("head").appendChild(link); + } else { + document.querySelector("body").removeClassName("css_loading"); + + if (callback) callback(); + } + }, + enableCsrfSupport: function() { + const _this = this; + + Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap( + function (callOriginal, options) { + + if (_this.getInitParam("csrf_token") != undefined) { + Object.extend(options, options || { }); + + if (Object.isString(options.parameters)) + options.parameters = options.parameters.toQueryParams(); + else if (Object.isHash(options.parameters)) + options.parameters = options.parameters.toObject(); + + options.parameters["csrf_token"] = _this.getInitParam("csrf_token"); + } + + return callOriginal(options); + } + ); + }, + postCurrentWindow: function(target, params) { + const form = document.createElement("form"); + + form.setAttribute("method", "post"); + form.setAttribute("action", App.getInitParam("self_url_prefix") + "/" + target); + + for (const [k,v] of Object.entries(params)) { + const field = document.createElement("input"); + + field.setAttribute("name", k); + field.setAttribute("value", v); + field.setAttribute("type", "hidden"); + + form.appendChild(field); + } + + document.body.appendChild(form); + + form.submit(); + + form.parentNode.removeChild(form); + }, + postOpenWindow: function(target, params) { + const w = window.open(""); + + if (w) { + w.opener = null; + + const form = document.createElement("form"); + + form.setAttribute("method", "post"); + form.setAttribute("action", App.getInitParam("self_url_prefix") + "/" + target); + + for (const [k,v] of Object.entries(params)) { + const field = document.createElement("input"); + + field.setAttribute("name", k); + field.setAttribute("value", v); + field.setAttribute("type", "hidden"); + + form.appendChild(field); + } + + w.document.body.appendChild(form); + form.submit(); + } + + }, + urlParam: function(param) { + return String(window.location.href).parseQuery()[param]; + }, + next_seq: function() { + this._rpc_seq += 1; + return this._rpc_seq; + }, + get_seq: function() { + return this._rpc_seq; + }, + setLoadingProgress: function(p) { + this._loading_progress += p; + + if (dijit.byId("loading_bar")) + dijit.byId("loading_bar").update({progress: this._loading_progress}); + + if (this._loading_progress >= 90) { + $("overlay").hide(); + } + + }, + isCombinedMode: function() { + return this.getInitParam("combined_display_mode"); + }, + getActionByHotkeySequence: function(sequence) { + const hotkeys_map = this.getInitParam("hotkeys"); + + for (const seq in hotkeys_map[1]) { + if (hotkeys_map[1].hasOwnProperty(seq)) { + if (seq == sequence) { + return hotkeys_map[1][seq]; + } + } + } + }, + keyeventToAction: function(event) { + + const hotkeys_map = this.getInitParam("hotkeys"); + const keycode = event.which; + const keychar = String.fromCharCode(keycode); + + if (keycode == 27) { // escape and drop prefix + this.hotkey_prefix = false; + } + + if (!this.hotkey_prefix && hotkeys_map[0].indexOf(keychar) != -1) { + + this.hotkey_prefix = keychar; + $("cmdline").innerHTML = keychar; + Element.show("cmdline"); + + window.clearTimeout(this.hotkey_prefix_timeout); + this.hotkey_prefix_timeout = window.setTimeout(() => { + this.hotkey_prefix = false; + Element.hide("cmdline"); + }, 3 * 1000); + + event.stopPropagation(); + + return false; + } + + Element.hide("cmdline"); + + let hotkey_name = ""; + + if (event.type == "keydown") { + hotkey_name = "(" + keycode + ")"; + + // ensure ^*char notation + if (event.shiftKey) hotkey_name = "*" + hotkey_name; + if (event.ctrlKey) hotkey_name = "^" + hotkey_name; + if (event.altKey) hotkey_name = "+" + hotkey_name; + if (event.metaKey) hotkey_name = "%" + hotkey_name; + } else { + hotkey_name = keychar ? keychar : "(" + keycode + ")"; + } + + let hotkey_full = this.hotkey_prefix ? this.hotkey_prefix + " " + hotkey_name : hotkey_name; + this.hotkey_prefix = false; + + let action_name = this.getActionByHotkeySequence(hotkey_full); + + // check for mode-specific hotkey + if (!action_name) { + hotkey_full = (this.isCombinedMode() ? "{C}" : "{3}") + hotkey_full; + + action_name = this.getActionByHotkeySequence(hotkey_full); + } + + console.log('keyeventToAction', hotkey_full, '=>', action_name); + + return action_name; + }, + cleanupMemory: function(root) { + const dijits = dojo.query("[widgetid]", dijit.byId(root).domNode).map(dijit.byNode); + + dijits.each(function (d) { + dojo.destroy(d.domNode); + }); + + $$("#" + root + " *").each(function (i) { + i.parentNode ? i.parentNode.removeChild(i) : true; + }); + }, + // htmlspecialchars()-alike for headlines data-content attribute + escapeHtml: function(text) { + const map = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + }; + + return text.replace(/[&<>"']/g, function(m) { return map[m]; }); + }, + displayIfChecked: function(checkbox, elemId) { + if (checkbox.checked) { + Effect.Appear(elemId, {duration : 0.5}); + } else { + Effect.Fade(elemId, {duration : 0.5}); + } + }, + helpDialog: function(topic) { + if (dijit.byId("helpDlg")) + dijit.byId("helpDlg").destroyRecursive(); + + xhrPost("backend.php", {op: "backend", method: "help", topic: topic}, (transport) => { + const dialog = new dijit.Dialog({ + id: "helpDlg", + title: __("Help"), + style: "width: 600px", + content: transport.responseText, + }); + + dialog.show(); + }); + }, + displayDlg: function(title, id, param, callback) { + Notify.progress("Loading, please wait...", true); + + const query = {op: "dlg", method: id, param: param}; + + xhrPost("backend.php", query, (transport) => { + try { + const content = transport.responseText; + + let dialog = dijit.byId("infoBox"); + + if (!dialog) { + dialog = new dijit.Dialog({ + title: title, + id: 'infoBox', + style: "width: 600px", + onCancel: function () { + return true; + }, + onExecute: function () { + return true; + }, + onClose: function () { + return true; + }, + content: content + }); + } else { + dialog.attr('title', title); + dialog.attr('content', content); + } + + dialog.show(); + + Notify.close(); + + if (callback) callback(transport); + } catch (e) { + this.Error.report(e); + } + }); + + return false; + }, + handleRpcJson: function(transport) { + + const netalert = $$("#toolbar .net-alert")[0]; + + try { + const reply = JSON.parse(transport.responseText); + + if (reply) { + const error = reply['error']; + + if (error) { + const code = error['code']; + const msg = error['message']; + + console.warn("[handleRpcJson] received fatal error ", code, msg); + + if (code != 0) { + /* global ERRORS */ + this.Error.fatal(ERRORS[code], {info: msg, code: code}); + return false; + } + } + + const seq = reply['seq']; + + if (seq && this.get_seq() != seq) { + console.log("[handleRpcJson] sequence mismatch: ", seq, '!=', this.get_seq()); + return true; + } + + const message = reply['message']; + + if (message == "UPDATE_COUNTERS") { + console.log("need to refresh counters..."); + Feeds.requestCounters(true); + } + + const counters = reply['counters']; + + if (counters) + Feeds.parseCounters(counters); + + const runtime_info = reply['runtime-info']; + + if (runtime_info) + this.parseRuntimeInfo(runtime_info); + + if (netalert) netalert.hide(); + + return reply; + + } else { + if (netalert) netalert.show(); + + Notify.error("Communication problem with server."); + } + + } catch (e) { + if (netalert) netalert.show(); + + Notify.error("Communication problem with server."); + + console.error(e); + } + + return false; + }, + parseRuntimeInfo: function(data) { + for (const k in data) { + if (data.hasOwnProperty(k)) { + const v = data[k]; + + console.log("RI:", k, "=>", v); + + if (k == "daemon_is_running" && v != 1) { + Notify.error("<span onclick=\"App.explainError(1)\">Update daemon is not running.</span>", true); + return; + } + + if (k == "recent_log_events") { + const alert = $$(".log-alert")[0]; + + if (alert) { + v > 0 ? alert.show() : alert.hide(); + } + } + + if (k == "daemon_stamp_ok" && v != 1) { + Notify.error("<span onclick=\"App.explainError(3)\">Update daemon is not updating feeds.</span>", true); + return; + } + + if (k == "max_feed_id" || k == "num_feeds") { + if (this.getInitParam(k) != v) { + console.log("feed count changed, need to reload feedlist."); + Feeds.reload(); + } + } + + this.setInitParam(k, v); + } + } + + PluginHost.run(PluginHost.HOOK_RUNTIME_INFO_LOADED, data); + }, + backendSanityCallback: function(transport) { + const reply = JSON.parse(transport.responseText); + + /* global ERRORS */ + + if (!reply) { + this.Error.fatal(ERRORS[3], {info: transport.responseText}); + return; + } + + if (reply['error']) { + const code = reply['error']['code']; + + if (code && code != 0) { + return this.Error.fatal(ERRORS[code], + {code: code, info: reply['error']['message']}); + } + } + + console.log("sanity check ok"); + + const params = reply['init-params']; + + if (params) { + console.log('reading init-params...'); + + for (const k in params) { + if (params.hasOwnProperty(k)) { + switch (k) { + case "label_base_index": + this.LABEL_BASE_INDEX = parseInt(params[k]); + break; + case "cdm_auto_catchup": + if (params[k] == 1) { + const hl = $("headlines-frame"); + if (hl) hl.addClassName("auto_catchup"); + } + break; + case "hotkeys": + // filter mnemonic definitions (used for help panel) from hotkeys map + // i.e. *(191)|Ctrl-/ -> *(191) + { + const tmp = []; + for (const sequence in params[k][1]) { + if (params[k][1].hasOwnProperty(sequence)) { + const filtered = sequence.replace(/\|.*$/, ""); + tmp[filtered] = params[k][1][sequence]; + } + } + + params[k][1] = tmp; + } + break; + } + + console.log("IP:", k, "=>", params[k]); + this.setInitParam(k, params[k]); + } + } + + // PluginHost might not be available on non-index pages + if (typeof PluginHost !== 'undefined') + PluginHost.run(PluginHost.HOOK_PARAMS_LOADED, this._initParams); + } + + this.initSecondStage(); + }, + explainError: function(code) { + return this.displayDlg(__("Error explained"), "explainError", code); + }, + Error: { + fatal: function (error, params) { + params = params || {}; + + if (params.code) { + if (params.code == 6) { + window.location.href = "index.php"; + return; + } else if (params.code == 5) { + window.location.href = "public.php?op=dbupdate"; + return; + } + } + + return this.report(error, + Object.extend({title: __("Fatal error")}, params)); + }, + report: function(error, params) { + params = params || {}; + + if (!error) return; + + console.error("[Error.report]", error, params); + + const message = params.message ? params.message : error.toString(); + + try { + xhrPost("backend.php", + {op: "rpc", method: "log", + file: params.filename ? params.filename : error.fileName, + line: params.lineno ? params.lineno : error.lineNumber, + msg: message, + context: error.stack}, + (transport) => { + console.warn("[Error.report] log response", transport.responseText); + }); + } catch (re) { + console.error("[Error.report] exception while saving logging error on server", re); + } + + try { + if (dijit.byId("exceptionDlg")) + dijit.byId("exceptionDlg").destroyRecursive(); + + let stack_msg = ""; + + if (error.stack) + stack_msg += `<div><b>Stack trace:</b></div> + <textarea name="stack" readonly="1">${error.stack}</textarea>`; + + if (params.info) + stack_msg += `<div><b>Additional information:</b></div> + <textarea name="stack" readonly="1">${params.info}</textarea>`; + + const content = `<div class="error-contents"> + <p class="message">${message}</p> + ${stack_msg} + <div class="dlgButtons"> + <button dojoType="dijit.form.Button" + onclick="dijit.byId('exceptionDlg').hide()">${__('Close this window')}</button> + </div> + </div>`; + + const dialog = new dijit.Dialog({ + id: "exceptionDlg", + title: params.title || __("Unhandled exception"), + style: "width: 600px", + content: content + }); + + dialog.show(); + } catch (de) { + console.error("[Error.report] exception while showing error dialog", de); + + alert(error.stack ? error.stack : message); + } + + }, + onWindowError: function (message, filename, lineno, colno, error) { + // called without context (this) from window.onerror + App.Error.report(error, + {message: message, filename: filename, lineno: lineno, colno: colno}); + }, + }, + isPrefs() { + return this.is_prefs; + }, + init: function(parser, is_prefs) { + this.is_prefs = is_prefs; + window.onerror = this.Error.onWindowError; + + this.setInitParam("csrf_token", __csrf_token); + + this.setupNightModeDetection(() => { + parser.parse(); + + console.log('is_prefs', this.is_prefs); + + if (!this.checkBrowserFeatures()) + return; + + this.setLoadingProgress(30); + this.initHotkeyActions(); + this.enableCsrfSupport(); + + const a = document.createElement('audio'); + const hasAudio = !!a.canPlayType; + const hasSandbox = "sandbox" in document.createElement("iframe"); + const hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, '')); + const clientTzOffset = new Date().getTimezoneOffset() * 60; + + const params = { + op: "rpc", method: "sanityCheck", hasAudio: hasAudio, + hasMp3: hasMp3, + clientTzOffset: clientTzOffset, + hasSandbox: hasSandbox + }; + + xhrPost("backend.php", params, (transport) => { + try { + this.backendSanityCallback(transport); + } catch (e) { + this.Error.report(e); + } + }); + }); + }, + checkBrowserFeatures: function() { + let errorMsg = ""; + + ['MutationObserver'].each(function(wf) { + if (!(wf in window)) { + errorMsg = `Browser feature check failed: <code>window.${wf}</code> not found.`; + throw new Error(errorMsg); + } + }); + + if (errorMsg) { + this.Error.fatal(errorMsg, {info: navigator.userAgent}); + } + + return errorMsg == ""; + }, + initSecondStage: function() { + + document.onkeydown = (event) => { return this.hotkeyHandler(event) }; + document.onkeypress = (event) => { return this.hotkeyHandler(event) }; + + if (this.is_prefs) { + + this.setLoadingProgress(70); + Notify.close(); + + let tab = this.urlParam('tab'); + + if (tab) { + tab = dijit.byId(tab + "Tab"); + if (tab) { + dijit.byId("pref-tabs").selectChild(tab); + + switch (this.urlParam('method')) { + case "editfeed": + window.setTimeout(() => { + CommonDialogs.editFeed(this.urlParam('methodparam')) + }, 100); + break; + default: + console.warn("initSecondStage, unknown method:", this.urlParam("method")); + } + } + } else { + let tab = localStorage.getItem("ttrss:prefs-tab"); + + if (tab) { + tab = dijit.byId(tab); + if (tab) { + dijit.byId("pref-tabs").selectChild(tab); + } + } + } + + dojo.connect(dijit.byId("pref-tabs"), "selectChild", function (elem) { + localStorage.setItem("ttrss:prefs-tab", elem.id); + }); + + } else { + + Feeds.reload(); + Article.close(); + + if (parseInt(Cookie.get("ttrss_fh_width")) > 0) { + dijit.byId("feeds-holder").domNode.setStyle( + {width: Cookie.get("ttrss_fh_width") + "px"}); + } + + dijit.byId("main").resize(); + + dojo.connect(dijit.byId('feeds-holder'), 'resize', + (args) => { + if (args && args.w >= 0) { + Cookie.set("ttrss_fh_width", args.w, this.getInitParam("cookie_lifetime")); + } + }); + + dojo.connect(dijit.byId('content-insert'), 'resize', + (args) => { + if (args && args.w >= 0 && args.h >= 0) { + Cookie.set("ttrss_ci_width", args.w, this.getInitParam("cookie_lifetime")); + Cookie.set("ttrss_ci_height", args.h, this.getInitParam("cookie_lifetime")); + } + }); + + const toolbar = document.forms["toolbar-main"]; + + dijit.getEnclosingWidget(toolbar.view_mode).attr('value', + this.getInitParam("default_view_mode")); + + dijit.getEnclosingWidget(toolbar.order_by).attr('value', + this.getInitParam("default_view_order_by")); + + this.setLoadingProgress(50); + + this._widescreen_mode = this.getInitParam("widescreen"); + this.switchPanelMode(this._widescreen_mode); + + Headlines.initScrollHandler(); + + if (this.getInitParam("simple_update")) { + console.log("scheduling simple feed updater..."); + window.setInterval(() => { Feeds.updateRandom() }, 30 * 1000); + } + + if (this.getInitParam('check_for_updates')) { + window.setInterval(() => { + this.checkForUpdates(); + }, 3600 * 1000); + } + + console.log("second stage ok"); + + PluginHost.run(PluginHost.HOOK_INIT_COMPLETE, null); + + } + + }, + checkForUpdates: function() { + console.log('checking for updates...'); + + xhrJson("backend.php", {op: 'rpc', method: 'checkforupdates'}) + .then((reply) => { + console.log('update reply', reply); + + if (reply.id) { + $("updates-available").show(); + } else { + $("updates-available").hide(); + } + }); + }, + updateTitle: function() { + let tmp = "Tiny Tiny RSS"; + + if (this.global_unread > 0) { + tmp = "(" + this.global_unread + ") " + tmp; + } + + document.title = tmp; + }, + onViewModeChanged: function() { + const view_mode = document.forms["toolbar-main"].view_mode.value; + + $$("body")[0].setAttribute("view-mode", view_mode); + + return Feeds.reloadCurrent(''); + }, + hotkeyHandler: function(event) { + if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return; + + // Arrow buttons and escape are not reported via keypress, handle them via keydown. + // escape = 27, left = 37, up = 38, right = 39, down = 40, pgup = 33, pgdn = 34, insert = 45, delete = 46 + if (event.type == "keydown" && event.which != 27 && (event.which < 33 || event.which > 46)) return; + + const action_name = this.keyeventToAction(event); + + if (action_name) { + const action_func = this.hotkey_actions[action_name]; + + if (action_func != null) { + action_func(event); + event.stopPropagation(); + return false; + } + } + }, + switchPanelMode: function(wide) { + const article_id = Article.getActive(); + + if (wide) { + dijit.byId("headlines-wrap-inner").attr("design", 'sidebar'); + dijit.byId("content-insert").attr("region", "trailing"); + + dijit.byId("content-insert").domNode.setStyle({width: '50%', + height: 'auto', + borderTopWidth: '0px' }); + + if (parseInt(Cookie.get("ttrss_ci_width")) > 0) { + dijit.byId("content-insert").domNode.setStyle( + {width: Cookie.get("ttrss_ci_width") + "px" }); + } + + $("headlines-frame").setStyle({ borderBottomWidth: '0px' }); + $("headlines-frame").addClassName("wide"); + + } else { + + dijit.byId("content-insert").attr("region", "bottom"); + + dijit.byId("content-insert").domNode.setStyle({width: 'auto', + height: '50%', + borderTopWidth: '0px'}); + + if (parseInt(Cookie.get("ttrss_ci_height")) > 0) { + dijit.byId("content-insert").domNode.setStyle( + {height: Cookie.get("ttrss_ci_height") + "px" }); + } + + $("headlines-frame").setStyle({ borderBottomWidth: '1px' }); + $("headlines-frame").removeClassName("wide"); + + } + + Article.close(); + + if (article_id) Article.view(article_id); + + xhrPost("backend.php", {op: "rpc", method: "setpanelmode", wide: wide ? 1 : 0}); + }, + initHotkeyActions: function() { + if (this.is_prefs) { + + this.hotkey_actions["feed_subscribe"] = () => { + CommonDialogs.quickAddFeed(); + }; + + this.hotkey_actions["create_label"] = () => { + CommonDialogs.addLabel(); + }; + + this.hotkey_actions["create_filter"] = () => { + Filters.quickAddFilter(); + }; + + this.hotkey_actions["help_dialog"] = () => { + this.helpDialog("main"); + }; + + } else { + + this.hotkey_actions["next_feed"] = () => { + const rv = dijit.byId("feedTree").getNextFeed( + Feeds.getActive(), Feeds.activeIsCat()); + + if (rv) Feeds.open({feed: rv[0], is_cat: rv[1], delayed: true}) + }; + this.hotkey_actions["prev_feed"] = () => { + const rv = dijit.byId("feedTree").getPreviousFeed( + Feeds.getActive(), Feeds.activeIsCat()); + + if (rv) Feeds.open({feed: rv[0], is_cat: rv[1], delayed: true}) + }; + this.hotkey_actions["next_article_or_scroll"] = (event) => { + if (this.isCombinedMode()) + Headlines.scroll(Headlines.line_scroll_offset, event); + else + Headlines.move('next'); + }; + this.hotkey_actions["prev_article_or_scroll"] = (event) => { + if (this.isCombinedMode()) + Headlines.scroll(-Headlines.line_scroll_offset, event); + else + Headlines.move('prev'); + }; + this.hotkey_actions["next_article_noscroll"] = () => { + Headlines.move('next'); + }; + this.hotkey_actions["prev_article_noscroll"] = () => { + Headlines.move('prev'); + }; + this.hotkey_actions["next_article_noexpand"] = () => { + Headlines.move('next', {no_expand: true}); + }; + this.hotkey_actions["prev_article_noexpand"] = () => { + Headlines.move('prev', {no_expand: true}); + }; + this.hotkey_actions["search_dialog"] = () => { + Feeds.search(); + }; + this.hotkey_actions["cancel_search"] = () => { + Feeds.cancelSearch(); + }; + this.hotkey_actions["toggle_mark"] = () => { + Headlines.selectionToggleMarked(); + }; + this.hotkey_actions["toggle_publ"] = () => { + Headlines.selectionTogglePublished(); + }; + this.hotkey_actions["toggle_unread"] = () => { + Headlines.selectionToggleUnread({no_error: 1}); + }; + this.hotkey_actions["edit_tags"] = () => { + const id = Article.getActive(); + if (id) { + Article.editTags(id); + } + }; + this.hotkey_actions["open_in_new_window"] = () => { + if (Article.getActive()) { + Article.openInNewWindow(Article.getActive()); + } + }; + this.hotkey_actions["catchup_below"] = () => { + Headlines.catchupRelativeTo(1); + }; + this.hotkey_actions["catchup_above"] = () => { + Headlines.catchupRelativeTo(0); + }; + this.hotkey_actions["article_scroll_down"] = (event) => { + if (this.isCombinedMode()) + Headlines.scroll(Headlines.line_scroll_offset, event); + else + Article.scroll(Headlines.line_scroll_offset, event); + }; + this.hotkey_actions["article_scroll_up"] = (event) => { + if (this.isCombinedMode()) + Headlines.scroll(-Headlines.line_scroll_offset, event); + else + Article.scroll(-Headlines.line_scroll_offset, event); + }; + this.hotkey_actions["next_headlines_page"] = (event) => { + Headlines.scrollByPages(1, event); + }; + this.hotkey_actions["prev_headlines_page"] = (event) => { + Headlines.scrollByPages(-1, event); + }; + this.hotkey_actions["article_page_down"] = (event) => { + if (this.isCombinedMode()) + Headlines.scrollByPages(1, event); + else + Article.scrollByPages(1, event); + }; + this.hotkey_actions["article_page_up"] = (event) => { + if (this.isCombinedMode()) + Headlines.scrollByPages(-1, event); + else + Article.scrollByPages(-1, event); + }; + this.hotkey_actions["close_article"] = () => { + if (this.isCombinedMode()) { + Article.cdmUnsetActive(); + } else { + Article.close(); + } + }; + this.hotkey_actions["email_article"] = () => { + if (typeof Plugins.Mail != "undefined") { + Plugins.Mail.onHotkey(Headlines.getSelected()); + } else { + alert(__("Please enable mail or mailto plugin first.")); + } + }; + this.hotkey_actions["select_all"] = () => { + Headlines.select('all'); + }; + this.hotkey_actions["select_unread"] = () => { + Headlines.select('unread'); + }; + this.hotkey_actions["select_marked"] = () => { + Headlines.select('marked'); + }; + this.hotkey_actions["select_published"] = () => { + Headlines.select('published'); + }; + this.hotkey_actions["select_invert"] = () => { + Headlines.select('invert'); + }; + this.hotkey_actions["select_none"] = () => { + Headlines.select('none'); + }; + this.hotkey_actions["feed_refresh"] = () => { + if (typeof Feeds.getActive() != "undefined") { + Feeds.open({feed: Feeds.getActive(), is_cat: Feeds.activeIsCat()}); + } + }; + this.hotkey_actions["feed_unhide_read"] = () => { + Feeds.toggleUnread(); + }; + this.hotkey_actions["feed_subscribe"] = () => { + CommonDialogs.quickAddFeed(); + }; + this.hotkey_actions["feed_debug_update"] = () => { + if (!Feeds.activeIsCat() && parseInt(Feeds.getActive()) > 0) { + //window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + Feeds.getActive()); + + /* global __csrf_token */ + App.postOpenWindow("backend.php", {op: "feeds", method: "update_debugger", feed_id: Feeds.getActive(), csrf_token: __csrf_token}); + + } else { + alert("You can't debug this kind of feed."); + } + }; + + this.hotkey_actions["feed_debug_viewfeed"] = () => { + Feeds.open({feed: Feeds.getActive(), is_cat: Feeds.activeIsCat(), viewfeed_debug: true}); + }; + + this.hotkey_actions["feed_edit"] = () => { + if (Feeds.activeIsCat()) + alert(__("You can't edit this kind of feed.")); + else + CommonDialogs.editFeed(Feeds.getActive()); + }; + this.hotkey_actions["feed_catchup"] = () => { + if (typeof Feeds.getActive() != "undefined") { + Feeds.catchupCurrent(); + } + }; + this.hotkey_actions["feed_reverse"] = () => { + Headlines.reverse(); + }; + this.hotkey_actions["feed_toggle_vgroup"] = () => { + xhrPost("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => { + Feeds.reloadCurrent(); + }) + }; + this.hotkey_actions["catchup_all"] = () => { + Feeds.catchupAll(); + }; + this.hotkey_actions["cat_toggle_collapse"] = () => { + if (Feeds.activeIsCat()) { + dijit.byId("feedTree").collapseCat(Feeds.getActive()); + } + }; + this.hotkey_actions["goto_read"] = () => { + Feeds.open({feed: -6}); + }; + this.hotkey_actions["goto_all"] = () => { + Feeds.open({feed: -4}); + }; + this.hotkey_actions["goto_fresh"] = () => { + Feeds.open({feed: -3}); + }; + this.hotkey_actions["goto_marked"] = () => { + Feeds.open({feed: -1}); + }; + this.hotkey_actions["goto_published"] = () => { + Feeds.open({feed: -2}); + }; + this.hotkey_actions["goto_tagcloud"] = () => { + this.displayDlg(__("Tag cloud"), "printTagCloud"); + }; + this.hotkey_actions["goto_prefs"] = () => { + document.location.href = "prefs.php"; + }; + this.hotkey_actions["select_article_cursor"] = () => { + const id = Article.getUnderPointer(); + if (id) { + const row = $("RROW-" + id); + + if (row) + row.toggleClassName("Selected"); + } + }; + this.hotkey_actions["create_label"] = () => { + CommonDialogs.addLabel(); + }; + this.hotkey_actions["create_filter"] = () => { + Filters.quickAddFilter(); + }; + this.hotkey_actions["collapse_sidebar"] = () => { + Feeds.toggle(); + }; + this.hotkey_actions["toggle_full_text"] = () => { + if (typeof Plugins.Af_Readability != "undefined") { + if (Article.getActive()) + Plugins.Af_Readability.embed(Article.getActive()); + } else { + alert(__("Please enable af_readability first.")); + } + }; + this.hotkey_actions["toggle_widescreen"] = () => { + if (!this.isCombinedMode()) { + this._widescreen_mode = !this._widescreen_mode; + + // reset stored sizes because geometry changed + Cookie.set("ttrss_ci_width", 0); + Cookie.set("ttrss_ci_height", 0); + + this.switchPanelMode(this._widescreen_mode); + } else { + alert(__("Widescreen is not available in combined mode.")); + } + }; + this.hotkey_actions["help_dialog"] = () => { + this.helpDialog("main"); + }; + this.hotkey_actions["toggle_combined_mode"] = () => { + const value = this.isCombinedMode() ? "false" : "true"; + + xhrPost("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => { + this.setInitParam("combined_display_mode", + !this.getInitParam("combined_display_mode")); + + Article.close(); + Headlines.renderAgain(); + }) + }; + this.hotkey_actions["toggle_cdm_expanded"] = () => { + const value = this.getInitParam("cdm_expanded") ? "false" : "true"; + + xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => { + this.setInitParam("cdm_expanded", !this.getInitParam("cdm_expanded")); + Headlines.renderAgain(); + }); + }; + } + }, + onActionSelected: function(opid) { + switch (opid) { + case "qmcPrefs": + document.location.href = "prefs.php"; + break; + case "qmcLogout": + App.postCurrentWindow("public.php", {op: "logout", csrf_token: __csrf_token}); + break; + case "qmcTagCloud": + this.displayDlg(__("Tag cloud"), "printTagCloud"); + break; + case "qmcSearch": + Feeds.search(); + break; + case "qmcAddFeed": + CommonDialogs.quickAddFeed(); + break; + case "qmcDigest": + window.location.href = "backend.php?op=digest"; + break; + case "qmcEditFeed": + if (Feeds.activeIsCat()) + alert(__("You can't edit this kind of feed.")); + else + CommonDialogs.editFeed(Feeds.getActive()); + break; + case "qmcRemoveFeed": + { + const actid = Feeds.getActive(); + + if (!actid) { + alert(__("Please select some feed first.")); + return; + } + + if (Feeds.activeIsCat()) { + alert(__("You can't unsubscribe from the category.")); + return; + } + + const fn = Feeds.getName(actid); + + if (confirm(__("Unsubscribe from %s?").replace("%s", fn))) { + CommonDialogs.unsubscribeFeed(actid); + } + } + break; + case "qmcCatchupAll": + Feeds.catchupAll(); + break; + case "qmcShowOnlyUnread": + Feeds.toggleUnread(); + break; + case "qmcToggleWidescreen": + if (!this.isCombinedMode()) { + this._widescreen_mode = !this._widescreen_mode; + + // reset stored sizes because geometry changed + Cookie.set("ttrss_ci_width", 0); + Cookie.set("ttrss_ci_height", 0); + + this.switchPanelMode(this._widescreen_mode); + } else { + alert(__("Widescreen is not available in combined mode.")); + } + break; + case "qmcHKhelp": + this.helpDialog("main"); + break; + default: + console.log("quickMenuGo: unknown action: " + opid); + } + } +} + diff --git a/js/AppBase.js b/js/AppBase.js deleted file mode 100644 index 86cc44e8a..000000000 --- a/js/AppBase.js +++ /dev/null @@ -1,494 +0,0 @@ -'use strict' -/* global __, ngettext */ -define(["dojo/_base/declare"], function (declare) { - return declare("fox.AppBase", null, { - _initParams: [], - _rpc_seq: 0, - hotkey_prefix: 0, - hotkey_prefix_pressed: false, - hotkey_prefix_timeout: 0, - constructor: function() { - window.onerror = this.Error.onWindowError; - }, - getInitParam: function(k) { - return this._initParams[k]; - }, - setInitParam: function(k, v) { - this._initParams[k] = v; - }, - nightModeChanged: function(is_night, link) { - console.log("night mode changed to", is_night); - - if (link) { - const css_override = is_night ? "themes/night.css" : "themes/light.css"; - link.setAttribute("href", css_override + "?" + Date.now()); - } - }, - setupNightModeDetection: function(callback) { - if (!$("theme_css")) { - const mql = window.matchMedia('(prefers-color-scheme: dark)'); - - try { - mql.addEventListener("change", () => { - this.nightModeChanged(mql.matches, $("theme_auto_css")); - }); - } catch (e) { - console.warn("exception while trying to set MQL event listener"); - } - - const link = new Element("link", { - rel: "stylesheet", - id: "theme_auto_css" - }); - - if (callback) { - link.onload = function () { - document.querySelector("body").removeClassName("css_loading"); - callback(); - }; - - link.onerror = function(event) { - alert("Fatal error while loading application stylesheet: " + link.getAttribute("href")); - } - } - - this.nightModeChanged(mql.matches, link); - - document.querySelector("head").appendChild(link); - } else { - document.querySelector("body").removeClassName("css_loading"); - - if (callback) callback(); - } - }, - enableCsrfSupport: function() { - Ajax.Base.prototype.initialize = Ajax.Base.prototype.initialize.wrap( - function (callOriginal, options) { - - if (App.getInitParam("csrf_token") != undefined) { - Object.extend(options, options || { }); - - if (Object.isString(options.parameters)) - options.parameters = options.parameters.toQueryParams(); - else if (Object.isHash(options.parameters)) - options.parameters = options.parameters.toObject(); - - options.parameters["csrf_token"] = App.getInitParam("csrf_token"); - } - - return callOriginal(options); - } - ); - }, - urlParam: function(param) { - return String(window.location.href).parseQuery()[param]; - }, - next_seq: function() { - this._rpc_seq += 1; - return this._rpc_seq; - }, - get_seq: function() { - return this._rpc_seq; - }, - setLoadingProgress: function(p) { - loading_progress += p; - - if (dijit.byId("loading_bar")) - dijit.byId("loading_bar").update({progress: loading_progress}); - - if (loading_progress >= 90) { - $("overlay").hide(); - } - - }, - keyeventToAction: function(event) { - - const hotkeys_map = App.getInitParam("hotkeys"); - const keycode = event.which; - const keychar = String.fromCharCode(keycode); - - if (keycode == 27) { // escape and drop prefix - this.hotkey_prefix = false; - } - - if (!this.hotkey_prefix && hotkeys_map[0].indexOf(keychar) != -1) { - - this.hotkey_prefix = keychar; - $("cmdline").innerHTML = keychar; - Element.show("cmdline"); - - window.clearTimeout(this.hotkey_prefix_timeout); - this.hotkey_prefix_timeout = window.setTimeout(() => { - this.hotkey_prefix = false; - Element.hide("cmdline"); - }, 3 * 1000); - - event.stopPropagation(); - - return false; - } - - Element.hide("cmdline"); - - let hotkey_name = ""; - - if (event.type == "keydown") { - hotkey_name = "(" + keycode + ")"; - - // ensure ^*char notation - if (event.shiftKey) hotkey_name = "*" + hotkey_name; - if (event.ctrlKey) hotkey_name = "^" + hotkey_name; - if (event.altKey) hotkey_name = "+" + hotkey_name; - if (event.metaKey) hotkey_name = "%" + hotkey_name; - } else { - hotkey_name = keychar ? keychar : "(" + keycode + ")"; - } - - const hotkey_full = this.hotkey_prefix ? this.hotkey_prefix + " " + hotkey_name : hotkey_name; - this.hotkey_prefix = false; - - let action_name = false; - - for (const sequence in hotkeys_map[1]) { - if (hotkeys_map[1].hasOwnProperty(sequence)) { - if (sequence == hotkey_full) { - action_name = hotkeys_map[1][sequence]; - break; - } - } - } - - console.log('keyeventToAction', hotkey_full, '=>', action_name); - - return action_name; - }, - cleanupMemory: function(root) { - const dijits = dojo.query("[widgetid]", dijit.byId(root).domNode).map(dijit.byNode); - - dijits.each(function (d) { - dojo.destroy(d.domNode); - }); - - $$("#" + root + " *").each(function (i) { - i.parentNode ? i.parentNode.removeChild(i) : true; - }); - }, - helpDialog: function(topic) { - const query = "backend.php?op=backend&method=help&topic=" + encodeURIComponent(topic); - - if (dijit.byId("helpDlg")) - dijit.byId("helpDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ - id: "helpDlg", - title: __("Help"), - style: "width: 600px", - href: query, - }); - - dialog.show(); - }, - displayDlg: function(title, id, param, callback) { - Notify.progress("Loading, please wait...", true); - - const query = {op: "dlg", method: id, param: param}; - - xhrPost("backend.php", query, (transport) => { - try { - const content = transport.responseText; - - let dialog = dijit.byId("infoBox"); - - if (!dialog) { - dialog = new dijit.Dialog({ - title: title, - id: 'infoBox', - style: "width: 600px", - onCancel: function () { - return true; - }, - onExecute: function () { - return true; - }, - onClose: function () { - return true; - }, - content: content - }); - } else { - dialog.attr('title', title); - dialog.attr('content', content); - } - - dialog.show(); - - Notify.close(); - - if (callback) callback(transport); - } catch (e) { - this.Error.report(e); - } - }); - - return false; - }, - handleRpcJson: function(transport) { - - const netalert = $$("#toolbar .net-alert")[0]; - - try { - const reply = JSON.parse(transport.responseText); - - if (reply) { - const error = reply['error']; - - if (error) { - const code = error['code']; - const msg = error['message']; - - console.warn("[handleRpcJson] received fatal error ", code, msg); - - if (code != 0) { - /* global ERRORS */ - this.Error.fatal(ERRORS[code], {info: msg, code: code}); - return false; - } - } - - const seq = reply['seq']; - - if (seq && this.get_seq() != seq) { - console.log("[handleRpcJson] sequence mismatch: ", seq, '!=', this.get_seq()); - return true; - } - - const message = reply['message']; - - if (message == "UPDATE_COUNTERS") { - console.log("need to refresh counters..."); - Feeds.requestCounters(true); - } - - const counters = reply['counters']; - - if (counters) - Feeds.parseCounters(counters); - - const runtime_info = reply['runtime-info']; - - if (runtime_info) - App.parseRuntimeInfo(runtime_info); - - if (netalert) netalert.hide(); - - return reply; - - } else { - if (netalert) netalert.show(); - - Notify.error("Communication problem with server."); - } - - } catch (e) { - if (netalert) netalert.show(); - - Notify.error("Communication problem with server."); - - console.error(e); - } - - return false; - }, - parseRuntimeInfo: function(data) { - for (const k in data) { - if (data.hasOwnProperty(k)) { - const v = data[k]; - - console.log("RI:", k, "=>", v); - - if (k == "daemon_is_running" && v != 1) { - Notify.error("<span onclick=\"App.explainError(1)\">Update daemon is not running.</span>", true); - return; - } - - if (k == "recent_log_events") { - const alert = $$(".log-alert")[0]; - - if (alert) { - v > 0 ? alert.show() : alert.hide(); - } - } - - if (k == "daemon_stamp_ok" && v != 1) { - Notify.error("<span onclick=\"App.explainError(3)\">Update daemon is not updating feeds.</span>", true); - return; - } - - if (k == "max_feed_id" || k == "num_feeds") { - if (App.getInitParam(k) != v) { - console.log("feed count changed, need to reload feedlist."); - Feeds.reload(); - } - } - - this.setInitParam(k, v); - } - } - - PluginHost.run(PluginHost.HOOK_RUNTIME_INFO_LOADED, data); - }, - backendSanityCallback: function (transport) { - const reply = JSON.parse(transport.responseText); - - /* global ERRORS */ - - if (!reply) { - this.Error.fatal(ERRORS[3], {info: transport.responseText}); - return; - } - - if (reply['error']) { - const code = reply['error']['code']; - - if (code && code != 0) { - return this.Error.fatal(ERRORS[code], - {code: code, info: reply['error']['message']}); - } - } - - console.log("sanity check ok"); - - const params = reply['init-params']; - - if (params) { - console.log('reading init-params...'); - - for (const k in params) { - if (params.hasOwnProperty(k)) { - switch (k) { - case "label_base_index": - LABEL_BASE_INDEX = parseInt(params[k]); - break; - case "cdm_auto_catchup": - if (params[k] == 1) { - const hl = $("headlines-frame"); - if (hl) hl.addClassName("auto_catchup"); - } - break; - case "hotkeys": - // filter mnemonic definitions (used for help panel) from hotkeys map - // i.e. *(191)|Ctrl-/ -> *(191) - - const tmp = []; - for (const sequence in params[k][1]) { - if (params[k][1].hasOwnProperty(sequence)) { - const filtered = sequence.replace(/\|.*$/, ""); - tmp[filtered] = params[k][1][sequence]; - } - } - - params[k][1] = tmp; - break; - } - - console.log("IP:", k, "=>", params[k]); - this.setInitParam(k, params[k]); - } - } - - // PluginHost might not be available on non-index pages - if (typeof PluginHost !== 'undefined') - PluginHost.run(PluginHost.HOOK_PARAMS_LOADED, App._initParams); - } - - this.initSecondStage(); - }, - explainError: function(code) { - return this.displayDlg(__("Error explained"), "explainError", code); - }, - Error: { - fatal: function (error, params) { - params = params || {}; - - if (params.code) { - if (params.code == 6) { - window.location.href = "index.php"; - return; - } else if (params.code == 5) { - window.location.href = "public.php?op=dbupdate"; - return; - } - } - - return this.report(error, - Object.extend({title: __("Fatal error")}, params)); - }, - report: function(error, params) { - params = params || {}; - - if (!error) return; - - console.error("[Error.report]", error, params); - - const message = params.message ? params.message : error.toString(); - - try { - xhrPost("backend.php", - {op: "rpc", method: "log", - file: params.filename ? params.filename : error.fileName, - line: params.lineno ? params.lineno : error.lineNumber, - msg: message, - context: error.stack}, - (transport) => { - console.warn("[Error.report] log response", transport.responseText); - }); - } catch (re) { - console.error("[Error.report] exception while saving logging error on server", re); - } - - try { - if (dijit.byId("exceptionDlg")) - dijit.byId("exceptionDlg").destroyRecursive(); - - let stack_msg = ""; - - if (error.stack) - stack_msg += `<div><b>Stack trace:</b></div> - <textarea name="stack" readonly="1">${error.stack}</textarea>`; - - if (params.info) - stack_msg += `<div><b>Additional information:</b></div> - <textarea name="stack" readonly="1">${params.info}</textarea>`; - - let content = `<div class="error-contents"> - <p class="message">${message}</p> - ${stack_msg} - <div class="dlgButtons"> - <button dojoType="dijit.form.Button" - onclick=\"dijit.byId('exceptionDlg').hide()">${__('Close this window')}</button> - </div> - </div>`; - - const dialog = new dijit.Dialog({ - id: "exceptionDlg", - title: params.title || __("Unhandled exception"), - style: "width: 600px", - content: content - }); - - dialog.show(); - } catch (de) { - console.error("[Error.report] exception while showing error dialog", de); - - alert(error.stack ? error.stack : message); - } - - }, - onWindowError: function (message, filename, lineno, colno, error) { - // called without context (this) from window.onerror - App.Error.report(error, - {message: message, filename: filename, lineno: lineno, colno: colno}); - }, - } - }); -}); diff --git a/js/Article.js b/js/Article.js index 50447c2a1..76637cd69 100644 --- a/js/Article.js +++ b/js/Article.js @@ -1,243 +1,272 @@ 'use strict' -/* global __, ngettext */ -define(["dojo/_base/declare"], function (declare) { - Article = { - _scroll_reset_timeout: false, - getScoreClass: function (score) { - if (score > 500) { - return "score-high"; - } else if (score > 0) { - return "score-half-high"; - } else if (score < -100) { - return "score-low"; - } else if (score < 0) { - return "score-half-low"; - } else { - return "score-neutral"; - } - }, - getScorePic: function (score) { - if (score > 500) { - return "trending_up"; - } else if (score > 0) { - return "trending_up"; - } else if (score < 0) { - return "trending_down"; - } else { - return "trending_neutral"; - } - }, - selectionSetScore: function () { - const ids = Headlines.getSelected(); - if (ids.length > 0) { - const score = prompt(__("Please enter new score for selected articles:")); +/* global __, ngettext, App, Headlines, xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, $$, Ajax */ + +const Article = { + _scroll_reset_timeout: false, + getScoreClass: function (score) { + if (score > 500) { + return "score-high"; + } else if (score > 0) { + return "score-half-high"; + } else if (score < -100) { + return "score-low"; + } else if (score < 0) { + return "score-half-low"; + } else { + return "score-neutral"; + } + }, + getScorePic: function (score) { + if (score > 500) { + return "trending_up"; + } else if (score > 0) { + return "trending_up"; + } else if (score < 0) { + return "trending_down"; + } else { + return "trending_neutral"; + } + }, + selectionSetScore: function () { + const ids = Headlines.getSelected(); - if (!isNaN(parseInt(score))) { - ids.each((id) => { - const row = $("RROW-" + id); + if (ids.length > 0) { + const score = prompt(__("Please enter new score for selected articles:")); - if (row) { - row.setAttribute("data-score", score); + if (!isNaN(parseInt(score))) { + ids.each((id) => { + const row = $("RROW-" + id); - const pic = row.select(".icon-score")[0]; + if (row) { + row.setAttribute("data-score", score); - pic.innerHTML = Article.getScorePic(score); - pic.setAttribute("title", score); + const pic = row.select(".icon-score")[0]; - ["score-low", "score-high", "score-half-low", "score-half-high", "score-neutral"] - .each(function(scl) { - if (row.hasClassName(scl)) - row.removeClassName(scl); - }); + pic.innerHTML = Article.getScorePic(score); + pic.setAttribute("title", score); - row.addClassName(Article.getScoreClass(score)); - } - }); - } + ["score-low", "score-high", "score-half-low", "score-half-high", "score-neutral"] + .each(function(scl) { + if (row.hasClassName(scl)) + row.removeClassName(scl); + }); - } else { - alert(__("No articles selected.")); + row.addClassName(Article.getScoreClass(score)); + } + }); } - }, - setScore: function (id, pic) { - const row = pic.up("div[id*=RROW]"); - if (row) { - const score_old = row.getAttribute("data-score"); - const score = prompt(__("Please enter new score for this article:"), score_old); - - if (!isNaN(parseInt(score))) { - row.setAttribute("data-score", score); + } else { + alert(__("No articles selected.")); + } + }, + setScore: function (id, pic) { + const row = pic.up("div[id*=RROW]"); - const pic = row.select(".icon-score")[0]; + if (row) { + const score_old = row.getAttribute("data-score"); + const score = prompt(__("Please enter new score for this article:"), score_old); - pic.innerHTML = Article.getScorePic(score); - pic.setAttribute("title", score); + if (!isNaN(parseInt(score))) { + row.setAttribute("data-score", score); - ["score-low", "score-high", "score-half-low", "score-half-high", "score-neutral"] - .each(function(scl) { - if (row.hasClassName(scl)) - row.removeClassName(scl); - }); + const pic = row.select(".icon-score")[0]; - row.addClassName(Article.getScoreClass(score)); - } - } - }, - cdmUnsetActive: function (event) { - const row = $("RROW-" + Article.getActive()); + pic.innerHTML = Article.getScorePic(score); + pic.setAttribute("title", score); - if (row) { - row.removeClassName("active"); - - if (event) - event.stopPropagation(); + ["score-low", "score-high", "score-half-low", "score-half-high", "score-neutral"] + .each(function(scl) { + if (row.hasClassName(scl)) + row.removeClassName(scl); + }); - return false; + row.addClassName(Article.getScoreClass(score)); } - }, - close: function () { - if (dijit.byId("content-insert")) - dijit.byId("headlines-wrap-inner").removeChild( - dijit.byId("content-insert")); - - Article.setActive(0); - }, - displayUrl: function (id) { - const query = {op: "rpc", method: "getlinktitlebyid", id: id}; - - xhrJson("backend.php", query, (reply) => { - if (reply && reply.link) { - prompt(__("Article URL:"), reply.link); - } - }); - }, - openInNewWindow: function (id) { - const w = window.open(""); + } + }, + popupOpenUrl: function(url) { + const w = window.open(""); + + w.opener = null; + w.location = url; + }, + /* popupOpenArticle: function(id) { + const w = window.open("", + "ttrss_article_popup", + "height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no"); + + if (w) { + w.opener = null; + w.location = "backend.php?op=article&method=view&mode=raw&html=1&zoom=1&id=" + id + "&csrf_token=" + App.getInitParam("csrf_token"); + } + }, */ + cdmUnsetActive: function (event) { + const row = $("RROW-" + Article.getActive()); - if (w) { - w.opener = null; - w.location = "backend.php?op=article&method=redirect&id=" + id; + if (row) { + row.removeClassName("active"); - Headlines.toggleUnread(id, 0); - } - }, - render: function (article) { - App.cleanupMemory("content-insert"); + if (event) + event.stopPropagation(); - dijit.byId("headlines-wrap-inner").addChild( + return false; + } + }, + close: function () { + if (dijit.byId("content-insert")) + dijit.byId("headlines-wrap-inner").removeChild( dijit.byId("content-insert")); - const c = dijit.byId("content-insert"); + Article.setActive(0); + }, + displayUrl: function (id) { + const query = {op: "rpc", method: "getlinktitlebyid", id: id}; - try { - c.domNode.scrollTop = 0; - } catch (e) { + xhrJson("backend.php", query, (reply) => { + if (reply && reply.link) { + prompt(__("Article URL:"), reply.link); } + }); + }, + openInNewWindow: function (id) { + /* global __csrf_token */ + App.postOpenWindow("backend.php", + { "op": "article", "method": "redirect", "id": id, "csrf_token": __csrf_token }); + + Headlines.toggleUnread(id, 0); + }, + render: function (article) { + App.cleanupMemory("content-insert"); + + dijit.byId("headlines-wrap-inner").addChild( + dijit.byId("content-insert")); + + const c = dijit.byId("content-insert"); + + try { + c.domNode.scrollTop = 0; + } catch (e) { + } - c.attr('content', article); - PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED, c.domNode); - - Headlines.correctHeadlinesOffset(Article.getActive()); + c.attr('content', article); + PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED, c.domNode); - try { - c.focus(); - } catch (e) { - } - }, - formatComments: function(hl) { - let comments = ""; + //Headlines.correctHeadlinesOffset(Article.getActive()); - if (hl.comments) { - let comments_msg = __("comments"); + try { + c.focus(); + } catch (e) { + } + }, + formatComments: function(hl) { + let comments = ""; - if (hl.num_comments > 0) { - comments_msg = hl.num_comments + " " + ngettext("comment", "comments", hl.num_comments) - } + if (hl.comments || hl.num_comments > 0) { + let comments_msg = __("comments"); - comments = `<a href="${escapeHtml(hl.comments)}">(${comments_msg})</a>`; + if (hl.num_comments > 0) { + comments_msg = hl.num_comments + " " + ngettext("comment", "comments", hl.num_comments) } - return comments; - }, - formatOriginallyFrom: function(hl) { - return hl.orig_feed ? `<span> - ${__('Originally from:')} <a target="_blank" rel="noopener noreferrer" href="${escapeHtml(hl.orig_feed[1])}">${hl.orig_feed[0]}</a> - </span>` : ""; - }, - unpack: function(row) { - if (row.hasAttribute("data-content")) { - console.log("unpacking: " + row.id); + comments = `<a target="_blank" rel="noopener noreferrer" href="${App.escapeHtml(hl.comments ? hl.comments : hl.link)}">(${comments_msg})</a>`; + } - const container = row.querySelector(".content-inner"); + return comments; + }, + formatOriginallyFrom: function(hl) { + return hl.orig_feed ? `<span> + ${__('Originally from:')} <a target="_blank" rel="noopener noreferrer" href="${App.escapeHtml(hl.orig_feed[1])}">${hl.orig_feed[0]}</a> + </span>` : ""; + }, + unpack: function(row) { + if (row.hasAttribute("data-content")) { + console.log("unpacking: " + row.id); - container.innerHTML = row.getAttribute("data-content").trim(); + const container = row.querySelector(".content-inner"); - // blank content element might screw up onclick selection and keyboard moving - if (container.textContent.length == 0) - container.innerHTML += " "; + container.innerHTML = row.getAttribute("data-content").trim(); - row.removeAttribute("data-content"); + // blank content element might screw up onclick selection and keyboard moving + if (container.textContent.length == 0) + container.innerHTML += " "; - PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row); - } - }, - view: function (id, noexpand) { - this.setActive(id); - - if (!noexpand) { - const hl = Headlines.objectById(id); - - if (hl) { - - const comments = this.formatComments(hl); - const originally_from = this.formatOriginallyFrom(hl); - - const article = `<div class="post post-${hl.id}" data-article-id="${hl.id}"> - <div class="header"> - <div class="row"> - <div class="title"><a target="_blank" rel="noopener noreferrer" - title="${escapeHtml(hl.title)}" - href="${escapeHtml(hl.link)}">${hl.title}</a></div> - <div class="date">${hl.updated_long}</div> - </div> - <div class="row"> - <div class="buttons left">${hl.buttons_left}</div> - <div class="comments">${comments}</div> - <div class="author">${hl.author}</div> - <i class="material-icons">label_outline</i> - <span id="ATSTR-${hl.id}">${hl.tags_str}</span> - <a title="${__("Edit tags for this article")}" href="#" - onclick="Article.editTags(${hl.id})">(+)</a> - <div class="buttons right">${hl.buttons}</div> - </div> + // in expandable mode, save content for later, so that we can pack unfocused rows back + if (App.isCombinedMode() && $("main").hasClassName("expandable")) + row.setAttribute("data-content-original", row.getAttribute("data-content")); + + row.removeAttribute("data-content"); + + PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED_CDM, row); + } + }, + pack: function(row) { + if (row.hasAttribute("data-content-original")) { + console.log("packing", row.id); + row.setAttribute("data-content", row.getAttribute("data-content-original")); + row.removeAttribute("data-content-original"); + + row.querySelector(".content-inner").innerHTML = " "; + } + }, + view: function (id, no_expand) { + this.setActive(id); + Headlines.scrollToArticleId(id); + + if (!no_expand) { + const hl = Headlines.objectById(id); + + if (hl) { + + const comments = this.formatComments(hl); + const originally_from = this.formatOriginallyFrom(hl); + + const article = `<div class="post post-${hl.id}" data-article-id="${hl.id}"> + <div class="header"> + <div class="row"> + <div class="title"><a target="_blank" rel="noopener noreferrer" + title="${App.escapeHtml(hl.title)}" + href="${App.escapeHtml(hl.link)}">${hl.title}</a></div> + <div class="date">${hl.updated_long}</div> </div> - <div id="POSTNOTE-${hl.id}">${hl.note}</div> - <div class="content" lang="${hl.lang ? hl.lang : 'en'}"> - ${originally_from} - ${hl.content} - ${hl.enclosures} + <div class="row"> + <div class="buttons left">${hl.buttons_left}</div> + <div class="comments">${comments}</div> + <div class="author">${hl.author}</div> + <i class="material-icons">label_outline</i> + <span id="ATSTR-${hl.id}">${hl.tags_str}</span> + <a title="${__("Edit tags for this article")}" href="#" + onclick="Article.editTags(${hl.id})">(+)</a> + <div class="buttons right">${hl.buttons}</div> </div> - </div>`; + </div> + <div id="POSTNOTE-${hl.id}">${hl.note}</div> + <div class="content" lang="${hl.lang ? hl.lang : 'en'}"> + ${originally_from} + ${hl.content} + ${hl.enclosures} + </div> + </div>`; - Headlines.toggleUnread(id, 0); - this.render(article); - } + Headlines.toggleUnread(id, 0); + this.render(article); } + } - return false; - }, - editTags: function (id) { - const query = "backend.php?op=article&method=editArticleTags¶m=" + encodeURIComponent(id); + return false; + }, + editTags: function (id) { + if (dijit.byId("editTagsDlg")) + dijit.byId("editTagsDlg").destroyRecursive(); - if (dijit.byId("editTagsDlg")) - dijit.byId("editTagsDlg").destroyRecursive(); + xhrPost("backend.php", {op: "article", method: "editarticletags", param: id}, (transport) => { const dialog = new dijit.Dialog({ id: "editTagsDlg", title: __("Edit article Tags"), style: "width: 600px", + content: transport.responseText, execute: function () { if (this.validate()) { Notify.progress("Saving article tags...", true); @@ -264,7 +293,6 @@ define(["dojo/_base/declare"], function (declare) { }); } }, - href: query }); const tmph = dojo.connect(dialog, 'onLoad', function () { @@ -276,39 +304,31 @@ define(["dojo/_base/declare"], function (declare) { }); dialog.show(); - }, - cdmScrollToId: function (id, force, event) { - const ctr = $("headlines-frame"); - const e = $("RROW-" + id); - const is_expanded = App.getInitParam("cdm_expanded"); - - if (!e || !ctr) return; - if (force || is_expanded || e.offsetTop + e.offsetHeight > (ctr.scrollTop + ctr.offsetHeight) || - e.offsetTop < ctr.scrollTop) { + }); - if (event && event.repeat || !is_expanded) { - ctr.addClassName("forbid-smooth-scroll"); - window.clearTimeout(this._scroll_reset_timeout); + }, + cdmMoveToId: function (id, params) { + params = params || {}; - this._scroll_reset_timeout = window.setTimeout(() => { - if (ctr) ctr.removeClassName("forbid-smooth-scroll"); - }, 250) + const force_to_top = params.force_to_top || false; - } else { - ctr.removeClassName("forbid-smooth-scroll"); - } + const ctr = $("headlines-frame"); + const row = $("RROW-" + id); - ctr.scrollTop = e.offsetTop; + if (!row || !ctr) return; - Element.hide("floatingTitle"); - } - }, - setActive: function (id) { - console.log("setActive", id); + if (force_to_top || !App.Scrollable.fitsInContainer(row, ctr)) { + ctr.scrollTop = row.offsetTop; + } + }, + setActive: function (id) { + if (id != Article.getActive()) { + console.log("setActive", id, "was", Article.getActive()); - $$("div[id*=RROW][class*=active]").each((e) => { - e.removeClassName("active"); + $$("div[id*=RROW][class*=active]").each((row) => { + row.removeClassName("active"); + Article.pack(row); }); const row = $("RROW-" + id); @@ -321,50 +341,29 @@ define(["dojo/_base/declare"], function (declare) { PluginHost.run(PluginHost.HOOK_ARTICLE_SET_ACTIVE, row.getAttribute("data-article-id")); } - }, - getActive: function () { - const row = document.querySelector("#headlines-frame > div[id*=RROW][class*=active]"); - - if (row) - return row.getAttribute("data-article-id"); - else - return 0; - }, - scrollByPages: function (page_offset, event) { - const elem = App.isCombinedMode() ? $("headlines-frame") : $("content-insert"); - - const offset = elem.offsetHeight * page_offset * 0.99; - - this.scroll(offset, event); - }, - scroll: function (offset, event) { - - const elem = App.isCombinedMode() ? $("headlines-frame") : $("content-insert"); - - if (event && event.repeat) { - elem.addClassName("forbid-smooth-scroll"); - window.clearTimeout(this._scroll_reset_timeout); - - this._scroll_reset_timeout = window.setTimeout(() => { - if (elem) elem.removeClassName("forbid-smooth-scroll"); - }, 250) - - } else { - elem.removeClassName("forbid-smooth-scroll"); - } - - elem.scrollTop += offset; - }, - mouseIn: function (id) { - this.post_under_pointer = id; - }, - mouseOut: function (id) { - this.post_under_pointer = false; - }, - getUnderPointer: function () { - return this.post_under_pointer; } + }, + getActive: function () { + const row = document.querySelector("#headlines-frame > div[id*=RROW][class*=active]"); + + if (row) + return row.getAttribute("data-article-id"); + else + return 0; + }, + scrollByPages: function (page_offset) { + App.Scrollable.scrollByPages($("content-insert"), page_offset); + }, + scroll: function (offset) { + App.Scrollable.scroll($("content-insert"), offset); + }, + mouseIn: function (id) { + this.post_under_pointer = id; + }, + mouseOut: function (/* id */) { + this.post_under_pointer = false; + }, + getUnderPointer: function () { + return this.post_under_pointer; } - - return Article; -}); +} diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index c6d476de0..c59ef9b25 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -1,8 +1,9 @@ 'use strict' -/* global __, ngettext */ -define(["dojo/_base/declare"], function (declare) { - // noinspection JSUnusedGlobalSymbols - CommonDialogs = { + +/* global __, ngettext, dojo, dijit, Notify, App, Feeds, $$, xhrPost, xhrJson, Tables, Effect */ + +/* exported CommonDialogs */ +const CommonDialogs = { closeInfoBox: function() { const dialog = dijit.byId("infoBox"); if (dialog) dialog.hide(); @@ -45,18 +46,20 @@ define(["dojo/_base/declare"], function (declare) { xhr.onload = function () { switch (parseInt(this.responseText)) { case 0: - Notify.info("Upload complete."); + { + Notify.info("Upload complete."); - if (App.isPrefs()) - dijit.byId("feedTree").reload(); - else - Feeds.reload(); + if (App.isPrefs()) + dijit.byId("feedTree").reload(); + else + Feeds.reload(); - const icon = $$(".feed-editor-icon")[0]; + const icon = $$(".feed-editor-icon")[0]; - if (icon) - icon.src = icon.src.replace(/\?[0-9]+$/, "?" + new Date().getTime()); + if (icon) + icon.src = icon.src.replace(/\?[0-9]+$/, "?" + new Date().getTime()); + } break; case 1: Notify.error("Upload failed: icon is too big."); @@ -72,115 +75,120 @@ define(["dojo/_base/declare"], function (declare) { return false; }, quickAddFeed: function() { - const query = "backend.php?op=feeds&method=quickAddFeed"; // overlapping widgets if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive(); if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive(); - const dialog = new dijit.Dialog({ - id: "feedAddDlg", - title: __("Subscribe to Feed"), - style: "width: 600px", - show_error: function (msg) { - const elem = $("fadd_error_message"); - - elem.innerHTML = msg; - - if (!Element.visible(elem)) - new Effect.Appear(elem); - - }, - execute: function () { - if (this.validate()) { - console.log(dojo.objectToQuery(this.attr('value'))); - - const feed_url = this.attr('value').feed; - - Element.show("feed_add_spinner"); - Element.hide("fadd_error_message"); - - xhrPost("backend.php", this.attr('value'), (transport) => { - try { - - try { - var reply = JSON.parse(transport.responseText); - } catch (e) { - Element.hide("feed_add_spinner"); - alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console.")); - console.log('quickAddFeed, backend returned:' + transport.responseText); - return; - } - - const rc = reply['result']; + xhrPost("backend.php", + {op: "feeds", method: "quickAddFeed"}, + (transport) => { - Notify.close(); - Element.hide("feed_add_spinner"); + const dialog = new dijit.Dialog({ + id: "feedAddDlg", + title: __("Subscribe to Feed"), + style: "width: 600px", + content: transport.responseText, + show_error: function (msg) { + const elem = $("fadd_error_message"); - console.log(rc); + elem.innerHTML = msg; - switch (parseInt(rc['code'])) { - case 1: - dialog.hide(); - Notify.info(__("Subscribed to %s").replace("%s", feed_url)); + if (!Element.visible(elem)) + new Effect.Appear(elem); - if (App.isPrefs()) - dijit.byId("feedTree").reload(); - else - Feeds.reload(); + }, + execute: function () { + if (this.validate()) { + console.log(dojo.objectToQuery(this.attr('value'))); - break; - case 2: - dialog.show_error(__("Specified URL seems to be invalid.")); - break; - case 3: - dialog.show_error(__("Specified URL doesn't seem to contain any feeds.")); - break; - case 4: - const feeds = rc['feeds']; + const feed_url = this.attr('value').feed; - Element.show("fadd_multiple_notify"); + Element.show("feed_add_spinner"); + Element.hide("fadd_error_message"); - const select = dijit.byId("feedDlg_feedContainerSelect"); + xhrPost("backend.php", this.attr('value'), (transport) => { + try { - while (select.getOptions().length > 0) - select.removeOption(0); + let reply; - select.addOption({value: '', label: __("Expand to select feed")}); + try { + reply = JSON.parse(transport.responseText); + } catch (e) { + Element.hide("feed_add_spinner"); + alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console.")); + console.log('quickAddFeed, backend returned:' + transport.responseText); + return; + } - let count = 0; - for (const feedUrl in feeds) { - if (feeds.hasOwnProperty(feedUrl)) { - select.addOption({value: feedUrl, label: feeds[feedUrl]}); - count++; + const rc = reply['result']; + + Notify.close(); + Element.hide("feed_add_spinner"); + + console.log(rc); + + switch (parseInt(rc['code'])) { + case 1: + dialog.hide(); + Notify.info(__("Subscribed to %s").replace("%s", feed_url)); + + if (App.isPrefs()) + dijit.byId("feedTree").reload(); + else + Feeds.reload(); + + break; + case 2: + dialog.show_error(__("Specified URL seems to be invalid.")); + break; + case 3: + dialog.show_error(__("Specified URL doesn't seem to contain any feeds.")); + break; + case 4: + { + const feeds = rc['feeds']; + + Element.show("fadd_multiple_notify"); + + const select = dijit.byId("feedDlg_feedContainerSelect"); + + while (select.getOptions().length > 0) + select.removeOption(0); + + select.addOption({value: '', label: __("Expand to select feed")}); + + for (const feedUrl in feeds) { + if (feeds.hasOwnProperty(feedUrl)) { + select.addOption({value: feedUrl, label: feeds[feedUrl]}); + } + } + + Effect.Appear('feedDlg_feedsContainer', {duration: 0.5}); + } + break; + case 5: + dialog.show_error(__("Couldn't download the specified URL: %s").replace("%s", rc['message'])); + break; + case 6: + dialog.show_error(__("XML validation failed: %s").replace("%s", rc['message'])); + break; + case 0: + dialog.show_error(__("You are already subscribed to this feed.")); + break; } - } - Effect.Appear('feedDlg_feedsContainer', {duration: 0.5}); - - break; - case 5: - dialog.show_error(__("Couldn't download the specified URL: %s").replace("%s", rc['message'])); - break; - case 6: - dialog.show_error(__("XML validation failed: %s").replace("%s", rc['message'])); - break; - case 0: - dialog.show_error(__("You are already subscribed to this feed.")); - break; + } catch (e) { + console.error(transport.responseText); + App.Error.report(e); + } + }); } - - } catch (e) { - console.error(transport.responseText); - App.Error.report(e); - } + }, }); - } - }, - href: query - }); - dialog.show(); + dialog.show(); + }); }, showFeedsWithErrors: function() { const query = {op: "pref-feeds", method: "feedsWithErrors"}; @@ -436,7 +444,7 @@ define(["dojo/_base/declare"], function (declare) { Notify.close(); if (App.isPrefs()) - dijit.byId("feedTree").reload(); + dijit.byId("feedTree") && dijit.byId("feedTree").reload(); else Feeds.reload(); @@ -478,6 +486,3 @@ define(["dojo/_base/declare"], function (declare) { return false; } }; - - return CommonDialogs; -}); diff --git a/js/CommonFilters.js b/js/CommonFilters.js index 1538a3fb3..9676abe9e 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -1,398 +1,383 @@ 'use strict' -/* global __, ngettext */ -define(["dojo/_base/declare"], function (declare) { - Filters = { - filterDlgCheckRegExp: function(sender) { - const tooltip = dijit.byId("filterDlg_regExp_tip").domNode; - try { - sender.domNode.removeClassName("invalid"); - sender.domNode.removeClassName("valid"); +/* global __, App, Article, Lists, Effect */ +/* global xhrPost, dojo, dijit, Notify, $$, Feeds */ - new RegExp("/" + sender.value + "/"); +const Filters = { + filterDlgCheckAction: function(sender) { + const action = sender.value; - sender.domNode.addClassName("valid"); - tooltip.innerText = __("Regular expression, without outer delimiters (i.e. slashes)"); + const action_param = $("filterDlg_paramBox"); - } catch (e) { - sender.domNode.addClassName("invalid"); + if (!action_param) { + console.log("filterDlgCheckAction: can't find action param box!"); + return; + } - tooltip.innerText = e.message; - } - }, - filterDlgCheckAction: function(sender) { - const action = sender.value; + // if selected action supports parameters, enable params field + if (action == 4 || action == 6 || action == 7 || action == 9) { + new Effect.Appear(action_param, {duration: 0.5}); - const action_param = $("filterDlg_paramBox"); + Element.hide(dijit.byId("filterDlg_actionParam").domNode); + Element.hide(dijit.byId("filterDlg_actionParamLabel").domNode); + Element.hide(dijit.byId("filterDlg_actionParamPlugin").domNode); - if (!action_param) { - console.log("filterDlgCheckAction: can't find action param box!"); - return; + if (action == 7) { + Element.show(dijit.byId("filterDlg_actionParamLabel").domNode); + } else if (action == 9) { + Element.show(dijit.byId("filterDlg_actionParamPlugin").domNode); + } else { + Element.show(dijit.byId("filterDlg_actionParam").domNode); } - // if selected action supports parameters, enable params field - if (action == 4 || action == 6 || action == 7 || action == 9) { - new Effect.Appear(action_param, {duration: 0.5}); - - Element.hide(dijit.byId("filterDlg_actionParam").domNode); - Element.hide(dijit.byId("filterDlg_actionParamLabel").domNode); - Element.hide(dijit.byId("filterDlg_actionParamPlugin").domNode); + } else { + Element.hide(action_param); + } + }, + createNewRuleElement: function(parentNode, replaceNode) { + const form = document.forms["filter_new_rule_form"]; + const query = {op: "pref-filters", method: "printrulename", rule: dojo.formToJson(form)}; - if (action == 7) { - Element.show(dijit.byId("filterDlg_actionParamLabel").domNode); - } else if (action == 9) { - Element.show(dijit.byId("filterDlg_actionParamPlugin").domNode); + xhrPost("backend.php", query, (transport) => { + try { + const li = dojo.create("li"); + + const cb = dojo.create("input", {type: "checkbox"}, li); + + new dijit.form.CheckBox({ + onChange: function () { + Lists.onRowChecked(this); + }, + }, cb); + + dojo.create("input", { + type: "hidden", + name: "rule[]", + value: dojo.formToJson(form) + }, li); + + dojo.create("span", { + onclick: function () { + dijit.byId('filterEditDlg').editRule(this); + }, + innerHTML: transport.responseText + }, li); + + if (replaceNode) { + parentNode.replaceChild(li, replaceNode); } else { - Element.show(dijit.byId("filterDlg_actionParam").domNode); + parentNode.appendChild(li); } - - } else { - Element.hide(action_param); + } catch (e) { + App.Error.report(e); } - }, - createNewRuleElement: function(parentNode, replaceNode) { - const form = document.forms["filter_new_rule_form"]; - const query = {op: "pref-filters", method: "printrulename", rule: dojo.formToJson(form)}; - - xhrPost("backend.php", query, (transport) => { - try { - const li = dojo.create("li"); - - const cb = dojo.create("input", {type: "checkbox"}, li); - - new dijit.form.CheckBox({ - onChange: function () { - Lists.onRowChecked(this); - }, - }, cb); - - dojo.create("input", { - type: "hidden", - name: "rule[]", - value: dojo.formToJson(form) - }, li); - - dojo.create("span", { - onclick: function () { - dijit.byId('filterEditDlg').editRule(this); - }, - innerHTML: transport.responseText - }, li); - - if (replaceNode) { - parentNode.replaceChild(li, replaceNode); - } else { - parentNode.appendChild(li); - } - } catch (e) { - App.Error.report(e); + }); + }, + createNewActionElement: function(parentNode, replaceNode) { + const form = document.forms["filter_new_action_form"]; + + if (form.action_id.value == 7) { + form.action_param.value = form.action_param_label.value; + } else if (form.action_id.value == 9) { + form.action_param.value = form.action_param_plugin.value; + } + + const query = { + op: "pref-filters", method: "printactionname", + action: dojo.formToJson(form) + }; + + xhrPost("backend.php", query, (transport) => { + try { + const li = dojo.create("li"); + + const cb = dojo.create("input", {type: "checkbox"}, li); + + new dijit.form.CheckBox({ + onChange: function () { + Lists.onRowChecked(this); + }, + }, cb); + + dojo.create("input", { + type: "hidden", + name: "action[]", + value: dojo.formToJson(form) + }, li); + + dojo.create("span", { + onclick: function () { + dijit.byId('filterEditDlg').editAction(this); + }, + innerHTML: transport.responseText + }, li); + + if (replaceNode) { + parentNode.replaceChild(li, replaceNode); + } else { + parentNode.appendChild(li); } - }); - }, - createNewActionElement: function(parentNode, replaceNode) { - const form = document.forms["filter_new_action_form"]; - - if (form.action_id.value == 7) { - form.action_param.value = form.action_param_label.value; - } else if (form.action_id.value == 9) { - form.action_param.value = form.action_param_plugin.value; - } - - const query = { - op: "pref-filters", method: "printactionname", - action: dojo.formToJson(form) - }; - - xhrPost("backend.php", query, (transport) => { - try { - const li = dojo.create("li"); - - const cb = dojo.create("input", {type: "checkbox"}, li); - - new dijit.form.CheckBox({ - onChange: function () { - Lists.onRowChecked(this); - }, - }, cb); - - dojo.create("input", { - type: "hidden", - name: "action[]", - value: dojo.formToJson(form) - }, li); - - dojo.create("span", { - onclick: function () { - dijit.byId('filterEditDlg').editAction(this); - }, - innerHTML: transport.responseText - }, li); - - if (replaceNode) { - parentNode.replaceChild(li, replaceNode); - } else { - parentNode.appendChild(li); - } - } catch (e) { - App.Error.report(e); + } catch (e) { + App.Error.report(e); + } + }); + }, + addFilterRule: function(replaceNode, ruleStr) { + if (dijit.byId("filterNewRuleDlg")) + dijit.byId("filterNewRuleDlg").destroyRecursive(); + + const rule_dlg = new dijit.Dialog({ + id: "filterNewRuleDlg", + title: ruleStr ? __("Edit rule") : __("Add rule"), + style: "width: 600px", + execute: function () { + if (this.validate()) { + Filters.createNewRuleElement($("filterDlg_Matches"), replaceNode); + this.hide(); } - }); - }, - addFilterRule: function(replaceNode, ruleStr) { - if (dijit.byId("filterNewRuleDlg")) - dijit.byId("filterNewRuleDlg").destroyRecursive(); - - const query = "backend.php?op=pref-filters&method=newrule&rule=" + - encodeURIComponent(ruleStr); - - const rule_dlg = new dijit.Dialog({ - id: "filterNewRuleDlg", - title: ruleStr ? __("Edit rule") : __("Add rule"), - style: "width: 600px", - execute: function () { - if (this.validate()) { - Filters.createNewRuleElement($("filterDlg_Matches"), replaceNode); - this.hide(); - } - }, - href: query - }); - - rule_dlg.show(); - }, - addFilterAction: function(replaceNode, actionStr) { - if (dijit.byId("filterNewActionDlg")) - dijit.byId("filterNewActionDlg").destroyRecursive(); - - const query = "backend.php?op=pref-filters&method=newaction&action=" + - encodeURIComponent(actionStr); - - const rule_dlg = new dijit.Dialog({ - id: "filterNewActionDlg", - title: actionStr ? __("Edit action") : __("Add action"), - style: "width: 600px", - execute: function () { - if (this.validate()) { - Filters.createNewActionElement($("filterDlg_Actions"), replaceNode); - this.hide(); - } - }, - href: query - }); + }, + content: __('Loading, please wait...'), + }); - rule_dlg.show(); - }, - editFilterTest: function(query) { + const tmph = dojo.connect(rule_dlg, "onShow", null, function (/* e */) { + dojo.disconnect(tmph); - if (dijit.byId("filterTestDlg")) - dijit.byId("filterTestDlg").destroyRecursive(); - - const test_dlg = new dijit.Dialog({ - id: "filterTestDlg", - title: "Test Filter", - style: "width: 600px", - results: 0, - limit: 100, - max_offset: 10000, - getTestResults: function (query, offset) { - const updquery = query + "&offset=" + offset + "&limit=" + test_dlg.limit; - - console.log("getTestResults:" + offset); + xhrPost("backend.php", {op: 'pref-filters', method: 'newrule', rule: ruleStr}, (transport) => { + rule_dlg.attr('content', transport.responseText); + }); + }); + + rule_dlg.show(); + }, + addFilterAction: function(replaceNode, actionStr) { + if (dijit.byId("filterNewActionDlg")) + dijit.byId("filterNewActionDlg").destroyRecursive(); + + const query = "backend.php?op=pref-filters&method=newaction&action=" + + encodeURIComponent(actionStr); + + const rule_dlg = new dijit.Dialog({ + id: "filterNewActionDlg", + title: actionStr ? __("Edit action") : __("Add action"), + style: "width: 600px", + execute: function () { + if (this.validate()) { + Filters.createNewActionElement($("filterDlg_Actions"), replaceNode); + this.hide(); + } + }, + href: query + }); - xhrPost("backend.php", updquery, (transport) => { - try { - const result = JSON.parse(transport.responseText); + rule_dlg.show(); + }, + editFilterTest: function(params) { - if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) { - test_dlg.results += result.length; + if (dijit.byId("filterTestDlg")) + dijit.byId("filterTestDlg").destroyRecursive(); - console.log("got results:" + result.length); + const test_dlg = new dijit.Dialog({ + id: "filterTestDlg", + title: "Test Filter", + style: "width: 600px", + results: 0, + limit: 100, + max_offset: 10000, + getTestResults: function (params, offset) { + params.method = 'testFilterDo'; + params.offset = offset; + params.limit = test_dlg.limit; - $("prefFilterProgressMsg").innerHTML = __("Looking for articles (%d processed, %f found)...") - .replace("%f", test_dlg.results) - .replace("%d", offset); + console.log("getTestResults:" + offset); - console.log(offset + " " + test_dlg.max_offset); + xhrPost("backend.php", params, (transport) => { + try { + const result = JSON.parse(transport.responseText); - for (let i = 0; i < result.length; i++) { - const tmp = new Element("table"); - tmp.innerHTML = result[i]; - dojo.parser.parse(tmp); + if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) { + test_dlg.results += result.length; - $("prefFilterTestResultList").innerHTML += tmp.innerHTML; - } + console.log("got results:" + result.length); - if (test_dlg.results < 30 && offset < test_dlg.max_offset) { + $("prefFilterProgressMsg").innerHTML = __("Looking for articles (%d processed, %f found)...") + .replace("%f", test_dlg.results) + .replace("%d", offset); - // get the next batch - window.setTimeout(function () { - test_dlg.getTestResults(query, offset + test_dlg.limit); - }, 0); + console.log(offset + " " + test_dlg.max_offset); - } else { - // all done + for (let i = 0; i < result.length; i++) { + const tmp = dojo.create("table", { innerHTML: result[i]}); - Element.hide("prefFilterLoadingIndicator"); + $("prefFilterTestResultList").innerHTML += tmp.innerHTML; + } - if (test_dlg.results == 0) { - $("prefFilterTestResultList").innerHTML = `<tr><td align='center'> - ${__('No recent articles matching this filter have been found.')}</td></tr>`; - $("prefFilterProgressMsg").innerHTML = "Articles matching this filter:"; - } else { - $("prefFilterProgressMsg").innerHTML = __("Found %d articles matching this filter:") - .replace("%d", test_dlg.results); - } + if (test_dlg.results < 30 && offset < test_dlg.max_offset) { - } + // get the next batch + window.setTimeout(function () { + test_dlg.getTestResults(params, offset + test_dlg.limit); + }, 0); - } else if (!result) { - console.log("getTestResults: can't parse results object"); + } else { + // all done Element.hide("prefFilterLoadingIndicator"); - Notify.error("Error while trying to get filter test results."); + if (test_dlg.results == 0) { + $("prefFilterTestResultList").innerHTML = `<tr><td align='center'> + ${__('No recent articles matching this filter have been found.')}</td></tr>`; + $("prefFilterProgressMsg").innerHTML = "Articles matching this filter:"; + } else { + $("prefFilterProgressMsg").innerHTML = __("Found %d articles matching this filter:") + .replace("%d", test_dlg.results); + } - } else { - console.log("getTestResults: dialog closed, bailing out."); } - } catch (e) { - App.Error.report(e); - } - }); - }, - href: query - }); + } else if (!result) { + console.log("getTestResults: can't parse results object"); - dojo.connect(test_dlg, "onLoad", null, function (e) { - test_dlg.getTestResults(query, 0); - }); + Element.hide("prefFilterLoadingIndicator"); - test_dlg.show(); - }, - quickAddFilter: function() { - let query; + Notify.error("Error while trying to get filter test results."); - if (!App.isPrefs()) { - query = { - op: "pref-filters", method: "newfilter", - feed: Feeds.getActive(), is_cat: Feeds.activeIsCat() - }; - } else { - query = {op: "pref-filters", method: "newfilter"}; - } - - console.log('quickAddFilter', query); - - if (dijit.byId("feedEditDlg")) - dijit.byId("feedEditDlg").destroyRecursive(); - - if (dijit.byId("filterEditDlg")) - dijit.byId("filterEditDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ - id: "filterEditDlg", - title: __("Create Filter"), - style: "width: 600px", - test: function () { - const query = "backend.php?" + dojo.formToQuery("filter_new_form") + "&savemode=test"; - - Filters.editFilterTest(query); - }, - selectRules: function (select) { - Lists.select("filterDlg_Matches", select); - }, - selectActions: function (select) { - Lists.select("filterDlg_Actions", select); - }, - editRule: function (e) { - const li = e.parentNode; - const rule = li.getElementsByTagName("INPUT")[1].value; - Filters.addFilterRule(li, rule); - }, - editAction: function (e) { - const li = e.parentNode; - const action = li.getElementsByTagName("INPUT")[1].value; - Filters.addFilterAction(li, action); - }, - addAction: function () { - Filters.addFilterAction(); - }, - addRule: function () { - Filters.addFilterRule(); - }, - deleteAction: function () { - $$("#filterDlg_Actions li[class*=Selected]").each(function (e) { - e.parentNode.removeChild(e) - }); - }, - deleteRule: function () { - $$("#filterDlg_Matches li[class*=Selected]").each(function (e) { - e.parentNode.removeChild(e) - }); - }, - execute: function () { - if (this.validate()) { + } else { + console.log("getTestResults: dialog closed, bailing out."); + } + } catch (e) { + App.Error.report(e); + } - const query = dojo.formToQuery("filter_new_form"); + }); + }, + href: "backend.php?op=pref-filters&method=testFilterDlg" + }); + + dojo.connect(test_dlg, "onLoad", null, function (/* e */) { + test_dlg.getTestResults(params, 0); + }); + + test_dlg.show(); + }, + quickAddFilter: function() { + let query; + + if (!App.isPrefs()) { + query = { + op: "pref-filters", method: "newfilter", + feed: Feeds.getActive(), is_cat: Feeds.activeIsCat() + }; + } else { + query = {op: "pref-filters", method: "newfilter"}; + } + + console.log('quickAddFilter', query); + + if (dijit.byId("feedEditDlg")) + dijit.byId("feedEditDlg").destroyRecursive(); + + if (dijit.byId("filterEditDlg")) + dijit.byId("filterEditDlg").destroyRecursive(); + + const dialog = new dijit.Dialog({ + id: "filterEditDlg", + title: __("Create Filter"), + style: "width: 600px", + test: function () { + Filters.editFilterTest(dojo.formToObject("filter_new_form")); + }, + selectRules: function (select) { + Lists.select("filterDlg_Matches", select); + }, + selectActions: function (select) { + Lists.select("filterDlg_Actions", select); + }, + editRule: function (e) { + const li = e.parentNode; + const rule = li.getElementsByTagName("INPUT")[1].value; + Filters.addFilterRule(li, rule); + }, + editAction: function (e) { + const li = e.parentNode; + const action = li.getElementsByTagName("INPUT")[1].value; + Filters.addFilterAction(li, action); + }, + addAction: function () { + Filters.addFilterAction(); + }, + addRule: function () { + Filters.addFilterRule(); + }, + deleteAction: function () { + $$("#filterDlg_Actions li[class*=Selected]").each(function (e) { + e.parentNode.removeChild(e) + }); + }, + deleteRule: function () { + $$("#filterDlg_Matches li[class*=Selected]").each(function (e) { + e.parentNode.removeChild(e) + }); + }, + execute: function () { + if (this.validate()) { - xhrPost("backend.php", query, () => { - if (App.isPrefs()) { - dijit.byId("filterTree").reload(); - } + const query = dojo.formToQuery("filter_new_form"); - dialog.hide(); - }); - } - }, - href: "backend.php?" + dojo.objectToQuery(query) - }); + xhrPost("backend.php", query, () => { + if (App.isPrefs()) { + dijit.byId("filterTree").reload(); + } - if (!App.isPrefs()) { - const selectedText = getSelectionText(); + dialog.hide(); + }); + } + }, + href: "backend.php?" + dojo.objectToQuery(query) + }); - const lh = dojo.connect(dialog, "onLoad", function () { - dojo.disconnect(lh); + if (!App.isPrefs()) { + /* global getSelectionText */ + const selectedText = getSelectionText(); - if (selectedText != "") { + const lh = dojo.connect(dialog, "onLoad", function () { + dojo.disconnect(lh); - const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) : - Feeds.getActive(); + if (selectedText != "") { - const rule = {reg_exp: selectedText, feed_id: [feed_id], filter_type: 1}; + const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) : + Feeds.getActive(); - Filters.addFilterRule(null, dojo.toJson(rule)); + const rule = {reg_exp: selectedText, feed_id: [feed_id], filter_type: 1}; - } else { + Filters.addFilterRule(null, dojo.toJson(rule)); - const query = {op: "rpc", method: "getlinktitlebyid", id: Article.getActive()}; + } else { - xhrPost("backend.php", query, (transport) => { - const reply = JSON.parse(transport.responseText); + const query = {op: "rpc", method: "getlinktitlebyid", id: Article.getActive()}; - let title = false; + xhrPost("backend.php", query, (transport) => { + const reply = JSON.parse(transport.responseText); - if (reply && reply.title) title = reply.title; + let title = false; - if (title || Feeds.getActive() || Feeds.activeIsCat()) { + if (reply && reply.title) title = reply.title; - console.log(title + " " + Feeds.getActive()); + if (title || Feeds.getActive() || Feeds.activeIsCat()) { - const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) : - Feeds.getActive(); + console.log(title + " " + Feeds.getActive()); - const rule = {reg_exp: title, feed_id: [feed_id], filter_type: 1}; + const feed_id = Feeds.activeIsCat() ? 'CAT:' + parseInt(Feeds.getActive()) : + Feeds.getActive(); - Filters.addFilterRule(null, dojo.toJson(rule)); - } - }); - } - }); - } - dialog.show(); - }, - }; + const rule = {reg_exp: title, feed_id: [feed_id], filter_type: 1}; - return Filters; -}); + Filters.addFilterRule(null, dojo.toJson(rule)); + } + }); + } + }); + } + dialog.show(); + }, +}; diff --git a/js/FeedStoreModel.js b/js/FeedStoreModel.js index 7d8020871..736bfbed6 100644 --- a/js/FeedStoreModel.js +++ b/js/FeedStoreModel.js @@ -1,10 +1,12 @@ +/* global define, dijit */ + define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare) { return declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, { getItemsInCategory: function (id) { if (!this.store._itemsByIdentity) return undefined; - let cat = this.store._itemsByIdentity['CAT:' + id]; + const cat = this.store._itemsByIdentity['CAT:' + id]; if (cat && cat.items) return cat.items; @@ -18,6 +20,8 @@ define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare) getFeedValue: function (feed, is_cat, key) { if (!this.store._itemsByIdentity) return undefined; + let treeItem; + if (is_cat) treeItem = this.store._itemsByIdentity['CAT:' + feed]; else @@ -40,6 +44,8 @@ define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare) if (!value) value = ''; if (!this.store._itemsByIdentity) return undefined; + let treeItem; + if (is_cat) treeItem = this.store._itemsByIdentity['CAT:' + feed]; else @@ -52,29 +58,31 @@ define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare) if (!this.store._itemsByIdentity) return null; + let treeItem; + if (is_cat) { treeItem = this.store._itemsByIdentity['CAT:' + feed]; } else { treeItem = this.store._itemsByIdentity['FEED:' + feed]; } - let items = this.store._arrayOfAllItems; + const items = this.store._arrayOfAllItems; for (let i = 0; i < items.length; i++) { if (items[i] == treeItem) { - for (var j = i + 1; j < items.length; j++) { - let unread = this.store.getValue(items[j], 'unread'); - let id = this.store.getValue(items[j], 'id'); + for (let j = i + 1; j < items.length; j++) { + const unread = this.store.getValue(items[j], 'unread'); + const id = this.store.getValue(items[j], 'id'); if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) { if (!is_cat || !(this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed)) return items[j]; } } - for (var j = 0; j < i; j++) { - let unread = this.store.getValue(items[j], 'unread'); - let id = this.store.getValue(items[j], 'id'); + for (let j = 0; j < i; j++) { + const unread = this.store.getValue(items[j], 'unread'); + const id = this.store.getValue(items[j], 'id'); if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) { if (!is_cat || !(this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed)) return items[j]; diff --git a/js/FeedTree.js b/js/FeedTree.js index 85892b3d9..c61d8a50f 100755 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -1,11 +1,46 @@ -/* global dijit */ -define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct) { +/* eslint-disable prefer-rest-params */ +/* global __, dojo, dijit, define, App, Feeds, CommonDialogs */ + +define(["dojo/_base/declare", "dojo/dom-construct", "dojo/_base/array", "dojo/cookie", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct, array, cookie) { return declare("fox.FeedTree", dijit.Tree, { - _onContainerKeydown: function(/* Event */ e) { + // save state in localStorage instead of cookies + // reference: https://stackoverflow.com/a/27968996 + _saveExpandedNodes: function(){ + if(this.persist && this.cookieName){ + var ary = []; + for(var id in this._openedNodes){ + ary.push(id); + } + // Was: + // cookie(this.cookieName, ary.join(","), {expires: 365}); + localStorage.setItem(this.cookieName, ary.join(",")); + } + }, + _initState: function(){ + // summary: + // Load in which nodes should be opened automatically + this._openedNodes = {}; + if(this.persist && this.cookieName){ + // Was: + // var oreo = cookie(this.cookieName); + var oreo = localStorage.getItem(this.cookieName); + // migrate old data if nothing in localStorage + if(oreo == null || oreo === '') { + oreo = cookie(this.cookieName); + cookie(this.cookieName, null, { expires: -1 }); + } + if(oreo){ + array.forEach(oreo.split(','), function(item){ + this._openedNodes[item] = true; + }, this); + } + } + }, + _onContainerKeydown: function(/* Event */ /* e */) { return; // Stop dijit.Tree from interpreting keystrokes }, - _onContainerKeypress: function(/* Event */ e) { + _onContainerKeypress: function(/* Event */ /* e */) { return; // Stop dijit.Tree from interpreting keystrokes }, _createTreeNode: function(args) { @@ -33,7 +68,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], const id = args.item.id[0]; const bare_id = parseInt(id.substr(id.indexOf(':')+1)); - if (bare_id < LABEL_BASE_INDEX) { + if (bare_id < App.LABEL_BASE_INDEX) { const label = dojo.create('i', { className: "material-icons icon icon-label", innerHTML: "label" }); //const fg_color = args.item.fg_color[0]; @@ -47,7 +82,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], } if (id.match("FEED:")) { - let menu = new dijit.Menu(); + const menu = new dijit.Menu(); menu.row_id = bare_id; menu.addChild(new dijit.MenuItem({ @@ -66,8 +101,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], menu.addChild(new dijit.MenuItem({ label: __("Debug feed"), onClick: function() { - window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + this.getParent().row_id + - "&csrf_token=" + App.getInitParam("csrf_token")); + /* global __csrf_token */ + App.postOpenWindow("backend.php", {op: "feeds", method: "update_debugger", + feed_id: this.getParent().row_id, csrf_token: __csrf_token}); }})); } @@ -76,7 +112,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], } if (id.match("CAT:") && bare_id >= 0) { - let menu = new dijit.Menu(); + const menu = new dijit.Menu(); menu.row_id = bare_id; menu.addChild(new dijit.MenuItem({ @@ -101,7 +137,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], } if (id.match("CAT:") && bare_id == -1) { - let menu = new dijit.Menu(); + const menu = new dijit.Menu(); menu.row_id = bare_id; menu.addChild(new dijit.MenuItem({ @@ -145,15 +181,16 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], } }, getTooltip: function (item) { - return [item.updated, item.error].filter(x => x && x != "").join(" - "); + return [item.updated, item.error].filter((x) => x && x != "").join(" - "); }, getIconClass: function (item, opened) { + // eslint-disable-next-line no-nested-ternary return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon"; }, - getLabelClass: function (item, opened) { + getLabelClass: function (item/* , opened */) { return (item.unread <= 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread"; }, - getRowClass: function (item, opened) { + getRowClass: function (item/*, opened */) { let rc = "dijitTreeRow"; const is_cat = String(item.id).indexOf('CAT:') != -1; @@ -163,9 +200,9 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], if (item.auxcounter > 0) rc += " Has_Aux"; if (item.markedcounter > 0) rc += " Has_Marked"; if (item.updates_disabled > 0) rc += " UpdatesDisabled"; - if (item.bare_id >= LABEL_BASE_INDEX && item.bare_id < 0 && !is_cat || item.bare_id == 0 && !is_cat) rc += " Special"; + if (item.bare_id >= App.LABEL_BASE_INDEX && item.bare_id < 0 && !is_cat || item.bare_id == 0 && !is_cat) rc += " Special"; if (item.bare_id == -1 && is_cat) rc += " AlwaysVisible"; - if (item.bare_id < LABEL_BASE_INDEX) rc += " Label"; + if (item.bare_id < App.LABEL_BASE_INDEX) rc += " Label"; return rc; }, diff --git a/js/Feeds.js b/js/Feeds.js index 7fa376984..9259cd547 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -1,232 +1,235 @@ 'use strict' -/* global __, ngettext */ -define(["dojo/_base/declare"], function (declare) { - Feeds = { - counters_last_request: 0, - _active_feed_id: undefined, - _active_feed_is_cat: false, - infscroll_in_progress: 0, - infscroll_disabled: 0, - _infscroll_timeout: false, - _search_query: false, - last_search_query: [], - _viewfeed_wait_timeout: false, - _counters_prev: [], - // NOTE: this implementation is incomplete - // for general objects but good enough for counters - // http://adripofjavascript.com/blog/drips/object-equality-in-javascript.html - counterEquals: function(a, b) { - // Create arrays of property names - const aProps = Object.getOwnPropertyNames(a); - const bProps = Object.getOwnPropertyNames(b); - - // If number of properties is different, + +/* global __, App, Headlines, xhrPost, dojo, dijit, Form, fox, PluginHost, Notify, $$ */ + +const Feeds = { + counters_last_request: 0, + _active_feed_id: undefined, + _active_feed_is_cat: false, + infscroll_in_progress: 0, + infscroll_disabled: 0, + _infscroll_timeout: false, + _search_query: false, + last_search_query: [], + _viewfeed_wait_timeout: false, + _counters_prev: [], + // NOTE: this implementation is incomplete + // for general objects but good enough for counters + // http://adripofjavascript.com/blog/drips/object-equality-in-javascript.html + counterEquals: function(a, b) { + // Create arrays of property names + const aProps = Object.getOwnPropertyNames(a); + const bProps = Object.getOwnPropertyNames(b); + + // If number of properties is different, + // objects are not equivalent + if (aProps.length != bProps.length) { + return false; + } + + for (let i = 0; i < aProps.length; i++) { + const propName = aProps[i]; + + // If values of same property are not equal, // objects are not equivalent - if (aProps.length != bProps.length) { + if (a[propName] !== b[propName]) { return false; } + } + + // If we made it this far, objects + // are considered equivalent + return true; + }, + resetCounters: function () { + this._counters_prev = []; + }, + parseCounters: function (elems) { + PluginHost.run(PluginHost.HOOK_COUNTERS_RECEIVED, elems); + + for (let l = 0; l < elems.length; l++) { + + if (Feeds._counters_prev[l] && this.counterEquals(elems[l], this._counters_prev[l])) { + continue; + } - for (let i = 0; i < aProps.length; i++) { - const propName = aProps[i]; + const id = elems[l].id; + const kind = elems[l].kind; + const ctr = parseInt(elems[l].counter); + const error = elems[l].error; + const has_img = elems[l].has_img; + const updated = elems[l].updated; - // If values of same property are not equal, - // objects are not equivalent - if (a[propName] !== b[propName]) { - return false; - } + if (id == "global-unread") { + App.global_unread = ctr; + App.updateTitle(); + continue; } - // If we made it this far, objects - // are considered equivalent - return true; - }, - resetCounters: function () { - this._counters_prev = []; - }, - parseCounters: function (elems) { - PluginHost.run(PluginHost.HOOK_COUNTERS_RECEIVED, elems); + if (id == "subscribed-feeds") { + /* feeds_found = ctr; */ + continue; + } - for (let l = 0; l < elems.length; l++) { + /*if (this.getUnread(id, (kind == "cat")) != ctr || + (kind == "cat")) { + }*/ - if (Feeds._counters_prev[l] && this.counterEquals(elems[l], this._counters_prev[l])) { - continue; - } + this.setUnread(id, (kind == "cat"), ctr); + this.setValue(id, (kind == "cat"), 'auxcounter', parseInt(elems[l].auxcounter)); + this.setValue(id, (kind == "cat"), 'markedcounter', parseInt(elems[l].markedcounter)); - const id = elems[l].id; - const kind = elems[l].kind; - const ctr = parseInt(elems[l].counter); - const error = elems[l].error; - const has_img = elems[l].has_img; - const updated = elems[l].updated; - - if (id == "global-unread") { - App.global_unread = ctr; - App.updateTitle(); - continue; - } + if (kind != "cat") { + this.setValue(id, false, 'error', error); + this.setValue(id, false, 'updated', updated); - if (id == "subscribed-feeds") { - /* feeds_found = ctr; */ - continue; - } - - /*if (this.getUnread(id, (kind == "cat")) != ctr || - (kind == "cat")) { - }*/ - - this.setUnread(id, (kind == "cat"), ctr); - this.setValue(id, (kind == "cat"), 'auxcounter', parseInt(elems[l].auxcounter)); - this.setValue(id, (kind == "cat"), 'markedcounter', parseInt(elems[l].markedcounter)); - - if (kind != "cat") { - this.setValue(id, false, 'error', error); - this.setValue(id, false, 'updated', updated); - - if (id > 0) { - if (has_img) { - this.setIcon(id, false, - App.getInitParam("icons_url") + "/" + id + ".ico?" + has_img); - } else { - this.setIcon(id, false, 'images/blank_icon.gif'); - } + if (id > 0) { + if (has_img) { + this.setIcon(id, false, + App.getInitParam("icons_url") + "/" + id + ".ico?" + has_img); + } else { + this.setIcon(id, false, 'images/blank_icon.gif'); } } } - - Headlines.updateCurrentUnread(); - - this.hideOrShowFeeds(App.getInitParam("hide_read_feeds")); - this._counters_prev = elems; - - PluginHost.run(PluginHost.HOOK_COUNTERS_PROCESSED); - }, - reloadCurrent: function(method) { - if (this.getActive() != undefined) { - console.log("reloadCurrent: " + method); - - this.open({feed: this.getActive(), is_cat: this.activeIsCat(), method: method}); + } + + Headlines.updateCurrentUnread(); + + this.hideOrShowFeeds(App.getInitParam("hide_read_feeds")); + this._counters_prev = elems; + + PluginHost.run(PluginHost.HOOK_COUNTERS_PROCESSED); + }, + reloadCurrent: function(method) { + if (this.getActive() != undefined) { + console.log("reloadCurrent: " + method); + + this.open({feed: this.getActive(), is_cat: this.activeIsCat(), method: method}); + } + return false; // block unneeded form submits + }, + openNextUnread: function() { + const is_cat = this.activeIsCat(); + const nuf = this.getNextUnread(this.getActive(), is_cat); + if (nuf) this.open({feed: nuf, is_cat: is_cat}); + }, + toggle: function() { + Element.toggle("feeds-holder"); + + const splitter = $("feeds-holder_splitter"); + + Element.visible("feeds-holder") ? splitter.show() : splitter.hide(); + + dijit.byId("main").resize(); + + Headlines.updateCurrentUnread(); + }, + cancelSearch: function() { + this._search_query = ""; + this.reloadCurrent(); + }, + requestCounters: function() { + xhrPost("backend.php", {op: "rpc", method: "getAllCounters", seq: App.next_seq()}, (transport) => { + App.handleRpcJson(transport); + }); + }, + reload: function() { + try { + Element.show("feedlistLoading"); + + this.resetCounters(); + + if (dijit.byId("feedTree")) { + dijit.byId("feedTree").destroyRecursive(); } - return false; // block unneeded form submits - }, - openNextUnread: function() { - const is_cat = this.activeIsCat(); - const nuf = this.getNextUnread(this.getActive(), is_cat); - if (nuf) this.open({feed: nuf, is_cat: is_cat}); - }, - toggle: function() { - Element.toggle("feeds-holder"); - - const splitter = $("feeds-holder_splitter"); - - Element.visible("feeds-holder") ? splitter.show() : splitter.hide(); - - dijit.byId("main").resize(); - - Headlines.updateCurrentUnread(); - }, - cancelSearch: function() { - this._search_query = ""; - this.reloadCurrent(); - }, - requestCounters: function() { - xhrPost("backend.php", {op: "rpc", method: "getAllCounters", seq: App.next_seq()}, (transport) => { - App.handleRpcJson(transport); - }); - }, - reload: function() { - try { - Element.show("feedlistLoading"); - - this.resetCounters(); - if (dijit.byId("feedTree")) { - dijit.byId("feedTree").destroyRecursive(); - } - - const store = new dojo.data.ItemFileWriteStore({ - url: "backend.php?op=pref_feeds&method=getfeedtree&mode=2" - }); + const store = new dojo.data.ItemFileWriteStore({ + url: "backend.php?op=pref_feeds&method=getfeedtree&mode=2" + }); - // noinspection JSUnresolvedFunction - const treeModel = new fox.FeedStoreModel({ - store: store, - query: { - "type": App.getInitParam('enable_feed_cats') ? "category" : "feed" - }, - rootId: "root", - rootLabel: "Feeds", - childrenAttrs: ["items"] - }); + // noinspection JSUnresolvedFunction + const treeModel = new fox.FeedStoreModel({ + store: store, + query: { + "type": App.getInitParam('enable_feed_cats') ? "category" : "feed" + }, + rootId: "root", + rootLabel: "Feeds", + childrenAttrs: ["items"] + }); - // noinspection JSUnresolvedFunction - const tree = new fox.FeedTree({ - model: treeModel, - onClick: function (item/*, node*/) { - const id = String(item.id); - const is_cat = id.match("^CAT:"); - const feed = id.substr(id.indexOf(":") + 1); - Feeds.open({feed: feed, is_cat: is_cat}); - return false; - }, - openOnClick: false, - showRoot: false, - persist: true, - id: "feedTree", - }, "feedTree"); - - const tmph = dojo.connect(dijit.byId('feedMenu'), '_openMyself', function (event) { - console.log(dijit.getEnclosingWidget(event.target)); - dojo.disconnect(tmph); - }); + // noinspection JSUnresolvedFunction + const tree = new fox.FeedTree({ + model: treeModel, + onClick: function (item/*, node*/) { + const id = String(item.id); + const is_cat = id.match("^CAT:"); + const feed = id.substr(id.indexOf(":") + 1); + Feeds.open({feed: feed, is_cat: is_cat}); + return false; + }, + openOnClick: false, + showRoot: false, + persist: true, + id: "feedTree", + }, "feedTree"); + + const tmph = dojo.connect(dijit.byId('feedMenu'), '_openMyself', function (event) { + console.log(dijit.getEnclosingWidget(event.target)); + dojo.disconnect(tmph); + }); - $("feeds-holder").appendChild(tree.domNode); + $("feeds-holder").appendChild(tree.domNode); - const tmph2 = dojo.connect(tree, 'onLoad', function () { - dojo.disconnect(tmph2); - Element.hide("feedlistLoading"); + const tmph2 = dojo.connect(tree, 'onLoad', function () { + dojo.disconnect(tmph2); + Element.hide("feedlistLoading"); - try { - Feeds.init(); - App.setLoadingProgress(25); - } catch (e) { - App.Error.report(e); - } - }); + try { + Feeds.init(); + App.setLoadingProgress(25); + } catch (e) { + App.Error.report(e); + } + }); - tree.startup(); - } catch (e) { - App.Error.report(e); - } - }, - init: function() { - console.log("in feedlist init"); + tree.startup(); + } catch (e) { + App.Error.report(e); + } + }, + init: function() { + console.log("in feedlist init"); - App.setLoadingProgress(50); + App.setLoadingProgress(50); - document.onkeydown = (event) => { return App.hotkeyHandler(event) }; - document.onkeypress = (event) => { return App.hotkeyHandler(event) }; - window.onresize = () => { Headlines.scrollHandler(); } + //document.onkeydown = (event) => { return App.hotkeyHandler(event) }; + //document.onkeypress = (event) => { return App.hotkeyHandler(event) }; + window.onresize = () => { Headlines.scrollHandler(); } - const hash_feed_id = hash_get('f'); - const hash_feed_is_cat = hash_get('c') == "1"; + /* global hash_get */ + const hash_feed_id = hash_get('f'); + const hash_feed_is_cat = hash_get('c') == "1"; - if (hash_feed_id != undefined) { - this.open({feed: hash_feed_id, is_cat: hash_feed_is_cat}); - } else { - this.open({feed: -3}); - } + if (hash_feed_id != undefined) { + this.open({feed: hash_feed_id, is_cat: hash_feed_is_cat}); + } else { + this.open({feed: -3}); + } - this.hideOrShowFeeds(App.getInitParam("hide_read_feeds")); + this.hideOrShowFeeds(App.getInitParam("hide_read_feeds")); - if (App.getInitParam("is_default_pw")) { - console.warn("user password is at default value"); + if (App.getInitParam("is_default_pw")) { + console.warn("user password is at default value"); - if (dijit.byId("defaultPasswordDlg")) - dijit.byId("defaultPasswordDlg").destroyRecursive(); + if (dijit.byId("defaultPasswordDlg")) + dijit.byId("defaultPasswordDlg").destroyRecursive(); + xhrPost("backend.php", {op: 'dlg', method: 'defaultpasswordwarning'}, (transport) => { const dialog = new dijit.Dialog({ title: __("Your password is at default value"), - href: "backend.php?op=dlg&method=defaultpasswordwarning", + content: transport.responseText, id: 'defaultPasswordDlg', style: "width: 600px", onCancel: function () { @@ -241,364 +244,366 @@ define(["dojo/_base/declare"], function (declare) { }); dialog.show(); - } - - // bw_limit disables timeout() so we request initial counters separately - if (App.getInitParam("bw_limit")) { - this.requestCounters(true); - } else { - setTimeout(() => { - this.requestCounters(true); - setInterval(() => { this.requestCounters(); }, 60 * 1000) - }, 250); - } - }, - activeIsCat: function() { - return !!this._active_feed_is_cat; - }, - getActive: function() { - return this._active_feed_id; - }, - setActive: function(id, is_cat) { - console.log('setActive', id, is_cat); - - hash_set('f', id); - hash_set('c', is_cat ? 1 : 0); - - this._active_feed_id = id; - this._active_feed_is_cat = is_cat; - - $("headlines-frame").setAttribute("feed-id", id); - $("headlines-frame").setAttribute("is-cat", is_cat ? 1 : 0); - - this.select(id, is_cat); - - PluginHost.run(PluginHost.HOOK_FEED_SET_ACTIVE, [this._active_feed_id, this._active_feed_is_cat]); - }, - select: function(feed, is_cat) { - const tree = dijit.byId("feedTree"); - - if (tree) return tree.selectFeed(feed, is_cat); - }, - toggleUnread: function() { - const hide = !App.getInitParam("hide_read_feeds"); - - xhrPost("backend.php", {op: "rpc", method: "setpref", key: "HIDE_READ_FEEDS", value: hide}, () => { - this.hideOrShowFeeds(hide); - App.setInitParam("hide_read_feeds", hide); }); - }, - hideOrShowFeeds: function (hide) { - /*const tree = dijit.byId("feedTree"); - - if (tree) - return tree.hideRead(hide, App.getInitParam("hide_read_shows_special"));*/ - - $$("body")[0].setAttribute("hide-read-feeds", !!hide); - $$("body")[0].setAttribute("hide-read-shows-special", !!App.getInitParam("hide_read_shows_special")); - }, - open: function(params) { - const feed = params.feed; - const is_cat = !!params.is_cat || false; - const offset = params.offset || 0; - const viewfeed_debug = params.viewfeed_debug; - const append = params.append || false; - const method = params.method; - // this is used to quickly switch between feeds, sets active but xhr is on a timeout - const delayed = params.delayed || false; - - if (offset != 0) { - if (this.infscroll_in_progress) - return; - - this.infscroll_in_progress = 1; - - window.clearTimeout(this._infscroll_timeout); - this._infscroll_timeout = window.setTimeout(() => { - console.log('infscroll request timed out, aborting'); - this.infscroll_in_progress = 0; - - // call scroll handler to maybe repeat infscroll request - Headlines.scrollHandler(); - }, 10 * 1000); - } - - Form.enable("toolbar-main"); - - let query = Object.assign({op: "feeds", method: "view", feed: feed}, - dojo.formToObject("toolbar-main")); - - if (method) query.m = method; - - if (offset > 0) { - if (Headlines.current_first_id) { - query.fid = Headlines.current_first_id; - } - } - - if (this._search_query) { - query = Object.assign(query, this._search_query); - } - - if (offset != 0) { - query.skip = offset; - } else if (!is_cat && feed == this.getActive() && !params.method) { - query.m = "ForceUpdate"; - } + } - Form.enable("toolbar-main"); - - if (!delayed) - if (!this.setExpando(feed, is_cat, - (is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif')) - Notify.progress("Loading, please wait...", true); - - query.cat = is_cat; - - this.setActive(feed, is_cat); - - if (viewfeed_debug) { - window.open("backend.php?" + - dojo.objectToQuery( - Object.assign({csrf_token: App.getInitParam("csrf_token")}, query) - )); - } - - window.clearTimeout(this._viewfeed_wait_timeout); - this._viewfeed_wait_timeout = window.setTimeout(() => { - xhrPost("backend.php", query, (transport) => { - try { - window.clearTimeout(this._infscroll_timeout); - this.setExpando(feed, is_cat, 'images/blank_icon.gif'); - Headlines.onLoaded(transport, offset, append); - PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]); - } catch (e) { - App.Error.report(e); - } - }); - }, delayed ? 250 : 0); - }, - catchupAll: function() { - const str = __("Mark all articles as read?"); + // bw_limit disables timeout() so we request initial counters separately + if (App.getInitParam("bw_limit")) { + this.requestCounters(true); + } else { + setTimeout(() => { + this.requestCounters(true); + setInterval(() => { this.requestCounters(); }, 60 * 1000) + }, 250); + } + }, + activeIsCat: function() { + return !!this._active_feed_is_cat; + }, + getActive: function() { + return this._active_feed_id; + }, + setActive: function(id, is_cat) { + console.log('setActive', id, is_cat); + + /* global hash_set */ + hash_set('f', id); + hash_set('c', is_cat ? 1 : 0); + + this._active_feed_id = id; + this._active_feed_is_cat = is_cat; + + $("headlines-frame").setAttribute("feed-id", id); + $("headlines-frame").setAttribute("is-cat", is_cat ? 1 : 0); + + this.select(id, is_cat); + + PluginHost.run(PluginHost.HOOK_FEED_SET_ACTIVE, [this._active_feed_id, this._active_feed_is_cat]); + }, + select: function(feed, is_cat) { + const tree = dijit.byId("feedTree"); + + if (tree) return tree.selectFeed(feed, is_cat); + }, + toggleUnread: function() { + const hide = !App.getInitParam("hide_read_feeds"); + + xhrPost("backend.php", {op: "rpc", method: "setpref", key: "HIDE_READ_FEEDS", value: hide}, () => { + this.hideOrShowFeeds(hide); + App.setInitParam("hide_read_feeds", hide); + }); + }, + hideOrShowFeeds: function (hide) { + /*const tree = dijit.byId("feedTree"); + + if (tree) + return tree.hideRead(hide, App.getInitParam("hide_read_shows_special"));*/ + + $$("body")[0].setAttribute("hide-read-feeds", !!hide); + $$("body")[0].setAttribute("hide-read-shows-special", !!App.getInitParam("hide_read_shows_special")); + }, + open: function(params) { + const feed = params.feed; + const is_cat = !!params.is_cat || false; + const offset = params.offset || 0; + const viewfeed_debug = params.viewfeed_debug; + const append = params.append || false; + const method = params.method; + // this is used to quickly switch between feeds, sets active but xhr is on a timeout + const delayed = params.delayed || false; + + if (offset != 0) { + if (this.infscroll_in_progress) + return; - if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { + this.infscroll_in_progress = 1; - Notify.progress("Marking all feeds as read..."); + window.clearTimeout(this._infscroll_timeout); + this._infscroll_timeout = window.setTimeout(() => { + console.log('infscroll request timed out, aborting'); + this.infscroll_in_progress = 0; - xhrPost("backend.php", {op: "feeds", method: "catchupAll"}, () => { - this.requestCounters(true); - this.reloadCurrent(); - }); + // call scroll handler to maybe repeat infscroll request + Headlines.scrollHandler(); + }, 10 * 1000); + } - App.global_unread = 0; - App.updateTitle(); - } - }, - catchupFeed: function(feed, is_cat, mode) { - is_cat = is_cat || false; - - let str = false; - - switch (mode) { - case "1day": - str = __("Mark %w in %s older than 1 day as read?"); - break; - case "1week": - str = __("Mark %w in %s older than 1 week as read?"); - break; - case "2week": - str = __("Mark %w in %s older than 2 weeks as read?"); - break; - default: - str = __("Mark %w in %s as read?"); - } + Form.enable("toolbar-main"); - const mark_what = this.last_search_query && this.last_search_query[0] ? __("search results") : __("all articles"); - const fn = this.getName(feed, is_cat); + let query = Object.assign({op: "feeds", method: "view", feed: feed}, + dojo.formToObject("toolbar-main")); - str = str.replace("%s", fn) - .replace("%w", mark_what); + if (method) query.m = method; - if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { - return; + if (offset > 0) { + if (Headlines.current_first_id) { + query.fid = Headlines.current_first_id; } - - const catchup_query = { - op: 'rpc', method: 'catchupFeed', feed_id: feed, - is_cat: is_cat, mode: mode, search_query: this.last_search_query[0], - search_lang: this.last_search_query[1] - }; - - Notify.progress("Loading, please wait...", true); - - xhrPost("backend.php", catchup_query, (transport) => { - App.handleRpcJson(transport); - - const show_next_feed = App.getInitParam("on_catchup_show_next_feed"); - - if (show_next_feed) { - const nuf = this.getNextUnread(feed, is_cat); - - if (nuf) { - this.open({feed: nuf, is_cat: is_cat}); - } - } else if (feed == this.getActive() && is_cat == this.activeIsCat()) { - this.reloadCurrent(); + } + + if (this._search_query) { + query = Object.assign(query, this._search_query); + } + + if (offset != 0) { + query.skip = offset; + } else if (!is_cat && feed == this.getActive() && !params.method) { + query.m = "ForceUpdate"; + } + + Form.enable("toolbar-main"); + + if (!delayed) + if (!this.setExpando(feed, is_cat, + (is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif')) + Notify.progress("Loading, please wait...", true); + + query.cat = is_cat; + + this.setActive(feed, is_cat); + + if (viewfeed_debug) { + window.open("backend.php?" + + dojo.objectToQuery( + Object.assign({csrf_token: App.getInitParam("csrf_token")}, query) + )); + } + + window.clearTimeout(this._viewfeed_wait_timeout); + this._viewfeed_wait_timeout = window.setTimeout(() => { + xhrPost("backend.php", query, (transport) => { + try { + window.clearTimeout(this._infscroll_timeout); + this.setExpando(feed, is_cat, 'images/blank_icon.gif'); + Headlines.onLoaded(transport, offset, append); + PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]); + } catch (e) { + App.Error.report(e); } - - Notify.close(); }); - }, - catchupCurrent: function(mode) { - this.catchupFeed(this.getActive(), this.activeIsCat(), mode); - }, - catchupFeedInGroup: function(id) { - const title = this.getName(id); + }, delayed ? 250 : 0); + }, + catchupAll: function() { + const str = __("Mark all articles as read?"); - const str = __("Mark all articles in %s as read?").replace("%s", title); + if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { - if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { + Notify.progress("Marking all feeds as read..."); - const rows = $$("#headlines-frame > div[id*=RROW][class*=Unread][data-orig-feed-id='" + id + "']"); - - rows.each((row) => { - row.removeClassName("Unread"); - }) - } - }, - getUnread: function(feed, is_cat) { - try { - const tree = dijit.byId("feedTree"); - - if (tree && tree.model) - return tree.model.getFeedUnread(feed, is_cat); + xhrPost("backend.php", {op: "feeds", method: "catchupAll"}, () => { + this.requestCounters(true); + this.reloadCurrent(); + }); - } catch (e) { - // + App.global_unread = 0; + App.updateTitle(); + } + }, + catchupFeed: function(feed, is_cat, mode) { + is_cat = is_cat || false; + + let str = false; + + switch (mode) { + case "1day": + str = __("Mark %w in %s older than 1 day as read?"); + break; + case "1week": + str = __("Mark %w in %s older than 1 week as read?"); + break; + case "2week": + str = __("Mark %w in %s older than 2 weeks as read?"); + break; + default: + str = __("Mark %w in %s as read?"); + } + + const mark_what = this.last_search_query && this.last_search_query[0] ? __("search results") : __("all articles"); + const fn = this.getName(feed, is_cat); + + str = str.replace("%s", fn) + .replace("%w", mark_what); + + if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { + return; + } + + const catchup_query = { + op: 'rpc', method: 'catchupFeed', feed_id: feed, + is_cat: is_cat, mode: mode, search_query: this.last_search_query[0], + search_lang: this.last_search_query[1] + }; + + Notify.progress("Loading, please wait...", true); + + xhrPost("backend.php", catchup_query, (transport) => { + App.handleRpcJson(transport); + + const show_next_feed = App.getInitParam("on_catchup_show_next_feed"); + + if (show_next_feed) { + const nuf = this.getNextUnread(feed, is_cat); + + if (nuf) { + this.open({feed: nuf, is_cat: is_cat}); + } + } else if (feed == this.getActive() && is_cat == this.activeIsCat()) { + this.reloadCurrent(); } - return -1; - }, - getCategory: function(feed) { - try { - const tree = dijit.byId("feedTree"); + Notify.close(); + }); + }, + catchupCurrent: function(mode) { + this.catchupFeed(this.getActive(), this.activeIsCat(), mode); + }, + catchupFeedInGroup: function(id) { + const title = this.getName(id); - if (tree && tree.model) - return tree.getFeedCategory(feed); + const str = __("Mark all articles in %s as read?").replace("%s", title); - } catch (e) { - // - } + if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(str)) { - return false; - }, - getName: function(feed, is_cat) { - if (isNaN(feed)) return feed; // it's a tag + const rows = $$("#headlines-frame > div[id*=RROW][class*=Unread][data-orig-feed-id='" + id + "']"); + rows.each((row) => { + row.removeClassName("Unread"); + }) + } + }, + getUnread: function(feed, is_cat) { + try { const tree = dijit.byId("feedTree"); if (tree && tree.model) - return tree.model.getFeedValue(feed, is_cat, 'name'); - }, - setUnread: function(feed, is_cat, unread) { - const tree = dijit.byId("feedTree"); - - if (tree && tree.model) - return tree.model.setFeedUnread(feed, is_cat, unread); - }, - setValue: function(feed, is_cat, key, value) { - try { - const tree = dijit.byId("feedTree"); - - if (tree && tree.model) - return tree.model.setFeedValue(feed, is_cat, key, value); + return tree.model.getFeedUnread(feed, is_cat); - } catch (e) { - // - } - }, - getValue: function(feed, is_cat, key) { - try { - const tree = dijit.byId("feedTree"); - - if (tree && tree.model) - return tree.model.getFeedValue(feed, is_cat, key); + } catch (e) { + // + } - } catch (e) { - // - } - return ''; - }, - setIcon: function(feed, is_cat, src) { + return -1; + }, + getCategory: function(feed) { + try { const tree = dijit.byId("feedTree"); - if (tree) return tree.setFeedIcon(feed, is_cat, src); - }, - setExpando: function(feed, is_cat, src) { + if (tree && tree.model) + return tree.getFeedCategory(feed); + + } catch (e) { + // + } + + return false; + }, + getName: function(feed, is_cat) { + if (isNaN(feed)) return feed; // it's a tag + + const tree = dijit.byId("feedTree"); + + if (tree && tree.model) + return tree.model.getFeedValue(feed, is_cat, 'name'); + }, + setUnread: function(feed, is_cat, unread) { + const tree = dijit.byId("feedTree"); + + if (tree && tree.model) + return tree.model.setFeedUnread(feed, is_cat, unread); + }, + setValue: function(feed, is_cat, key, value) { + try { const tree = dijit.byId("feedTree"); - if (tree) return tree.setFeedExpandoIcon(feed, is_cat, src); - - return false; - }, - getNextUnread: function(feed, is_cat) { + if (tree && tree.model) + return tree.model.setFeedValue(feed, is_cat, key, value); + + } catch (e) { + // + } + }, + getValue: function(feed, is_cat, key) { + try { const tree = dijit.byId("feedTree"); - const nuf = tree.model.getNextUnreadFeed(feed, is_cat); - - if (nuf) - return tree.model.store.getValue(nuf, 'bare_id'); - }, - search: function() { - const query = "backend.php?op=feeds&method=search¶m=" + - encodeURIComponent(Feeds.getActive() + ":" + Feeds.activeIsCat()); - - if (dijit.byId("searchDlg")) - dijit.byId("searchDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ - id: "searchDlg", - title: __("Search"), - style: "width: 600px", - execute: function () { - if (this.validate()) { - Feeds._search_query = this.attr('value'); - - // disallow empty queries - if (!Feeds._search_query.query) - Feeds._search_query = false; - - this.hide(); - Feeds.reloadCurrent(); - } - }, - href: query - }); - - const tmph = dojo.connect(dialog, 'onLoad', function () { - dojo.disconnect(tmph); - - if (Feeds._search_query) { - if (Feeds._search_query.query) - dijit.byId('search_query') - .attr('value', Feeds._search_query.query); - - if (Feeds._search_query.search_language) - dijit.byId('search_language') - .attr('value', Feeds._search_query.search_language); - } - - }); - - dialog.show(); - }, - updateRandom: function() { - console.log("in update_random_feed"); - xhrPost("backend.php", {op: "rpc", method: "updaterandomfeed"}, (transport) => { - App.handleRpcJson(transport, true); - }); - }, - }; - - return Feeds; -}); + if (tree && tree.model) + return tree.model.getFeedValue(feed, is_cat, key); + + } catch (e) { + // + } + return ''; + }, + setIcon: function(feed, is_cat, src) { + const tree = dijit.byId("feedTree"); + + if (tree) return tree.setFeedIcon(feed, is_cat, src); + }, + setExpando: function(feed, is_cat, src) { + const tree = dijit.byId("feedTree"); + + if (tree) return tree.setFeedExpandoIcon(feed, is_cat, src); + + return false; + }, + getNextUnread: function(feed, is_cat) { + const tree = dijit.byId("feedTree"); + const nuf = tree.model.getNextUnreadFeed(feed, is_cat); + + if (nuf) + return tree.model.store.getValue(nuf, 'bare_id'); + }, + search: function() { + if (dijit.byId("searchDlg")) + dijit.byId("searchDlg").destroyRecursive(); + + xhrPost("backend.php", + {op: "feeds", method: "search", + param: Feeds.getActive() + ":" + Feeds.activeIsCat()}, + (transport) => { + const dialog = new dijit.Dialog({ + id: "searchDlg", + content: transport.responseText, + title: __("Search"), + style: "width: 600px", + execute: function () { + if (this.validate()) { + Feeds._search_query = this.attr('value'); + + // disallow empty queries + if (!Feeds._search_query.query) + Feeds._search_query = false; + + this.hide(); + Feeds.reloadCurrent(); + } + }, + }); + + const tmph = dojo.connect(dialog, 'onLoad', function () { + dojo.disconnect(tmph); + + if (Feeds._search_query) { + if (Feeds._search_query.query) + dijit.byId('search_query') + .attr('value', Feeds._search_query.query); + + if (Feeds._search_query.search_language) + dijit.byId('search_language') + .attr('value', Feeds._search_query.search_language); + } + + }); + + dialog.show(); + }); + + }, + updateRandom: function() { + console.log("in update_random_feed"); + + xhrPost("backend.php", {op: "rpc", method: "updaterandomfeed"}, (transport) => { + App.handleRpcJson(transport, true); + }); + }, +}; diff --git a/js/Headlines.js b/js/Headlines.js index 540c400d3..b98098c33 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -1,944 +1,760 @@ 'use strict'; -/* global __, ngettext */ -define(["dojo/_base/declare"], function (declare) { - Headlines = { - vgroup_last_feed: undefined, - _headlines_scroll_timeout: 0, - _observer_counters_timeout: 0, - headlines: [], - current_first_id: 0, - _scroll_reset_timeout: false, - row_observer: new MutationObserver((mutations) => { - const modified = []; - mutations.each((m) => { - if (m.type == 'attributes' && ['class', 'data-score'].indexOf(m.attributeName) != -1) { +/* global __, ngettext, Article, App */ +/* global xhrPost, dojo, dijit, PluginHost, Notify, $$, Feeds */ +/* global CommonDialogs */ + +const Headlines = { + vgroup_last_feed: undefined, + _headlines_scroll_timeout: 0, + _observer_counters_timeout: 0, + headlines: [], + current_first_id: 0, + _scroll_reset_timeout: false, + default_force_previous: false, + default_force_to_top: false, + line_scroll_offset: 120, /* px */ + sticky_header_observer: new IntersectionObserver( + (entries, observer) => { + entries.forEach((entry) => { + const header = entry.target.nextElementSibling; + + if (entry.intersectionRatio == 0) { + header.setAttribute("stuck", "1"); + + } else if (entry.intersectionRatio == 1) { + header.removeAttribute("stuck"); + } + + //console.log(entry.target, header, entry.intersectionRatio); - const row = m.target; - const id = row.getAttribute("data-article-id"); + }); + }, + {threshold: [0, 1], root: document.querySelector("#headlines-frame")} + ), + unpack_observer: new IntersectionObserver( + (entries, observer) => { + entries.forEach((entry) => { + if (entry.intersectionRatio > 0) + Article.unpack(entry.target); + }); + }, + {threshold: [0], root: document.querySelector("#headlines-frame")} + ), + row_observer: new MutationObserver((mutations) => { + const modified = []; - if (Headlines.headlines[id]) { - const hl = Headlines.headlines[id]; + mutations.each((m) => { + if (m.type == 'attributes' && ['class', 'data-score'].indexOf(m.attributeName) != -1) { - if (hl) { - const hl_old = Object.extend({}, hl); + const row = m.target; + const id = row.getAttribute("data-article-id"); - hl.unread = row.hasClassName("Unread"); - hl.marked = row.hasClassName("marked"); - hl.published = row.hasClassName("published"); + if (Headlines.headlines[id]) { + const hl = Headlines.headlines[id]; - // not sent by backend - hl.selected = row.hasClassName("Selected"); - hl.active = row.hasClassName("active"); + if (hl) { + const hl_old = Object.extend({}, hl); - hl.score = row.getAttribute("data-score"); + hl.unread = row.hasClassName("Unread"); + hl.marked = row.hasClassName("marked"); + hl.published = row.hasClassName("published"); - modified.push({id: hl.id, new: hl, old: hl_old, row: row}); - } + // not sent by backend + hl.selected = row.hasClassName("Selected"); + hl.active = row.hasClassName("active"); + + hl.score = row.getAttribute("data-score"); + + modified.push({id: hl.id, new: hl, old: hl_old, row: row}); } } - }); + } + }); - Headlines.updateSelectedPrompt(); - Headlines.updateFloatingTitle(true); + Headlines.updateSelectedPrompt(); - if ('requestIdleCallback' in window) - window.requestIdleCallback(() => { - Headlines.syncModified(modified); - }); - else + if ('requestIdleCallback' in window) + window.requestIdleCallback(() => { Headlines.syncModified(modified); - }), - syncModified: function(modified) { - const ops = { - tmark: [], - tpub: [], - read: [], - unread: [], - select: [], - deselect: [], - activate: [], - deactivate: [], - rescore: {}, - }; - - modified.each(function(m) { - if (m.old.marked != m.new.marked) - ops.tmark.push(m.id); - - if (m.old.published != m.new.published) - ops.tpub.push(m.id); - - if (m.old.unread != m.new.unread) - m.new.unread ? ops.unread.push(m.id) : ops.read.push(m.id); - - if (m.old.selected != m.new.selected) - m.new.selected ? ops.select.push(m.row) : ops.deselect.push(m.row); - - if (m.old.active != m.new.active) - m.new.active ? ops.activate.push(m.row) : ops.deactivate.push(m.row); - - if (m.old.score != m.new.score) { - const score = m.new.score; - - ops.rescore[score] = ops.rescore[score] || []; - ops.rescore[score].push(m.id); - } }); + else + Headlines.syncModified(modified); + }), + syncModified: function (modified) { + const ops = { + tmark: [], + tpub: [], + read: [], + unread: [], + select: [], + deselect: [], + activate: [], + deactivate: [], + rescore: {}, + }; + + modified.each(function (m) { + if (m.old.marked != m.new.marked) + ops.tmark.push(m.id); + + if (m.old.published != m.new.published) + ops.tpub.push(m.id); + + if (m.old.unread != m.new.unread) + m.new.unread ? ops.unread.push(m.id) : ops.read.push(m.id); + + if (m.old.selected != m.new.selected) + m.new.selected ? ops.select.push(m.row) : ops.deselect.push(m.row); + + if (m.old.active != m.new.active) + m.new.active ? ops.activate.push(m.row) : ops.deactivate.push(m.row); + + if (m.old.score != m.new.score) { + const score = m.new.score; + + ops.rescore[score] = ops.rescore[score] || []; + ops.rescore[score].push(m.id); + } + }); - ops.select.each((row) => { - const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]); + ops.select.each((row) => { + const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]); - if (cb) - cb.attr('checked', true); - }); + if (cb) + cb.attr('checked', true); + }); - ops.deselect.each((row) => { - const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]); + ops.deselect.each((row) => { + const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]); - if (cb && !row.hasClassName("active")) - cb.attr('checked', false); - }); + if (cb && !row.hasClassName("active")) + cb.attr('checked', false); + }); - ops.activate.each((row) => { - const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]); + ops.activate.each((row) => { + const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]); - if (cb) - cb.attr('checked', true); - }); + if (cb) + cb.attr('checked', true); + }); - ops.deactivate.each((row) => { - const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]); + ops.deactivate.each((row) => { + const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]); - if (cb && !row.hasClassName("Selected")) - cb.attr('checked', false); - }); + if (cb && !row.hasClassName("Selected")) + cb.attr('checked', false); + }); - const promises = []; + const promises = []; - if (ops.tmark.length != 0) - promises.push(xhrPost("backend.php", - { op: "rpc", method: "markSelected", ids: ops.tmark.toString(), cmode: 2})); + if (ops.tmark.length != 0) + promises.push(xhrPost("backend.php", + {op: "rpc", method: "markSelected", ids: ops.tmark.toString(), cmode: 2})); - if (ops.tpub.length != 0) - promises.push(xhrPost("backend.php", - { op: "rpc", method: "publishSelected", ids: ops.tpub.toString(), cmode: 2})); + if (ops.tpub.length != 0) + promises.push(xhrPost("backend.php", + {op: "rpc", method: "publishSelected", ids: ops.tpub.toString(), cmode: 2})); - if (ops.read.length != 0) - promises.push(xhrPost("backend.php", - { op: "rpc", method: "catchupSelected", ids: ops.read.toString(), cmode: 0})); + if (ops.read.length != 0) + promises.push(xhrPost("backend.php", + {op: "rpc", method: "catchupSelected", ids: ops.read.toString(), cmode: 0})); - if (ops.unread.length != 0) - promises.push(xhrPost("backend.php", - { op: "rpc", method: "catchupSelected", ids: ops.unread.toString(), cmode: 1})); + if (ops.unread.length != 0) + promises.push(xhrPost("backend.php", + {op: "rpc", method: "catchupSelected", ids: ops.unread.toString(), cmode: 1})); - const scores = Object.keys(ops.rescore); + const scores = Object.keys(ops.rescore); - if (scores.length != 0) { - scores.each((score) => { - promises.push(xhrPost("backend.php", - { op: "article", method: "setScore", id: ops.rescore[score].toString(), score: score })); - }); - } + if (scores.length != 0) { + scores.each((score) => { + promises.push(xhrPost("backend.php", + {op: "article", method: "setScore", id: ops.rescore[score].toString(), score: score})); + }); + } - if (promises.length > 0) - Promise.all([promises]).then(() => { - window.clearTimeout(this._observer_counters_timeout); + if (promises.length > 0) + Promise.all([promises]).then(() => { + window.clearTimeout(this._observer_counters_timeout); - this._observer_counters_timeout = setTimeout(() => { - Feeds.requestCounters(true); - }, 1000); - }); + this._observer_counters_timeout = setTimeout(() => { + Feeds.requestCounters(true); + }, 1000); + }); - }, - click: function (event, id, in_body) { - in_body = in_body || false; + }, + click: function (event, id, in_body) { + in_body = in_body || false; - if (event.shiftKey && Article.getActive()) { - Headlines.select('none'); + if (event.shiftKey && Article.getActive()) { + Headlines.select('none'); - const ids = Headlines.getRange(Article.getActive(), id); + const ids = Headlines.getRange(Article.getActive(), id); - console.log(Article.getActive(), id, ids); + console.log(Article.getActive(), id, ids); - for (let i = 0; i < ids.length; i++) - Headlines.select('all', ids[i]); + for (let i = 0; i < ids.length; i++) + Headlines.select('all', ids[i]); - } else if (event.ctrlKey) { - Headlines.select('invert', id); - } else { - if (App.isCombinedMode()) { + } else if (event.ctrlKey) { + Headlines.select('invert', id); + } else { + if (App.isCombinedMode()) { - if (event.altKey && !in_body) { + if (event.altKey && !in_body) { - Article.openInNewWindow(id); - Headlines.toggleUnread(id, 0); + Article.openInNewWindow(id); + Headlines.toggleUnread(id, 0); - } else if (Article.getActive() != id) { + } else if (Article.getActive() != id) { - Headlines.select('none'); - Article.setActive(id); + Headlines.select('none'); - if (App.getInitParam("cdm_expanded")) { - if (!in_body) - Article.openInNewWindow(id); + const scroll_position_A = $("RROW-" + id).offsetTop - $("headlines-frame").scrollTop; - Headlines.toggleUnread(id, 0); - } else { - Article.cdmScrollToId(id); - } + Article.setActive(id); - } else if (in_body) { - Headlines.toggleUnread(id, 0); - } else { /* !in body */ - Article.openInNewWindow(id); - } + if (App.getInitParam("cdm_expanded")) { + + if (!in_body) + Article.openInNewWindow(id); - return in_body; - } else { - if (event.altKey) { - Article.openInNewWindow(id); Headlines.toggleUnread(id, 0); } else { - Headlines.select('none'); - Article.view(id); - } - } - } - - return false; - }, - initScrollHandler: function () { - $("headlines-frame").onscroll = (event) => { - clearTimeout(this._headlines_scroll_timeout); - this._headlines_scroll_timeout = window.setTimeout(function () { - //console.log('done scrolling', event); - Headlines.scrollHandler(event); - }, 50); - } - }, - loadMore: function () { - const view_mode = document.forms["toolbar-main"].view_mode.value; - const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length; - const num_all = $$("#headlines-frame > div[id*=RROW]").length; - const num_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat()); + const scroll_position_B = $("RROW-" + id).offsetTop - $("headlines-frame").scrollTop; - // TODO implement marked & published + // this would only work if there's enough space + $("headlines-frame").scrollTop -= scroll_position_A-scroll_position_B; - let offset = num_all; - - switch (view_mode) { - case "marked": - case "published": - console.warn("loadMore: ", view_mode, "not implemented"); - break; - case "unread": - offset = unread_in_buffer; - break; - case "adaptive": - if (!(Feeds.getActive() == -1 && !Feeds.activeIsCat())) - offset = num_unread > 0 ? unread_in_buffer : num_all; - break; - } - - console.log("loadMore, offset=", offset); - - Feeds.open({feed: Feeds.getActive(), is_cat: Feeds.activeIsCat(), offset: offset, append: true}); - }, - isChildVisible: function (elem, ctr) { - const ctop = ctr.scrollTop; - const cbottom = ctop + ctr.offsetHeight; - - const etop = elem.offsetTop; - const ebottom = etop + elem.offsetHeight; - - return etop >= ctop && ebottom <= cbottom || - etop < ctop && ebottom > ctop || ebottom > cbottom && etop < cbottom - - }, - firstVisible: function() { - const rows = $$("#headlines-frame > div[id*=RROW]"); - const ctr = $("headlines-frame"); + Article.cdmMoveToId(id); + } - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; + } else if (in_body) { + Headlines.toggleUnread(id, 0); + } else { /* !in body */ + Article.openInNewWindow(id); + } - if (this.isChildVisible(row, ctr)) { - return row.getAttribute("data-article-id"); + return in_body; + } else { + if (event.altKey) { + Article.openInNewWindow(id); + Headlines.toggleUnread(id, 0); + } else { + Headlines.select('none'); + Article.view(id); } } - }, - scrollHandler: function (/*event*/) { - try { - Headlines.unpackVisible(); + } - if (App.isCombinedMode()) - Headlines.updateFloatingTitle(); + return false; + }, + initScrollHandler: function () { + $("headlines-frame").onscroll = (event) => { + clearTimeout(this._headlines_scroll_timeout); + this._headlines_scroll_timeout = window.setTimeout(function () { + //console.log('done scrolling', event); + Headlines.scrollHandler(event); + }, 50); + } + }, + loadMore: function () { + const view_mode = document.forms["toolbar-main"].view_mode.value; + const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length; + const num_all = $$("#headlines-frame > div[id*=RROW]").length; + const num_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat()); + + // TODO implement marked & published + + let offset = num_all; + + switch (view_mode) { + case "marked": + case "published": + console.warn("loadMore: ", view_mode, "not implemented"); + break; + case "unread": + offset = unread_in_buffer; + break; + case "adaptive": + if (!(Feeds.getActive() == -1 && !Feeds.activeIsCat())) + offset = num_unread > 0 ? unread_in_buffer : num_all; + break; + } - if (!Feeds.infscroll_disabled && !Feeds.infscroll_in_progress) { - const hsp = $("headlines-spacer"); - const container = $("headlines-frame"); + console.log("loadMore, offset=", offset); - if (hsp && hsp.previousSibling) { - const last_row = hsp.previousSibling; + Feeds.open({feed: Feeds.getActive(), is_cat: Feeds.activeIsCat(), offset: offset, append: true}); + }, + isChildVisible: function (elem) { + return App.Scrollable.isChildVisible(elem, $("headlines-frame")); + }, + firstVisible: function () { + const rows = $$("#headlines-frame > div[id*=RROW]"); - // invoke lazy load if last article in buffer is nearly visible OR is active - if (Article.getActive() == last_row.getAttribute("data-article-id") || last_row.offsetTop - 250 <= container.scrollTop + container.offsetHeight) { - hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " + - __("Loading, please wait...") + "</span>"; + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; - Headlines.loadMore(); - return; - } + if (this.isChildVisible(row)) { + return row.getAttribute("data-article-id"); + } + } + }, + scrollHandler: function (/*event*/) { + try { + if (!Feeds.infscroll_disabled && !Feeds.infscroll_in_progress) { + const hsp = $("headlines-spacer"); + const container = $("headlines-frame"); + + if (hsp && hsp.previousSibling) { + const last_row = hsp.previousSibling; + + // invoke lazy load if last article in buffer is nearly visible OR is active + if (Article.getActive() == last_row.getAttribute("data-article-id") || last_row.offsetTop - 250 <= container.scrollTop + container.offsetHeight) { + hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " + + __("Loading, please wait...") + "</span>"; + + Headlines.loadMore(); + return; } } + } - if (App.getInitParam("cdm_auto_catchup")) { + if (App.getInitParam("cdm_auto_catchup")) { - let rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]"); + const rows = $$("#headlines-frame > div[id*=RROW][class*=Unread]"); - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; - if ($("headlines-frame").scrollTop > (row.offsetTop + row.offsetHeight / 2)) { - row.removeClassName("Unread"); - } else { - break; - } + if ($("headlines-frame").scrollTop > (row.offsetTop + row.offsetHeight / 2)) { + row.removeClassName("Unread"); + } else { + break; } } - } catch (e) { - console.warn("scrollHandler", e); } - }, - updateFloatingTitle: function (status_only) { - if (!App.isCombinedMode()/* || !App.getInitParam("cdm_expanded")*/) return; - - const safety_offset = 120; /* px, needed for firefox */ - const hf = $("headlines-frame"); - const elems = $$("#headlines-frame > div[id*=RROW]"); - const ft = $("floatingTitle"); - - for (let i = 0; i < elems.length; i++) { - const row = elems[i]; - - if (row && row.offsetTop + row.offsetHeight > hf.scrollTop + safety_offset) { - - const header = row.select(".header")[0]; - const id = row.getAttribute("data-article-id"); - - if (status_only || id != ft.getAttribute("data-article-id")) { - if (id != ft.getAttribute("data-article-id")) { - - ft.setAttribute("data-article-id", id); - ft.innerHTML = header.innerHTML; - - ft.select(".dijitCheckBox")[0].outerHTML = "<i class=\"material-icons icon-anchor\" onclick=\"Article.cdmScrollToId(" + id + ", true)\">expand_more</i>"; - - this.initFloatingMenu(); - - } - - if (row.hasClassName("Unread")) - ft.addClassName("Unread"); - else - ft.removeClassName("Unread"); - - if (row.hasClassName("marked")) - ft.addClassName("marked"); - else - ft.removeClassName("marked"); - - if (row.hasClassName("published")) - ft.addClassName("published"); - else - ft.removeClassName("published"); - - PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, row); - } + } catch (e) { + console.warn("scrollHandler", e); + } + }, + objectById: function (id) { + return this.headlines[id]; + }, + setCommonClasses: function () { + $("headlines-frame").removeClassName("cdm"); + $("headlines-frame").removeClassName("normal"); + + $("headlines-frame").addClassName(App.isCombinedMode() ? "cdm" : "normal"); + + // for floating title because it's placed outside of headlines-frame + $("main").removeClassName("expandable"); + $("main").removeClassName("expanded"); + + if (App.isCombinedMode()) + $("main").addClassName(App.getInitParam("cdm_expanded") ? " expanded" : " expandable"); + }, + renderAgain: function () { + // TODO: wrap headline elements into a knockoutjs model to prevent all this stuff + Headlines.setCommonClasses(); + + $$("#headlines-frame > div[id*=RROW]").each((row) => { + const id = row.getAttribute("data-article-id"); + const hl = this.headlines[id]; + + if (hl) { + const new_row = this.render({}, hl); + + row.parentNode.replaceChild(new_row, row); + + if (hl.active) { + new_row.addClassName("active"); + Article.unpack(new_row); - if (hf.scrollTop - row.offsetTop <= header.offsetHeight + safety_offset) - ft.fade({duration: 0.2}); + if (App.isCombinedMode()) + Article.cdmMoveToId(id, {noscroll: true}); else - ft.appear({duration: 0.2}); - - return; + Article.view(id); } + + if (hl.selected) this.select("all", id); } - }, - unpackVisible: function () { - if (!App.isCombinedMode() || !App.getInitParam("cdm_expanded")) return; + }); - const rows = $$("#headlines-frame div[id*=RROW][data-content]"); - const threshold = $("headlines-frame").scrollTop + $("headlines-frame").offsetHeight + 600; + $$(".cdm .header-sticky-guard").each((e) => { + this.sticky_header_observer.observe(e) + }); - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; + if (App.getInitParam("cdm_expanded")) + $$("#headlines-frame > div[id*=RROW].cdm").each((e) => { + this.unpack_observer.observe(e) + }); - if (row.offsetTop <= threshold) { - Article.unpack(row); - } else { - break; - } - } - }, - objectById: function (id){ - return this.headlines[id]; - }, - renderAgain: function() { - // TODO: wrap headline elements into a knockoutjs model to prevent all this stuff + }, + render: function (headlines, hl) { + let row = null; - $$("#headlines-frame > div[id*=RROW]").each((row) => { - const id = row.getAttribute("data-article-id"); - const hl = this.headlines[id]; + let row_class = ""; - if (hl) { - const new_row = this.render({}, hl); + if (hl.marked) row_class += " marked"; + if (hl.published) row_class += " published"; + if (hl.unread) row_class += " Unread"; + if (headlines.vfeed_group_enabled) row_class += " vgrlf"; - row.parentNode.replaceChild(new_row, row); + if (headlines.vfeed_group_enabled && hl.feed_title && this.vgroup_last_feed != hl.feed_id) { + const vgrhdr = `<div data-feed-id='${hl.feed_id}' class='feed-title'> + <div style='float : right'>${hl.feed_icon}</div> + <a class="title" href="#" onclick="Feeds.open({feed:${hl.feed_id}})">${hl.feed_title} + <a class="catchup" title="${__('mark feed as read')}" onclick="Feeds.catchupFeedInGroup(${hl.feed_id})" href="#"><i class="icon-done material-icons">done_all</i></a> + </div>` - if (hl.active) { - new_row.addClassName("active"); - - if (App.isCombinedMode()) - Article.cdmScrollToId(id); - else - Article.view(id); - } + const tmp = document.createElement("div"); + tmp.innerHTML = vgrhdr; - if (hl.selected) this.select("all", id); + $("headlines-frame").appendChild(tmp.firstChild); - Article.unpack(new_row); + this.vgroup_last_feed = hl.feed_id; + } - } - }); - }, - render: function (headlines, hl) { - let row = null; + if (App.isCombinedMode()) { + row_class += App.getInitParam("cdm_expanded") ? " expanded" : " expandable"; + + const comments = Article.formatComments(hl); + const originally_from = Article.formatOriginallyFrom(hl); + + row = `<div class="cdm ${row_class} ${Article.getScoreClass(hl.score)}" + id="RROW-${hl.id}" + data-article-id="${hl.id}" + data-orig-feed-id="${hl.feed_id}" + data-content="${App.escapeHtml(hl.content)}" + data-score="${hl.score}" + data-article-title="${App.escapeHtml(hl.title)}" + onmouseover="Article.mouseIn(${hl.id})" + onmouseout="Article.mouseOut(${hl.id})"> + <div class="header-sticky-guard"></div> + <div class="header"> + <div class="left"> + <input dojoType="dijit.form.CheckBox" type="checkbox" onclick="Headlines.onRowChecked(this)" class='rchk'> + <i class="marked-pic marked-${hl.id} material-icons" onclick="Headlines.toggleMark(${hl.id})">star</i> + <i class="pub-pic pub-${hl.id} material-icons" onclick="Headlines.togglePub(${hl.id})">rss_feed</i> + </div> - let row_class = ""; + <span onclick="return Headlines.click(event, ${hl.id});" data-article-id="${hl.id}" class="titleWrap hlMenuAttach"> + <a class="title" title="${App.escapeHtml(hl.title)}" target="_blank" rel="noopener noreferrer" href="${App.escapeHtml(hl.link)}"> + ${hl.title}</a> + <span class="author">${hl.author}</span> + ${hl.labels} + ${hl.cdm_excerpt ? hl.cdm_excerpt : ""} + </span> + + <div class="feed"> + <a href="#" style="background-color: ${hl.feed_bg_color}" + onclick="Feeds.open({feed:${hl.feed_id}})">${hl.feed_title}</a> + </div> - if (hl.marked) row_class += " marked"; - if (hl.published) row_class += " published"; - if (hl.unread) row_class += " Unread"; - if (headlines.vfeed_group_enabled) row_class += " vgrlf"; + <span class="updated" title="${hl.imported}">${hl.updated}</span> - if (headlines.vfeed_group_enabled && hl.feed_title && this.vgroup_last_feed != hl.feed_id) { - let vgrhdr = `<div data-feed-id='${hl.feed_id}' class='feed-title'> - <div style='float : right'>${hl.feed_icon}</div> - <a class="title" href="#" onclick="Feeds.open({feed:${hl.feed_id}})">${hl.feed_title} - <a class="catchup" title="${__('mark feed as read')}" onclick="Feeds.catchupFeedInGroup(${hl.feed_id})" href="#"><i class="icon-done material-icons">done_all</i></a> - </div>` + <div class="right"> + <i class="material-icons icon-score" title="${hl.score}" onclick="Article.setScore(${hl.id}, this)">${Article.getScorePic(hl.score)}</i> - const tmp = document.createElement("div"); - tmp.innerHTML = vgrhdr; + <span style="cursor : pointer" title="${App.escapeHtml(hl.feed_title)}" onclick="Feeds.open({feed:${hl.feed_id}})"> + ${hl.feed_icon}</span> + </div> - $("headlines-frame").appendChild(tmp.firstChild); + </div> - this.vgroup_last_feed = hl.feed_id; - } + <div class="content" onclick="return Headlines.click(event, ${hl.id}, true);"> + <div id="POSTNOTE-${hl.id}">${hl.note}</div> + <div class="content-inner" lang="${hl.lang ? hl.lang : 'en'}"> + <img src="${App.getInitParam('icon_indicator_white')}"> + </div> + <div class="intermediate"> + ${hl.enclosures} + </div> + <div class="footer" onclick="event.stopPropagation()"> - if (App.isCombinedMode()) { - row_class += App.getInitParam("cdm_expanded") ? " expanded" : " expandable"; - - const comments = Article.formatComments(hl); - const originally_from = Article.formatOriginallyFrom(hl); - - row = `<div class="cdm ${row_class} ${Article.getScoreClass(hl.score)}" - id="RROW-${hl.id}" - data-article-id="${hl.id}" - data-orig-feed-id="${hl.feed_id}" - data-content="${escapeHtml(hl.content)}" - data-score="${hl.score}" - data-article-title="${escapeHtml(hl.title)}" - onmouseover="Article.mouseIn(${hl.id})" - onmouseout="Article.mouseOut(${hl.id})"> - - <div class="header"> <div class="left"> - <input dojoType="dijit.form.CheckBox" type="checkbox" onclick="Headlines.onRowChecked(this)" class='rchk'> - <i class="marked-pic marked-${hl.id} material-icons" onclick="Headlines.toggleMark(${hl.id})">star</i> - <i class="pub-pic pub-${hl.id} material-icons" onclick="Headlines.togglePub(${hl.id})">rss_feed</i> + ${hl.buttons_left} + <i class="material-icons">label_outline</i> + <span id="ATSTR-${hl.id}">${hl.tags_str}</span> + <a title="${__("Edit tags for this article")}" href="#" + onclick="Article.editTags(${hl.id})">(+)</a> + ${comments} </div> - - <span onclick="return Headlines.click(event, ${hl.id});" data-article-id="${hl.id}" class="titleWrap hlMenuAttach"> - <a class="title" title="${escapeHtml(hl.title)}" target="_blank" rel="noopener noreferrer" href="${escapeHtml(hl.link)}"> - ${hl.title}</a> - <span class="author">${hl.author}</span> - ${hl.labels} - ${hl.cdm_excerpt ? hl.cdm_excerpt : ""} - </span> - - <div class="feed"> - <a href="#" style="background-color: ${hl.feed_bg_color}" - onclick="Feeds.open({feed:${hl.feed_id}})">${hl.feed_title}</a> - </div> - - <span class="updated" title="${hl.imported}">${hl.updated}</span> - - <div class="right"> - <i class="material-icons icon-score" title="${hl.score}" onclick="Article.setScore(${hl.id}, this)">${Article.getScorePic(hl.score)}</i> - - <span style="cursor : pointer" title="${escapeHtml(hl.feed_title)}" onclick="Feeds.open({feed:${hl.feed_id}})"> - ${hl.feed_icon}</span> - </div> - - </div> - - <div class="content" onclick="return Headlines.click(event, ${hl.id}, true);"> - <div id="POSTNOTE-${hl.id}">${hl.note}</div> - <div class="content-inner" lang="${hl.lang ? hl.lang : 'en'}"> - <img src="${App.getInitParam('icon_indicator_white')}"> - </div> - <div class="intermediate"> - ${hl.enclosures} - </div> - <div class="footer" onclick="event.stopPropagation()"> - - <div class="left"> - ${hl.buttons_left} - <i class="material-icons">label_outline</i> - <span id="ATSTR-${hl.id}">${hl.tags_str}</span> - <a title="${__("Edit tags for this article")}" href="#" - onclick="Article.editTags(${hl.id})">(+)</a> - ${comments} - </div> - - <div class="right"> - ${originally_from} - ${hl.buttons} - </div> + + <div class="right"> + ${originally_from} + ${hl.buttons} </div> </div> - </div>`; - - - } else { - row = `<div class="hl ${row_class} ${Article.getScoreClass(hl.score)}" - id="RROW-${hl.id}" - data-orig-feed-id="${hl.feed_id}" - data-article-id="${hl.id}" - data-score="${hl.score}" - data-article-title="${escapeHtml(hl.title)}" - onmouseover="Article.mouseIn(${hl.id})" - onmouseout="Article.mouseOut(${hl.id})"> - <div class="left"> - <input dojoType="dijit.form.CheckBox" type="checkbox" onclick="Headlines.onRowChecked(this)" class='rchk'> - <i class="marked-pic marked-${hl.id} material-icons" onclick="Headlines.toggleMark(${hl.id})">star</i> - <i class="pub-pic pub-${hl.id} material-icons" onclick="Headlines.togglePub(${hl.id})">rss_feed</i> - </div> - <div onclick="return Headlines.click(event, ${hl.id})" class="title"> - <span data-article-id="${hl.id}" class="hl-content hlMenuAttach"> - <a class="title" href="${escapeHtml(hl.link)}">${hl.title} <span class="preview">${hl.content_preview}</span></a> - <span class="author">${hl.author}</span> - ${hl.labels} + </div> + </div>`; + + + } else { + row = `<div class="hl ${row_class} ${Article.getScoreClass(hl.score)}" + id="RROW-${hl.id}" + data-orig-feed-id="${hl.feed_id}" + data-article-id="${hl.id}" + data-score="${hl.score}" + data-article-title="${App.escapeHtml(hl.title)}" + onmouseover="Article.mouseIn(${hl.id})" + onmouseout="Article.mouseOut(${hl.id})"> + <div class="left"> + <input dojoType="dijit.form.CheckBox" type="checkbox" onclick="Headlines.onRowChecked(this)" class='rchk'> + <i class="marked-pic marked-${hl.id} material-icons" onclick="Headlines.toggleMark(${hl.id})">star</i> + <i class="pub-pic pub-${hl.id} material-icons" onclick="Headlines.togglePub(${hl.id})">rss_feed</i> + </div> + <div onclick="return Headlines.click(event, ${hl.id})" class="title"> + <span data-article-id="${hl.id}" class="hl-content hlMenuAttach"> + <a class="title" href="${App.escapeHtml(hl.link)}">${hl.title} <span class="preview">${hl.content_preview}</span></a> + <span class="author">${hl.author}</span> + ${hl.labels} + </span> + </div> + <span class="feed"> + <a style="background : ${hl.feed_bg_color}" href="#" onclick="Feeds.open({feed:${hl.feed_id}})">${hl.feed_title}</a> </span> - </div> - <span class="feed"> - <a style="background : ${hl.feed_bg_color}" href="#" onclick="Feeds.open({feed:${hl.feed_id}})">${hl.feed_title}</a> - </span> - <div title="${hl.imported}"> - <span class="updated">${hl.updated}</span> - </div> - <div class="right"> - <i class="material-icons icon-score" title="${hl.score}" onclick="Article.setScore(${hl.id}, this)">${Article.getScorePic(hl.score)}</i> - <span onclick="Feeds.open({feed:${hl.feed_id}})" style="cursor : pointer" title="${escapeHtml(hl.feed_title)}">${hl.feed_icon}</span> - </div> - </div> - `; - } + <div title="${hl.imported}"> + <span class="updated">${hl.updated}</span> + </div> + <div class="right"> + <i class="material-icons icon-score" title="${hl.score}" onclick="Article.setScore(${hl.id}, this)">${Article.getScorePic(hl.score)}</i> + <span onclick="Feeds.open({feed:${hl.feed_id}})" style="cursor : pointer" title="${App.escapeHtml(hl.feed_title)}">${hl.feed_icon}</span> + </div> + </div> + `; + } - const tmp = document.createElement("div"); - tmp.innerHTML = row; - dojo.parser.parse(tmp); + const tmp = document.createElement("div"); + tmp.innerHTML = row; + dojo.parser.parse(tmp); - this.row_observer.observe(tmp.firstChild, {attributes: true}); + this.row_observer.observe(tmp.firstChild, {attributes: true}); - PluginHost.run(PluginHost.HOOK_HEADLINE_RENDERED, tmp.firstChild); + PluginHost.run(PluginHost.HOOK_HEADLINE_RENDERED, tmp.firstChild); - return tmp.firstChild; - }, - updateCurrentUnread: function() { - if ($("feed_current_unread")) { - const feed_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat()); + return tmp.firstChild; + }, + updateCurrentUnread: function () { + if ($("feed_current_unread")) { + const feed_unread = Feeds.getUnread(Feeds.getActive(), Feeds.activeIsCat()); - if (feed_unread > 0 && !Element.visible("feeds-holder")) { - $("feed_current_unread").innerText = feed_unread; - Element.show("feed_current_unread"); - } else { - Element.hide("feed_current_unread"); - } + if (feed_unread > 0 && !Element.visible("feeds-holder")) { + $("feed_current_unread").innerText = feed_unread; + Element.show("feed_current_unread"); + } else { + Element.hide("feed_current_unread"); } - }, - onLoaded: function (transport, offset, append) { - const reply = App.handleRpcJson(transport); - - console.log("Headlines.onLoaded: offset=", offset, "append=", append); - - let is_cat = false; - let feed_id = false; - - if (reply) { - - is_cat = reply['headlines']['is_cat']; - feed_id = reply['headlines']['id']; - Feeds.last_search_query = reply['headlines']['search_query']; - - if (feed_id != -7 && (feed_id != Feeds.getActive() || is_cat != Feeds.activeIsCat())) - return; - - const headlines_count = reply['headlines-info']['count']; - - //this.vgroup_last_feed = reply['headlines-info']['vgroup_last_feed']; - this.current_first_id = reply['headlines']['first_id']; - - console.log('received', headlines_count, 'headlines'); - - if (!append) { - Feeds.infscroll_disabled = parseInt(headlines_count) != 30; - console.log('infscroll_disabled=', Feeds.infscroll_disabled); - - // TODO: the below needs to be applied again when switching expanded/expandable on the fly - // via hotkeys, not just on feed load + } + }, + onLoaded: function (transport, offset, append) { + const reply = App.handleRpcJson(transport); - $("headlines-frame").removeClassName("cdm"); - $("headlines-frame").removeClassName("normal"); + console.log("Headlines.onLoaded: offset=", offset, "append=", append); - $("headlines-frame").addClassName(App.isCombinedMode() ? "cdm" : "normal"); + let is_cat = false; + let feed_id = false; - $("headlines-frame").setAttribute("is-vfeed", - reply['headlines']['is_vfeed'] ? 1 : 0); + if (reply) { - // for floating title because it's placed outside of headlines-frame - $("main").removeClassName("expandable"); - $("main").removeClassName("expanded"); + is_cat = reply['headlines']['is_cat']; + feed_id = reply['headlines']['id']; + Feeds.last_search_query = reply['headlines']['search_query']; - if (App.isCombinedMode()) - $("main").addClassName(App.getInitParam("cdm_expanded") ? " expanded" : " expandable"); + if (feed_id != -7 && (feed_id != Feeds.getActive() || is_cat != Feeds.activeIsCat())) + return; - Article.setActive(0); + const headlines_count = reply['headlines-info']['count']; - try { - $("headlines-frame").removeClassName("smooth-scroll"); - $("headlines-frame").scrollTop = 0; - $("headlines-frame").addClassName("smooth-scroll"); + //this.vgroup_last_feed = reply['headlines-info']['vgroup_last_feed']; + this.current_first_id = reply['headlines']['first_id']; - Element.hide("floatingTitle"); - $("floatingTitle").setAttribute("data-article-id", 0); - $("floatingTitle").innerHTML = ""; - } catch (e) { - console.warn(e); - } + console.log('received', headlines_count, 'headlines'); - this.headlines = []; - this.vgroup_last_feed = undefined; + if (!append) { + Feeds.infscroll_disabled = parseInt(headlines_count) != 30; + console.log('infscroll_disabled=', Feeds.infscroll_disabled); - dojo.html.set($("toolbar-headlines"), - reply['headlines']['toolbar'], - {parseContent: true}); + // also called in renderAgain() after view mode switch + Headlines.setCommonClasses(); - if (typeof reply['headlines']['content'] == 'string') { - $("headlines-frame").innerHTML = reply['headlines']['content']; - } else { - $("headlines-frame").innerHTML = ''; + $("headlines-frame").setAttribute("is-vfeed", + reply['headlines']['is_vfeed'] ? 1 : 0); - for (let i = 0; i < reply['headlines']['content'].length; i++) { - const hl = reply['headlines']['content'][i]; - - $("headlines-frame").appendChild(this.render(reply['headlines'], hl)); + Article.setActive(0); - this.headlines[parseInt(hl.id)] = hl; - } - } + try { + $("headlines-frame").removeClassName("smooth-scroll"); + $("headlines-frame").scrollTop = 0; + $("headlines-frame").addClassName("smooth-scroll"); + } catch (e) { + console.warn(e); + } - let hsp = $("headlines-spacer"); + this.headlines = []; + this.vgroup_last_feed = undefined; - if (!hsp) { - hsp = document.createElement("div"); - hsp.id = "headlines-spacer"; - } + dojo.html.set($("toolbar-headlines"), + reply['headlines']['toolbar'], + {parseContent: true}); - dijit.byId('headlines-frame').domNode.appendChild(hsp); + if (typeof reply['headlines']['content'] == 'string') { + $("headlines-frame").innerHTML = reply['headlines']['content']; + } else { + $("headlines-frame").innerHTML = ''; - this.initHeadlinesMenu(); + for (let i = 0; i < reply['headlines']['content'].length; i++) { + const hl = reply['headlines']['content'][i]; - if (Feeds.infscroll_disabled) - hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnread()'>" + - __("Click to open next unread feed.") + "</a>"; + $("headlines-frame").appendChild(this.render(reply['headlines'], hl)); - if (Feeds._search_query) { - $("feed_title").innerHTML += "<span id='cancel_search'>" + - " (<a href='#' onclick='Feeds.cancelSearch()'>" + __("Cancel search") + "</a>)" + - "</span>"; + this.headlines[parseInt(hl.id)] = hl; } + } - Headlines.updateCurrentUnread(); - - } else if (headlines_count > 0 && feed_id == Feeds.getActive() && is_cat == Feeds.activeIsCat()) { - const c = dijit.byId("headlines-frame"); - - let hsp = $("headlines-spacer"); + let hsp = $("headlines-spacer"); - if (hsp) - c.domNode.removeChild(hsp); + if (!hsp) { + hsp = document.createElement("div"); + hsp.id = "headlines-spacer"; + } - let headlines_appended = 0; + dijit.byId('headlines-frame').domNode.appendChild(hsp); - if (typeof reply['headlines']['content'] == 'string') { - $("headlines-frame").innerHTML = reply['headlines']['content']; - } else { - for (let i = 0; i < reply['headlines']['content'].length; i++) { - const hl = reply['headlines']['content'][i]; + this.initHeadlinesMenu(); - if (!this.headlines[parseInt(hl.id)]) { - $("headlines-frame").appendChild(this.render(reply['headlines'], hl)); + if (Feeds.infscroll_disabled) + hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnread()'>" + + __("Click to open next unread feed.") + "</a>"; - this.headlines[parseInt(hl.id)] = hl; - ++headlines_appended; - } - } - } - - Feeds.infscroll_disabled = headlines_appended == 0; + if (Feeds._search_query) { + $("feed_title").innerHTML += "<span id='cancel_search'>" + + " (<a href='#' onclick='Feeds.cancelSearch()'>" + __("Cancel search") + "</a>)" + + "</span>"; + } - console.log('appended', headlines_appended, 'headlines, infscroll_disabled=', Feeds.infscroll_disabled); + Headlines.updateCurrentUnread(); - if (!hsp) { - hsp = document.createElement("div"); - hsp.id = "headlines-spacer"; - } + } else if (headlines_count > 0 && feed_id == Feeds.getActive() && is_cat == Feeds.activeIsCat()) { + const c = dijit.byId("headlines-frame"); - c.domNode.appendChild(hsp); + let hsp = $("headlines-spacer"); - this.initHeadlinesMenu(); + if (hsp) + c.domNode.removeChild(hsp); - if (Feeds.infscroll_disabled) { - hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnread()'>" + - __("Click to open next unread feed.") + "</a>"; - } + let headlines_appended = 0; + if (typeof reply['headlines']['content'] == 'string') { + $("headlines-frame").innerHTML = reply['headlines']['content']; } else { - Feeds.infscroll_disabled = true; - const first_id_changed = reply['headlines']['first_id_changed']; + for (let i = 0; i < reply['headlines']['content'].length; i++) { + const hl = reply['headlines']['content'][i]; - console.log("no headlines received, infscroll_disabled=", Feeds.infscroll_disabled, 'first_id_changed=', first_id_changed); - - let hsp = $("headlines-spacer"); + if (!this.headlines[parseInt(hl.id)]) { + $("headlines-frame").appendChild(this.render(reply['headlines'], hl)); - if (hsp) { - if (first_id_changed) { - hsp.innerHTML = "<a href='#' onclick='Feeds.reloadCurrent()'>" + - __("New articles found, reload feed to continue.") + "</a>"; - } else { - hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnread()'>" + - __("Click to open next unread feed.") + "</a>"; + this.headlines[parseInt(hl.id)] = hl; + ++headlines_appended; } } } - } else { - console.error("Invalid object received: " + transport.responseText); - dijit.byId("headlines-frame").attr('content', "<div class='whiteBox'>" + - __('Could not update headlines (invalid object received - see error console for details)') + - "</div>"); - } - - Feeds.infscroll_in_progress = 0; + Feeds.infscroll_disabled = headlines_appended == 0; - // this is used to auto-catchup articles if needed after infscroll request has finished, - // unpack visible articles, fill buffer more, etc - this.scrollHandler(); + console.log('appended', headlines_appended, 'headlines, infscroll_disabled=', Feeds.infscroll_disabled); - Notify.close(); - }, - reverse: function () { - const toolbar = document.forms["toolbar-main"]; - const order_by = dijit.getEnclosingWidget(toolbar.order_by); - - let value = order_by.attr('value'); - - if (value != "date_reverse") - value = "date_reverse"; - else - value = "default"; + if (!hsp) { + hsp = document.createElement("div"); + hsp.id = "headlines-spacer"; + } - order_by.attr('value', value); + c.domNode.appendChild(hsp); - Feeds.reloadCurrent(); - }, - selectionToggleUnread: function (params) { - params = params || {}; + this.initHeadlinesMenu(); - const cmode = params.cmode != undefined ? params.cmode : 2; - const no_error = params.no_error || false; - const ids = params.ids || Headlines.getSelected(); + if (Feeds.infscroll_disabled) { + hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnread()'>" + + __("Click to open next unread feed.") + "</a>"; + } - if (ids.length == 0) { - if (!no_error) - alert(__("No articles selected.")); + } else { + Feeds.infscroll_disabled = true; + const first_id_changed = reply['headlines']['first_id_changed']; - return; - } + console.log("no headlines received, infscroll_disabled=", Feeds.infscroll_disabled, 'first_id_changed=', first_id_changed); - ids.each((id) => { - const row = $("RROW-" + id); + const hsp = $("headlines-spacer"); - if (row) { - switch (cmode) { - case 0: - row.removeClassName("Unread"); - break; - case 1: - row.addClassName("Unread"); - break; - case 2: - row.toggleClassName("Unread"); + if (hsp) { + if (first_id_changed) { + hsp.innerHTML = "<a href='#' onclick='Feeds.reloadCurrent()'>" + + __("New articles found, reload feed to continue.") + "</a>"; + } else { + hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnread()'>" + + __("Click to open next unread feed.") + "</a>"; } } - }); - }, - selectionToggleMarked: function (ids) { - ids = ids || Headlines.getSelected(); - - if (ids.length == 0) { - alert(__("No articles selected.")); - return; } - ids.each((id) => { - this.toggleMark(id); + $$(".cdm .header-sticky-guard").each((e) => { + this.sticky_header_observer.observe(e) }); - }, - selectionTogglePublished: function (ids) { - ids = ids || Headlines.getSelected(); - - if (ids.length == 0) { - alert(__("No articles selected.")); - return; - } - - ids.each((id) => { - this.togglePub(id); - }); - }, - toggleMark: function (id) { - const row = $("RROW-" + id); - - if (row) - row.toggleClassName("marked"); - - }, - togglePub: function (id) { - const row = $("RROW-" + id); - - if (row) - row.toggleClassName("published"); - }, - move: function (mode, params) { - params = params || {}; - - const noscroll = params.noscroll || false; - const noexpand = params.noexpand || false; - const event = params.event; - - const rows = Headlines.getLoaded(); - - let prev_id = false; - let next_id = false; - - const active_row = $("RROW-" + Article.getActive()); - if (!active_row) { - Article.setActive(0); - } - - if (!Article.getActive() || (active_row && !Headlines.isChildVisible(active_row, $("headlines-frame")))) { - next_id = Headlines.firstVisible(); - prev_id = next_id; - } else { - for (let i = 0; i < rows.length; i++) { - if (rows[i] == Article.getActive()) { - - // Account for adjacent identical article ids. - if (i > 0) prev_id = rows[i - 1]; + if (App.getInitParam("cdm_expanded")) + $$("#headlines-frame > div[id*=RROW].cdm").each((e) => { + this.unpack_observer.observe(e) + }); - for (let j = i + 1; j < rows.length; j++) { - if (rows[j] != Article.getActive()) { - next_id = rows[j]; - break; - } - } - break; - } - } - } + } else { + console.error("Invalid object received: " + transport.responseText); + dijit.byId("headlines-frame").attr('content', "<div class='whiteBox'>" + + __('Could not update headlines (invalid object received - see error console for details)') + + "</div>"); + } - console.log("cur: " + Article.getActive() + " next: " + next_id); + Feeds.infscroll_in_progress = 0; - if (mode === "next") { - if (next_id || Article.getActive()) { - if (App.isCombinedMode()) { + // this is used to auto-catchup articles if needed after infscroll request has finished, + // unpack visible articles, fill buffer more, etc + this.scrollHandler(); - //const row = $("RROW-" + Article.getActive()); - const ctr = $("headlines-frame"); + Notify.close(); + }, + reverse: function () { + const toolbar = document.forms["toolbar-main"]; + const order_by = dijit.getEnclosingWidget(toolbar.order_by); - if (!noscroll) { - Article.scroll(ctr.offsetHeight / 2, event); - } else if (next_id) { - Article.setActive(next_id); - Article.cdmScrollToId(next_id, true, event); - } + let value = order_by.attr('value'); - } else if (next_id) { - Headlines.correctHeadlinesOffset(next_id); - Article.view(next_id, noexpand); - } - } - } + if (value != "date_reverse") + value = "date_reverse"; + else + value = "default"; - if (mode === "prev") { - if (prev_id || Article.getActive()) { - if (App.isCombinedMode()) { + order_by.attr('value', value); - const row = $("RROW-" + Article.getActive()); - //const prev_row = $("RROW-" + prev_id); - const ctr = $("headlines-frame"); + Feeds.reloadCurrent(); + }, + selectionToggleUnread: function (params) { + params = params || {}; - if (!noscroll) { - Article.scroll(-ctr.offsetHeight / 2, event); - } else { - if (row && Math.round(row.offsetTop) < Math.round(ctr.scrollTop)) { - Article.cdmScrollToId(Article.getActive(), noscroll, event); - } else if (prev_id) { - Article.setActive(prev_id); - Article.cdmScrollToId(prev_id, noscroll, event); - } - } + const cmode = params.cmode != undefined ? params.cmode : 2; + const no_error = params.no_error || false; + const ids = params.ids || Headlines.getSelected(); - } else if (prev_id) { - Headlines.correctHeadlinesOffset(prev_id); - Article.view(prev_id, noexpand); - } - } - } - }, - updateSelectedPrompt: function () { - const count = Headlines.getSelected().length; - const elem = $("selected_prompt"); + if (ids.length == 0) { + if (!no_error) + alert(__("No articles selected.")); - if (elem) { - elem.innerHTML = ngettext("%d article selected", - "%d articles selected", count).replace("%d", count); + return; + } - count > 0 ? Element.show(elem) : Element.hide(elem); - } - }, - toggleUnread: function (id, cmode) { + ids.each((id) => { const row = $("RROW-" + id); if (row) { - if (typeof cmode == "undefined") cmode = 2; - switch (cmode) { case 0: row.removeClassName("Unread"); @@ -948,554 +764,668 @@ define(["dojo/_base/declare"], function (declare) { break; case 2: row.toggleClassName("Unread"); - break; } } - }, - selectionRemoveLabel: function (id, ids) { - if (!ids) ids = Headlines.getSelected(); + }); + }, + selectionToggleMarked: function (ids) { + ids = ids || Headlines.getSelected(); + + if (ids.length == 0) { + alert(__("No articles selected.")); + return; + } - if (ids.length == 0) { - alert(__("No articles selected.")); - return; - } + ids.each((id) => { + this.toggleMark(id); + }); + }, + selectionTogglePublished: function (ids) { + ids = ids || Headlines.getSelected(); - const query = { - op: "article", method: "removeFromLabel", - ids: ids.toString(), lid: id - }; + if (ids.length == 0) { + alert(__("No articles selected.")); + return; + } - xhrPost("backend.php", query, (transport) => { - App.handleRpcJson(transport); - this.onLabelsUpdated(transport); - }); - }, - selectionAssignLabel: function (id, ids) { - if (!ids) ids = Headlines.getSelected(); + ids.each((id) => { + this.togglePub(id); + }); + }, + toggleMark: function (id) { + const row = $("RROW-" + id); + + if (row) + row.toggleClassName("marked"); + + }, + togglePub: function (id) { + const row = $("RROW-" + id); + + if (row) + row.toggleClassName("published"); + }, + move: function (mode, params) { + params = params || {}; + + const no_expand = params.no_expand || false; + const force_previous = params.force_previous || this.default_force_previous; + const force_to_top = params.force_to_top || this.default_force_to_top; + + let prev_id = false; + let next_id = false; + let current_id = Article.getActive(); + + if (!Headlines.isChildVisible($("RROW-" + current_id))) { + console.log('active article is obscured, resetting to first visible...'); + current_id = Headlines.firstVisible(); + prev_id = current_id; + next_id = current_id; + } else { + const rows = Headlines.getLoaded(); - if (ids.length == 0) { - alert(__("No articles selected.")); - return; - } + for (let i = 0; i < rows.length; i++) { + if (rows[i] == current_id) { - const query = { - op: "article", method: "assignToLabel", - ids: ids.toString(), lid: id - }; + // Account for adjacent identical article ids. + if (i > 0) prev_id = rows[i - 1]; - xhrPost("backend.php", query, (transport) => { - App.handleRpcJson(transport); - this.onLabelsUpdated(transport); - }); - }, - deleteSelection: function () { - const rows = Headlines.getSelected(); + for (let j = i + 1; j < rows.length; j++) { + if (rows[j] != current_id) { + next_id = rows[j]; + break; + } + } + break; + } + } + } - if (rows.length == 0) { - alert(__("No articles selected.")); - return; + console.log("cur: " + current_id + " next: " + next_id + " prev:" + prev_id); + + if (mode === "next") { + if (next_id) { + if (App.isCombinedMode()) { + window.requestAnimationFrame(() => { + Article.setActive(next_id); + Article.cdmMoveToId(next_id, {force_to_top: force_to_top}); + }); + } else { + Article.view(next_id, no_expand); + } } + } else if (mode === "prev") { + if (prev_id || current_id) { + if (App.isCombinedMode()) { + window.requestAnimationFrame(() => { + const row = $("RROW-" + current_id); + const ctr = $("headlines-frame"); + const delta_px = Math.round(row.offsetTop) - Math.round(ctr.scrollTop); - const fn = Feeds.getName(Feeds.getActive(), Feeds.activeIsCat()); - let str; + console.log('moving back, delta_px', delta_px); - if (Feeds.getActive() != 0) { - str = ngettext("Delete %d selected article in %s?", "Delete %d selected articles in %s?", rows.length); - } else { - str = ngettext("Delete %d selected article?", "Delete %d selected articles?", rows.length); + if (!force_previous && row && delta_px < -8) { + Article.setActive(current_id); + Article.cdmMoveToId(current_id, {force_to_top: force_to_top}); + } else if (prev_id) { + Article.setActive(prev_id); + Article.cdmMoveToId(prev_id, {force_to_top: force_to_top}); + } + }); + } else if (prev_id) { + Article.view(prev_id, no_expand); + } } + } + }, + updateSelectedPrompt: function () { + const count = Headlines.getSelected().length; + const elem = $("selected_prompt"); - str = str.replace("%d", rows.length); - str = str.replace("%s", fn); + if (elem) { + elem.innerHTML = ngettext("%d article selected", + "%d articles selected", count).replace("%d", count); - if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { - return; + count > 0 ? Element.show(elem) : Element.hide(elem); + } + }, + toggleUnread: function (id, cmode) { + const row = $("RROW-" + id); + + if (row) { + if (typeof cmode == "undefined") cmode = 2; + + switch (cmode) { + case 0: + row.removeClassName("Unread"); + break; + case 1: + row.addClassName("Unread"); + break; + case 2: + row.toggleClassName("Unread"); + break; } + } + }, + selectionRemoveLabel: function (id, ids) { + if (!ids) ids = Headlines.getSelected(); - const query = {op: "rpc", method: "delete", ids: rows.toString()}; + if (ids.length == 0) { + alert(__("No articles selected.")); + return; + } - xhrPost("backend.php", query, (transport) => { - App.handleRpcJson(transport); - Feeds.reloadCurrent(); - }); - }, - getSelected: function () { - const rv = []; + const query = { + op: "article", method: "removeFromLabel", + ids: ids.toString(), lid: id + }; + + xhrPost("backend.php", query, (transport) => { + App.handleRpcJson(transport); + this.onLabelsUpdated(transport); + }); + }, + selectionAssignLabel: function (id, ids) { + if (!ids) ids = Headlines.getSelected(); + + if (ids.length == 0) { + alert(__("No articles selected.")); + return; + } - $$("#headlines-frame > div[id*=RROW][class*=Selected]").each( - function (child) { - rv.push(child.getAttribute("data-article-id")); - }); + const query = { + op: "article", method: "assignToLabel", + ids: ids.toString(), lid: id + }; + + xhrPost("backend.php", query, (transport) => { + App.handleRpcJson(transport); + this.onLabelsUpdated(transport); + }); + }, + deleteSelection: function () { + const rows = Headlines.getSelected(); + + if (rows.length == 0) { + alert(__("No articles selected.")); + return; + } - // consider active article a honorary member of selected articles - if (Article.getActive()) - rv.push(Article.getActive()); + const fn = Feeds.getName(Feeds.getActive(), Feeds.activeIsCat()); + let str; - return rv.uniq(); - }, - getLoaded: function () { - const rv = []; + if (Feeds.getActive() != 0) { + str = ngettext("Delete %d selected article in %s?", "Delete %d selected articles in %s?", rows.length); + } else { + str = ngettext("Delete %d selected article?", "Delete %d selected articles?", rows.length); + } - const children = $$("#headlines-frame > div[id*=RROW-]"); + str = str.replace("%d", rows.length); + str = str.replace("%s", fn); - children.each(function (child) { - if (Element.visible(child)) { - rv.push(child.getAttribute("data-article-id")); - } + if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { + return; + } + + const query = {op: "rpc", method: "delete", ids: rows.toString()}; + + xhrPost("backend.php", query, (transport) => { + App.handleRpcJson(transport); + Feeds.reloadCurrent(); + }); + }, + getSelected: function () { + const rv = []; + + $$("#headlines-frame > div[id*=RROW][class*=Selected]").each( + function (child) { + rv.push(child.getAttribute("data-article-id")); }); - return rv; - }, - onRowChecked: function (elem) { - const row = elem.domNode.up("div[id*=RROW]"); + // consider active article a honorary member of selected articles + if (Article.getActive()) + rv.push(Article.getActive()); - // do not allow unchecking active article checkbox - if (row.hasClassName("active")) { - elem.attr("checked", 1); - return; - } + return rv.uniq(); + }, + getLoaded: function () { + const rv = []; - if (elem.attr("checked")) { - row.addClassName("Selected"); - } else { - row.removeClassName("Selected"); - } - }, - getRange: function (start, stop) { - if (start == stop) - return [start]; + const children = $$("#headlines-frame > div[id*=RROW-]"); - const rows = $$("#headlines-frame > div[id*=RROW]"); - const results = []; - let collecting = false; + children.each(function (child) { + if (Element.visible(child)) { + rv.push(child.getAttribute("data-article-id")); + } + }); - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; - const id = row.getAttribute('data-article-id'); + return rv; + }, + onRowChecked: function (elem) { + const row = elem.domNode.up("div[id*=RROW]"); - if (id == start || id == stop) { - if (!collecting) { - collecting = true; - } else { - results.push(id); - break; - } - } + // do not allow unchecking active article checkbox + if (row.hasClassName("active")) { + elem.attr("checked", 1); + return; + } - if (collecting) + if (elem.attr("checked")) { + row.addClassName("Selected"); + } else { + row.removeClassName("Selected"); + } + }, + getRange: function (start, stop) { + if (start == stop) + return [start]; + + const rows = $$("#headlines-frame > div[id*=RROW]"); + const results = []; + let collecting = false; + + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + const id = row.getAttribute('data-article-id'); + + if (id == start || id == stop) { + if (!collecting) { + collecting = true; + } else { results.push(id); + break; + } } - return results; - }, - select: function (mode, articleId) { - // mode = all,none,unread,invert,marked,published - let query = "#headlines-frame > div[id*=RROW]"; + if (collecting) + results.push(id); + } - if (articleId) query += "[data-article-id=" + articleId + "]"; + return results; + }, + select: function (mode, articleId) { + // mode = all,none,unread,invert,marked,published + let query = "#headlines-frame > div[id*=RROW]"; + + if (articleId) query += "[data-article-id=" + articleId + "]"; + + switch (mode) { + case "none": + case "all": + case "invert": + break; + case "marked": + query += "[class*=marked]"; + break; + case "published": + query += "[class*=published]"; + break; + case "unread": + query += "[class*=Unread]"; + break; + default: + console.warn("select: unknown mode", mode); + } + + const rows = $$(query); + + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; switch (mode) { case "none": - case "all": - case "invert": + row.removeClassName("Selected"); break; - case "marked": - query += "[class*=marked]"; - break; - case "published": - query += "[class*=published]"; - break; - case "unread": - query += "[class*=Unread]"; + case "invert": + row.toggleClassName("Selected"); break; default: - console.warn("select: unknown mode", mode); - } - - const rows = $$(query); - - for (let i = 0; i < rows.length; i++) { - const row = rows[i]; - - switch (mode) { - case "none": - row.removeClassName("Selected"); - break; - case "invert": - row.toggleClassName("Selected"); - break; - default: - row.addClassName("Selected"); - } - } - }, - archiveSelection: function () { - const rows = Headlines.getSelected(); - - if (rows.length == 0) { - alert(__("No articles selected.")); - return; + row.addClassName("Selected"); } + } + }, + archiveSelection: function () { + const rows = Headlines.getSelected(); - const fn = Feeds.getName(Feeds.getActive(), Feeds.activeIsCat()); - let str; - let op; + if (rows.length == 0) { + alert(__("No articles selected.")); + return; + } - if (Feeds.getActive() != 0) { - str = ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows.length); - op = "archive"; - } else { - str = ngettext("Move %d archived article back?", "Move %d archived articles back?", rows.length); - str += " " + __("Please note that unstarred articles might get purged on next feed update."); + const fn = Feeds.getName(Feeds.getActive(), Feeds.activeIsCat()); + let str; + let op; - op = "unarchive"; - } + if (Feeds.getActive() != 0) { + str = ngettext("Archive %d selected article in %s?", "Archive %d selected articles in %s?", rows.length); + op = "archive"; + } else { + str = ngettext("Move %d archived article back?", "Move %d archived articles back?", rows.length); + str += " " + __("Please note that unstarred articles might get purged on next feed update."); - str = str.replace("%d", rows.length); - str = str.replace("%s", fn); + op = "unarchive"; + } - if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { - return; - } + str = str.replace("%d", rows.length); + str = str.replace("%s", fn); - const query = {op: "rpc", method: op, ids: rows.toString()}; + if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { + return; + } - xhrPost("backend.php", query, (transport) => { - App.handleRpcJson(transport); - Feeds.reloadCurrent(); - }); - }, - catchupSelection: function () { - const rows = Headlines.getSelected(); + const query = {op: "rpc", method: op, ids: rows.toString()}; - if (rows.length == 0) { - alert(__("No articles selected.")); - return; - } + xhrPost("backend.php", query, (transport) => { + App.handleRpcJson(transport); + Feeds.reloadCurrent(); + }); + }, + catchupSelection: function () { + const rows = Headlines.getSelected(); + + if (rows.length == 0) { + alert(__("No articles selected.")); + return; + } - const fn = Feeds.getName(Feeds.getActive(), Feeds.activeIsCat()); + const fn = Feeds.getName(Feeds.getActive(), Feeds.activeIsCat()); - let str = ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows.length); + let str = ngettext("Mark %d selected article in %s as read?", "Mark %d selected articles in %s as read?", rows.length); - str = str.replace("%d", rows.length); - str = str.replace("%s", fn); + str = str.replace("%d", rows.length); + str = str.replace("%s", fn); - if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { - return; - } + if (App.getInitParam("confirm_feed_catchup") && !confirm(str)) { + return; + } - Headlines.selectionToggleUnread({ids: rows, cmode: 0}); - }, - catchupRelativeTo: function (below, id) { + Headlines.selectionToggleUnread({ids: rows, cmode: 0}); + }, + catchupRelativeTo: function (below, id) { - if (!id) id = Article.getActive(); + if (!id) id = Article.getActive(); - if (!id) { - alert(__("No article is selected.")); - return; - } + if (!id) { + alert(__("No article is selected.")); + return; + } - const visible_ids = this.getLoaded(); + const visible_ids = this.getLoaded(); - const ids_to_mark = []; + const ids_to_mark = []; - if (!below) { - for (let i = 0; i < visible_ids.length; i++) { - if (visible_ids[i] != id) { - const e = $("RROW-" + visible_ids[i]); + if (!below) { + for (let i = 0; i < visible_ids.length; i++) { + if (visible_ids[i] != id) { + const e = $("RROW-" + visible_ids[i]); - if (e && e.hasClassName("Unread")) { - ids_to_mark.push(visible_ids[i]); - } - } else { - break; + if (e && e.hasClassName("Unread")) { + ids_to_mark.push(visible_ids[i]); } + } else { + break; } - } else { - for (let i = visible_ids.length - 1; i >= 0; i--) { - if (visible_ids[i] != id) { - const e = $("RROW-" + visible_ids[i]); + } + } else { + for (let i = visible_ids.length - 1; i >= 0; i--) { + if (visible_ids[i] != id) { + const e = $("RROW-" + visible_ids[i]); - if (e && e.hasClassName("Unread")) { - ids_to_mark.push(visible_ids[i]); - } - } else { - break; + if (e && e.hasClassName("Unread")) { + ids_to_mark.push(visible_ids[i]); } + } else { + break; } } + } - if (ids_to_mark.length == 0) { - alert(__("No articles found to mark")); - } else { - const msg = ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark.length).replace("%d", ids_to_mark.length); + if (ids_to_mark.length == 0) { + alert(__("No articles found to mark")); + } else { + const msg = ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark.length).replace("%d", ids_to_mark.length); - if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) { + if (App.getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) { - for (var i = 0; i < ids_to_mark.length; i++) { - var e = $("RROW-" + ids_to_mark[i]); - e.removeClassName("Unread"); - } + for (let i = 0; i < ids_to_mark.length; i++) { + const e = $("RROW-" + ids_to_mark[i]); + e.removeClassName("Unread"); } } - }, - onLabelsUpdated: function (transport) { - const data = JSON.parse(transport.responseText); - - if (data) { - data['info-for-headlines'].each(function (elem) { - $$(".HLLCTR-" + elem.id).each(function (ctr) { - ctr.innerHTML = elem.labels; - }); + } + }, + onLabelsUpdated: function (transport) { + const data = JSON.parse(transport.responseText); + + if (data) { + data['info-for-headlines'].each(function (elem) { + $$(".HLLCTR-" + elem.id).each(function (ctr) { + ctr.innerHTML = elem.labels; }); + }); + } + }, + onActionChanged: function (elem) { + // eslint-disable-next-line no-eval + eval(elem.value); + elem.attr('value', 'false'); + }, + scrollToArticleId: function (id) { + const container = $("headlines-frame"); + const row = $("RROW-" + id); + + if (!container || !row) return; + + const viewport = container.offsetHeight; + + const rel_offset_top = row.offsetTop - container.scrollTop; + const rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop; + + //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom); + //console.log("Vport: " + viewport); + + if (rel_offset_top <= 0 || rel_offset_top > viewport) { + container.scrollTop = row.offsetTop; + } else if (rel_offset_bottom > viewport) { + container.scrollTop = row.offsetTop + row.offsetHeight - viewport; + } + }, + headlinesMenuCommon: function (menu) { + + menu.addChild(new dijit.MenuItem({ + label: __("Open original article"), + onClick: function (/* event */) { + Article.openInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id")); } - }, - onActionChanged: function (elem) { - eval(elem.value); - elem.attr('value', 'false'); - }, - correctHeadlinesOffset: function (id) { - const container = $("headlines-frame"); - const row = $("RROW-" + id); + })); - if (!container || !row) return; + menu.addChild(new dijit.MenuItem({ + label: __("Display article URL"), + onClick: function (/* event */) { + Article.displayUrl(this.getParent().currentTarget.getAttribute("data-article-id")); + } + })); - const viewport = container.offsetHeight; + menu.addChild(new dijit.MenuSeparator()); - const rel_offset_top = row.offsetTop - container.scrollTop; - const rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop; + menu.addChild(new dijit.MenuItem({ + label: __("Toggle unread"), + onClick: function () { - //console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom); - //console.log("Vport: " + viewport); + let ids = Headlines.getSelected(); + // cast to string + const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; + ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; - if (rel_offset_top <= 0 || rel_offset_top > viewport) { - container.scrollTop = row.offsetTop; - } else if (rel_offset_bottom > viewport) { - container.scrollTop = row.offsetTop + row.offsetHeight - viewport; + Headlines.selectionToggleUnread({ids: ids, no_error: 1}); } - }, - initFloatingMenu: function () { - if (!dijit.byId("floatingMenu")) { + })); - const menu = new dijit.Menu({ - id: "floatingMenu", - selector: ".hlMenuAttach", - targetNodeIds: ["floatingTitle"] - }); - - this.headlinesMenuCommon(menu); + menu.addChild(new dijit.MenuItem({ + label: __("Toggle starred"), + onClick: function () { + let ids = Headlines.getSelected(); + // cast to string + const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; + ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; - menu.startup(); + Headlines.selectionToggleMarked(ids); } - }, - headlinesMenuCommon: function (menu) { + })); - menu.addChild(new dijit.MenuItem({ - label: __("Open original article"), - onClick: function (event) { - Article.openInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id")); - } - })); - - menu.addChild(new dijit.MenuItem({ - label: __("Display article URL"), - onClick: function (event) { - Article.displayUrl(this.getParent().currentTarget.getAttribute("data-article-id")); - } - })); - - menu.addChild(new dijit.MenuSeparator()); + menu.addChild(new dijit.MenuItem({ + label: __("Toggle published"), + onClick: function () { + let ids = Headlines.getSelected(); + // cast to string + const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; + ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; - menu.addChild(new dijit.MenuItem({ - label: __("Toggle unread"), - onClick: function () { + Headlines.selectionTogglePublished(ids); + } + })); - let ids = Headlines.getSelected(); - // cast to string - const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; - ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; + menu.addChild(new dijit.MenuSeparator()); - Headlines.selectionToggleUnread({ids: ids, no_error: 1}); - } - })); + menu.addChild(new dijit.MenuItem({ + label: __("Mark above as read"), + onClick: function () { + Headlines.catchupRelativeTo(0, this.getParent().currentTarget.getAttribute("data-article-id")); + } + })); - menu.addChild(new dijit.MenuItem({ - label: __("Toggle starred"), - onClick: function () { - let ids = Headlines.getSelected(); - // cast to string - const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; - ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; + menu.addChild(new dijit.MenuItem({ + label: __("Mark below as read"), + onClick: function () { + Headlines.catchupRelativeTo(1, this.getParent().currentTarget.getAttribute("data-article-id")); + } + })); - Headlines.selectionToggleMarked(ids); - } - })); - menu.addChild(new dijit.MenuItem({ - label: __("Toggle published"), - onClick: function () { - let ids = Headlines.getSelected(); - // cast to string - const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; - ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; + const labels = App.getInitParam("labels"); - Headlines.selectionTogglePublished(ids); - } - })); + if (labels && labels.length) { menu.addChild(new dijit.MenuSeparator()); - menu.addChild(new dijit.MenuItem({ - label: __("Mark above as read"), - onClick: function () { - Headlines.catchupRelativeTo(0, this.getParent().currentTarget.getAttribute("data-article-id")); - } - })); + const labelAddMenu = new dijit.Menu({ownerMenu: menu}); + const labelDelMenu = new dijit.Menu({ownerMenu: menu}); - menu.addChild(new dijit.MenuItem({ - label: __("Mark below as read"), - onClick: function () { - Headlines.catchupRelativeTo(1, this.getParent().currentTarget.getAttribute("data-article-id")); - } - })); + labels.each(function (label) { + const bare_id = label.id; + const name = label.caption; + labelAddMenu.addChild(new dijit.MenuItem({ + label: name, + labelId: bare_id, + onClick: function () { - const labels = App.getInitParam("labels"); - - if (labels && labels.length) { - - menu.addChild(new dijit.MenuSeparator()); - - const labelAddMenu = new dijit.Menu({ownerMenu: menu}); - const labelDelMenu = new dijit.Menu({ownerMenu: menu}); - - labels.each(function (label) { - const bare_id = label.id; - const name = label.caption; - - labelAddMenu.addChild(new dijit.MenuItem({ - label: name, - labelId: bare_id, - onClick: function () { - - let ids = Headlines.getSelected(); - // cast to string - const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + ""; - - ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; - - Headlines.selectionAssignLabel(this.labelId, ids); - } - })); + let ids = Headlines.getSelected(); + // cast to string + const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + ""; - labelDelMenu.addChild(new dijit.MenuItem({ - label: name, - labelId: bare_id, - onClick: function () { - let ids = Headlines.getSelected(); - // cast to string - const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + ""; + ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; - ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; + Headlines.selectionAssignLabel(this.labelId, ids); + } + })); - Headlines.selectionRemoveLabel(this.labelId, ids); - } - })); + labelDelMenu.addChild(new dijit.MenuItem({ + label: name, + labelId: bare_id, + onClick: function () { + let ids = Headlines.getSelected(); + // cast to string + const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + ""; - }); + ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; - menu.addChild(new dijit.PopupMenuItem({ - label: __("Assign label"), - popup: labelAddMenu - })); - - menu.addChild(new dijit.PopupMenuItem({ - label: __("Remove label"), - popup: labelDelMenu + Headlines.selectionRemoveLabel(this.labelId, ids); + } })); - } - }, - scrollByPages: function (offset, event) { - const elem = $("headlines-frame"); - - if (event && event.repeat) { - elem.addClassName("forbid-smooth-scroll"); - window.clearTimeout(this._scroll_reset_timeout); + }); - this._scroll_reset_timeout = window.setTimeout(() => { - if (elem) elem.removeClassName("forbid-smooth-scroll"); - }, 250) - } else { - elem.removeClassName("forbid-smooth-scroll"); - } + menu.addChild(new dijit.PopupMenuItem({ + label: __("Assign label"), + popup: labelAddMenu + })); - elem.scrollTop += elem.offsetHeight * offset * 0.99; - }, - initHeadlinesMenu: function () { - if (!dijit.byId("headlinesMenu")) { + menu.addChild(new dijit.PopupMenuItem({ + label: __("Remove label"), + popup: labelDelMenu + })); - const menu = new dijit.Menu({ - id: "headlinesMenu", - targetNodeIds: ["headlines-frame"], - selector: ".hlMenuAttach" - }); + } + }, + scrollByPages: function (page_offset) { + App.Scrollable.scrollByPages($("headlines-frame"), page_offset); + }, + scroll: function (offset) { + App.Scrollable.scroll($("headlines-frame"), offset); + }, + initHeadlinesMenu: function () { + if (!dijit.byId("headlinesMenu")) { + + const menu = new dijit.Menu({ + id: "headlinesMenu", + targetNodeIds: ["headlines-frame"], + selector: ".hlMenuAttach" + }); - this.headlinesMenuCommon(menu); + this.headlinesMenuCommon(menu); - menu.startup(); - } + menu.startup(); + } - /* vgroup feed title menu */ + /* vgroup feed title menu */ - if (!dijit.byId("headlinesFeedTitleMenu")) { + if (!dijit.byId("headlinesFeedTitleMenu")) { - const menu = new dijit.Menu({ - id: "headlinesFeedTitleMenu", - targetNodeIds: ["headlines-frame"], - selector: "div.cdmFeedTitle" - }); + const menu = new dijit.Menu({ + id: "headlinesFeedTitleMenu", + targetNodeIds: ["headlines-frame"], + selector: "div.cdmFeedTitle" + }); - menu.addChild(new dijit.MenuItem({ - label: __("Select articles in group"), - onClick: function (event) { - Headlines.select("all", - "#headlines-frame > div[id*=RROW]" + - "[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']"); + menu.addChild(new dijit.MenuItem({ + label: __("Select articles in group"), + onClick: function (/* event */) { + Headlines.select("all", + "#headlines-frame > div[id*=RROW]" + + "[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']"); - } - })); + } + })); - menu.addChild(new dijit.MenuItem({ - label: __("Mark group as read"), - onClick: function () { - Headlines.select("none"); - Headlines.select("all", - "#headlines-frame > div[id*=RROW]" + - "[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']"); + menu.addChild(new dijit.MenuItem({ + label: __("Mark group as read"), + onClick: function () { + Headlines.select("none"); + Headlines.select("all", + "#headlines-frame > div[id*=RROW]" + + "[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']"); - Headlines.catchupSelection(); - } - })); + Headlines.catchupSelection(); + } + })); - menu.addChild(new dijit.MenuItem({ - label: __("Mark feed as read"), - onClick: function () { - Feeds.catchupFeedInGroup(this.getParent().currentTarget.getAttribute("data-feed-id")); - } - })); + menu.addChild(new dijit.MenuItem({ + label: __("Mark feed as read"), + onClick: function () { + Feeds.catchupFeedInGroup(this.getParent().currentTarget.getAttribute("data-feed-id")); + } + })); - menu.addChild(new dijit.MenuItem({ - label: __("Edit feed"), - onClick: function () { - CommonDialogs.editFeed(this.getParent().currentTarget.getAttribute("data-feed-id")); - } - })); + menu.addChild(new dijit.MenuItem({ + label: __("Edit feed"), + onClick: function () { + CommonDialogs.editFeed(this.getParent().currentTarget.getAttribute("data-feed-id")); + } + })); - menu.startup(); - } + menu.startup(); } } - - return Headlines; -}); +} diff --git a/js/PluginHost.js b/js/PluginHost.js index 71596ad31..caee79d58 100644 --- a/js/PluginHost.js +++ b/js/PluginHost.js @@ -1,6 +1,8 @@ // based on http://www.velvetcache.org/2010/08/19/a-simple-javascript-hooks-system -PluginHost = { + +/* exported PluginHost */ +const PluginHost = { HOOK_ARTICLE_RENDERED: 1, HOOK_ARTICLE_RENDERED_CDM: 2, HOOK_ARTICLE_SET_ACTIVE: 3, @@ -31,7 +33,7 @@ PluginHost = { } }, unregister: function (name, callback) { - for (var i = 0; i < this.hooks[name].length; i++) + for (let i = 0; i < this.hooks[name].length; i++) if (this.hooks[name][i] == callback) this.hooks[name].splice(i, 1); } diff --git a/js/PrefFeedStore.js b/js/PrefFeedStore.js index 152ebba44..ee983af54 100644 --- a/js/PrefFeedStore.js +++ b/js/PrefFeedStore.js @@ -1,9 +1,10 @@ +/* global define, dojo */ + define(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) { return declare("fox.PrefFeedStore", dojo.data.ItemFileWriteStore, { - _saveEverything: function(saveCompleteCallback, saveFailedCallback, - newFileContentString) { + _saveEverything: function(saveCompleteCallback, saveFailedCallback, newFileContentString) { dojo.xhrPost({ url: "backend.php", diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index 3a5e33b2b..4ea0cdac1 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -1,4 +1,5 @@ -/* global lib,dijit */ +/* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhrPost */ + define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { return declare("fox.PrefFeedTree", lib.CheckBoxTree, { diff --git a/js/PrefFilterStore.js b/js/PrefFilterStore.js index cccec6479..a41d84129 100644 --- a/js/PrefFilterStore.js +++ b/js/PrefFilterStore.js @@ -1,9 +1,10 @@ +/* global define, dojo */ + define(["dojo/_base/declare", "dojo/data/ItemFileWriteStore"], function (declare) { return declare("fox.PrefFilterStore", dojo.data.ItemFileWriteStore, { - _saveEverything: function (saveCompleteCallback, saveFailedCallback, - newFileContentString) { + _saveEverything: function (saveCompleteCallback, saveFailedCallback, newFileContentString) { dojo.xhrPost({ url: "backend.php", diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index a7c7464fb..0e8e52658 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -1,4 +1,5 @@ -/* global dijit,lib */ +/* global __, $$, define, lib, dijit, dojo, xhrPost, Notify, Filters, Lists */ + define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { return declare("fox.PrefFilterTree", lib.CheckBoxTree, { @@ -149,9 +150,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio style: "width: 600px", test: function () { - const query = "backend.php?" + dojo.formToQuery("filter_edit_form") + "&savemode=test"; - - Filters.editFilterTest(query); + Filters.editFilterTest(dojo.formToObject("filter_edit_form")); }, selectRules: function (select) { Lists.select("filterDlg_Matches", select); @@ -238,9 +237,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio return false; }, - - - }); }); diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 4b908204c..12710bc6a 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -1,274 +1,273 @@ -define(["dojo/_base/declare"], function (declare) { - Helpers = { - AppPasswords: { - getSelected: function() { - return Tables.getSelected("app-password-list"); - }, - updateContent: function(data) { - $("app_passwords_holder").innerHTML = data; - dojo.parser.parse("app_passwords_holder"); - }, - removeSelected: function() { - const rows = this.getSelected(); +'use strict'; - if (rows.length == 0) { - alert("No passwords selected."); - } else { - if (confirm(__("Remove selected app passwords?"))) { +/* global __, dijit, dojo, Tables, xhrPost, Notify, xhrJson */ - xhrPost("backend.php", {op: "pref-prefs", method: "deleteAppPassword", ids: rows.toString()}, (transport) => { - this.updateContent(transport.responseText); - Notify.close(); - }); +const Helpers = { + AppPasswords: { + getSelected: function() { + return Tables.getSelected("app-password-list"); + }, + updateContent: function(data) { + $("app_passwords_holder").innerHTML = data; + dojo.parser.parse("app_passwords_holder"); + }, + removeSelected: function() { + const rows = this.getSelected(); - Notify.progress("Loading, please wait..."); - } - } - }, - generate: function() { - const title = prompt("Password description:") + if (rows.length == 0) { + alert("No passwords selected."); + } else if (confirm(__("Remove selected app passwords?"))) { - if (title) { - xhrPost("backend.php", {op: "pref-prefs", method: "generateAppPassword", title: title}, (transport) => { - this.updateContent(transport.responseText); - Notify.close(); - }); + xhrPost("backend.php", {op: "pref-prefs", method: "deleteAppPassword", ids: rows.toString()}, (transport) => { + this.updateContent(transport.responseText); + Notify.close(); + }); - Notify.progress("Loading, please wait..."); - } - }, + Notify.progress("Loading, please wait..."); + } }, - clearFeedAccessKeys: function() { - if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) { - Notify.progress("Clearing URLs..."); + generate: function() { + const title = prompt("Password description:") - xhrPost("backend.php", {op: "pref-feeds", method: "clearKeys"}, () => { - Notify.info("Generated URLs cleared."); + if (title) { + xhrPost("backend.php", {op: "pref-prefs", method: "generateAppPassword", title: title}, (transport) => { + this.updateContent(transport.responseText); + Notify.close(); }); - } - - return false; - }, - updateEventLog: function() { - xhrPost("backend.php", { op: "pref-system" }, (transport) => { - dijit.byId('systemConfigTab').attr('content', transport.responseText); - Notify.close(); - }); - }, - clearEventLog: function() { - if (confirm(__("Clear event log?"))) { Notify.progress("Loading, please wait..."); - - xhrPost("backend.php", {op: "pref-system", method: "clearLog"}, () => { - this.updateEventLog(); - }); } }, - editProfiles: function() { - - if (dijit.byId("profileEditDlg")) - dijit.byId("profileEditDlg").destroyRecursive(); + }, + clearFeedAccessKeys: function() { + if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) { + Notify.progress("Clearing URLs..."); - const query = "backend.php?op=pref-prefs&method=editPrefProfiles"; + xhrPost("backend.php", {op: "pref-feeds", method: "clearKeys"}, () => { + Notify.info("Generated URLs cleared."); + }); + } - // noinspection JSUnusedGlobalSymbols - const dialog = new dijit.Dialog({ - id: "profileEditDlg", - title: __("Settings Profiles"), - style: "width: 600px", - getSelectedProfiles: function () { - return Tables.getSelected("pref-profiles-list"); - }, - removeSelected: function () { - const sel_rows = this.getSelectedProfiles(); - - if (sel_rows.length > 0) { - if (confirm(__("Remove selected profiles? Active and default profiles will not be removed."))) { - Notify.progress("Removing selected profiles...", true); - - const query = { - op: "rpc", method: "remprofiles", - ids: sel_rows.toString() - }; - - xhrPost("backend.php", query, () => { - Notify.close(); - Helpers.editProfiles(); - }); - } + return false; + }, + updateEventLog: function() { + xhrPost("backend.php", { op: "pref-system" }, (transport) => { + dijit.byId('systemConfigTab').attr('content', transport.responseText); + Notify.close(); + }); + }, + clearEventLog: function() { + if (confirm(__("Clear event log?"))) { + + Notify.progress("Loading, please wait..."); + + xhrPost("backend.php", {op: "pref-system", method: "clearLog"}, () => { + this.updateEventLog(); + }); + } + }, + editProfiles: function() { - } else { - alert(__("No profiles selected.")); - } - }, - activateProfile: function () { - const sel_rows = this.getSelectedProfiles(); + if (dijit.byId("profileEditDlg")) + dijit.byId("profileEditDlg").destroyRecursive(); - if (sel_rows.length == 1) { - if (confirm(__("Activate selected profile?"))) { - Notify.progress("Loading, please wait..."); + const query = "backend.php?op=pref-prefs&method=editPrefProfiles"; - xhrPost("backend.php", {op: "rpc", method: "setprofile", id: sel_rows.toString()}, () => { - window.location.reload(); - }); - } + // noinspection JSUnusedGlobalSymbols + const dialog = new dijit.Dialog({ + id: "profileEditDlg", + title: __("Settings Profiles"), + style: "width: 600px", + getSelectedProfiles: function () { + return Tables.getSelected("pref-profiles-list"); + }, + removeSelected: function () { + const sel_rows = this.getSelectedProfiles(); - } else { - alert(__("Please choose a profile to activate.")); - } - }, - addProfile: function () { - if (this.validate()) { - Notify.progress("Creating profile...", true); + if (sel_rows.length > 0) { + if (confirm(__("Remove selected profiles? Active and default profiles will not be removed."))) { + Notify.progress("Removing selected profiles...", true); - const query = {op: "rpc", method: "addprofile", title: dialog.attr('value').newprofile}; + const query = { + op: "rpc", method: "remprofiles", + ids: sel_rows.toString() + }; xhrPost("backend.php", query, () => { Notify.close(); Helpers.editProfiles(); }); - - } - }, - execute: function () { - if (this.validate()) { } - }, - href: query - }); - dialog.show(); - }, - customizeCSS: function() { - const query = "backend.php?op=pref-prefs&method=customizeCSS"; + } else { + alert(__("No profiles selected.")); + } + }, + activateProfile: function () { + const sel_rows = this.getSelectedProfiles(); - if (dijit.byId("cssEditDlg")) - dijit.byId("cssEditDlg").destroyRecursive(); + if (sel_rows.length == 1) { + if (confirm(__("Activate selected profile?"))) { + Notify.progress("Loading, please wait..."); - const dialog = new dijit.Dialog({ - id: "cssEditDlg", - title: __("Customize stylesheet"), - style: "width: 600px", - apply: function() { - xhrPost("backend.php", this.attr('value'), () => { - new Effect.Appear("css_edit_apply_msg"); - $("user_css_style").innerText = this.attr('value'); - }); - }, - execute: function () { - Notify.progress('Saving data...', true); + xhrPost("backend.php", {op: "rpc", method: "setprofile", id: sel_rows.toString()}, () => { + window.location.reload(); + }); + } - xhrPost("backend.php", this.attr('value'), () => { - window.location.reload(); - }); + } else { + alert(__("Please choose a profile to activate.")); + } + }, + addProfile: function () { + if (this.validate()) { + Notify.progress("Creating profile...", true); - }, - href: query - }); + const query = {op: "rpc", method: "addprofile", title: dialog.attr('value').newprofile}; - dialog.show(); - }, - confirmReset: function() { - if (confirm(__("Reset to defaults?"))) { - xhrPost("backend.php", {op: "pref-prefs", method: "resetconfig"}, (transport) => { - Helpers.refresh(); - Notify.info(transport.responseText); + xhrPost("backend.php", query, () => { + Notify.close(); + Helpers.editProfiles(); + }); + + } + }, + execute: function () { + if (this.validate()) { + // + } + }, + href: query + }); + + dialog.show(); + }, + customizeCSS: function() { + const query = "backend.php?op=pref-prefs&method=customizeCSS"; + + if (dijit.byId("cssEditDlg")) + dijit.byId("cssEditDlg").destroyRecursive(); + + const dialog = new dijit.Dialog({ + id: "cssEditDlg", + title: __("Customize stylesheet"), + style: "width: 600px", + apply: function() { + xhrPost("backend.php", this.attr('value'), () => { + new Effect.Appear("css_edit_apply_msg"); + $("user_css_style").innerText = this.attr('value'); }); - } - }, - clearPluginData: function(name) { - if (confirm(__("Clear stored data for this plugin?"))) { - Notify.progress("Loading, please wait..."); + }, + execute: function () { + Notify.progress('Saving data...', true); - xhrPost("backend.php", {op: "pref-prefs", method: "clearplugindata", name: name}, () => { - Helpers.refresh(); + xhrPost("backend.php", this.attr('value'), () => { + window.location.reload(); }); - } - }, - refresh: function() { - xhrPost("backend.php", { op: "pref-prefs" }, (transport) => { - dijit.byId('genConfigTab').attr('content', transport.responseText); - Notify.close(); + + }, + href: query + }); + + dialog.show(); + }, + confirmReset: function() { + if (confirm(__("Reset to defaults?"))) { + xhrPost("backend.php", {op: "pref-prefs", method: "resetconfig"}, (transport) => { + Helpers.refresh(); + Notify.info(transport.responseText); }); - }, - OPML: { - import: function() { - const opml_file = $("opml_file"); + } + }, + clearPluginData: function(name) { + if (confirm(__("Clear stored data for this plugin?"))) { + Notify.progress("Loading, please wait..."); - if (opml_file.value.length == 0) { - alert(__("Please choose an OPML file first.")); - return false; - } else { - Notify.progress("Importing, please wait...", true); + xhrPost("backend.php", {op: "pref-prefs", method: "clearplugindata", name: name}, () => { + Helpers.refresh(); + }); + } + }, + refresh: function() { + xhrPost("backend.php", { op: "pref-prefs" }, (transport) => { + dijit.byId('genConfigTab').attr('content', transport.responseText); + Notify.close(); + }); + }, + OPML: { + import: function() { + const opml_file = $("opml_file"); + + if (opml_file.value.length == 0) { + alert(__("Please choose an OPML file first.")); + return false; + } else { + Notify.progress("Importing, please wait...", true); - Element.show("upload_iframe"); + Element.show("upload_iframe"); - return true; - } - }, - onImportComplete: function(iframe) { - if (!iframe.contentDocument.body.innerHTML) return false; + return true; + } + }, + onImportComplete: function(iframe) { + if (!iframe.contentDocument.body.innerHTML) return false; - Element.show(iframe); + Element.show(iframe); - Notify.close(); + Notify.close(); - if (dijit.byId('opmlImportDlg')) - dijit.byId('opmlImportDlg').destroyRecursive(); + if (dijit.byId('opmlImportDlg')) + dijit.byId('opmlImportDlg').destroyRecursive(); - const content = iframe.contentDocument.body.innerHTML; + const content = iframe.contentDocument.body.innerHTML; - const dialog = new dijit.Dialog({ - id: "opmlImportDlg", - title: __("OPML Import"), - style: "width: 600px", - onCancel: function () { - window.location.reload(); - }, - execute: function () { - window.location.reload(); - }, - content: content - }); + const dialog = new dijit.Dialog({ + id: "opmlImportDlg", + title: __("OPML Import"), + style: "width: 600px", + onCancel: function () { + window.location.reload(); + }, + execute: function () { + window.location.reload(); + }, + content: content + }); - dojo.connect(dialog, "onShow", function () { - Element.hide(iframe); - }); + dojo.connect(dialog, "onShow", function () { + Element.hide(iframe); + }); - dialog.show(); - }, - export: function() { - console.log("export"); - window.open("backend.php?op=opml&method=export&" + dojo.formToQuery("opmlExportForm")); - }, - changeKey: function() { - if (confirm(__("Replace current OPML publishing address with a new one?"))) { - Notify.progress("Trying to change address...", true); + dialog.show(); + }, + export: function() { + console.log("export"); + window.open("backend.php?op=opml&method=export&" + dojo.formToQuery("opmlExportForm")); + }, + changeKey: function() { + if (confirm(__("Replace current OPML publishing address with a new one?"))) { + Notify.progress("Trying to change address...", true); - xhrJson("backend.php", {op: "pref-feeds", method: "regenOPMLKey"}, (reply) => { - if (reply) { - const new_link = reply.link; - const e = $('pub_opml_url'); + xhrJson("backend.php", {op: "pref-feeds", method: "regenOPMLKey"}, (reply) => { + if (reply) { + const new_link = reply.link; + const e = $('pub_opml_url'); - if (new_link) { - e.href = new_link; - e.innerHTML = new_link; + if (new_link) { + e.href = new_link; + e.innerHTML = new_link; - new Effect.Highlight(e); + new Effect.Highlight(e); - Notify.close(); + Notify.close(); - } else { - Notify.error("Could not change feed URL."); - } + } else { + Notify.error("Could not change feed URL."); } - }); - } - return false; - }, - } - }; - - return Helpers; -}); + } + }); + } + return false; + }, + } +}; diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index 988e313b0..b14474feb 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -1,4 +1,5 @@ -/* global lib,dijit */ +/* global __, define, lib, dijit, dojo, xhrPost, Notify */ + define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) { return declare("fox.PrefLabelTree", lib.CheckBoxTree, { diff --git a/js/PrefUsers.js b/js/PrefUsers.js index 55dc43dfa..8136e9c65 100644 --- a/js/PrefUsers.js +++ b/js/PrefUsers.js @@ -1,122 +1,120 @@ 'use strict' -/* global __, ngettext */ -define(["dojo/_base/declare"], function (declare) { - Users = { - reload: function(sort) { - const user_search = $("user_search"); - const search = user_search ? user_search.value : ""; - - xhrPost("backend.php", { op: "pref-users", sort: sort, search: search }, (transport) => { - dijit.byId('userConfigTab').attr('content', transport.responseText); - Notify.close(); - }); - }, - add: function() { - const login = prompt(__("Please enter username:"), ""); - if (login) { - Notify.progress("Adding user..."); +/* global __ */ +/* global xhrPost, dojo, dijit, Notify, Tables */ - xhrPost("backend.php", {op: "pref-users", method: "add", login: login}, (transport) => { - alert(transport.responseText); - Users.reload(); - }); +const Users = { + reload: function(sort) { + const user_search = $("user_search"); + const search = user_search ? user_search.value : ""; - } - }, - edit: function(id) { - const query = "backend.php?op=pref-users&method=edit&id=" + - encodeURIComponent(id); - - if (dijit.byId("userEditDlg")) - dijit.byId("userEditDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ - id: "userEditDlg", - title: __("User Editor"), - style: "width: 600px", - execute: function () { - if (this.validate()) { - Notify.progress("Saving data...", true); - - xhrPost("backend.php", dojo.formToObject("user_edit_form"), (transport) => { - dialog.hide(); - Users.reload(); - }); - } - }, - href: query - }); - - dialog.show(); - }, - resetSelected: function() { - const rows = this.getSelection(); + xhrPost("backend.php", { op: "pref-users", sort: sort, search: search }, (transport) => { + dijit.byId('userConfigTab').attr('content', transport.responseText); + Notify.close(); + }); + }, + add: function() { + const login = prompt(__("Please enter username:"), ""); - if (rows.length == 0) { - alert(__("No users selected.")); - return; - } + if (login) { + Notify.progress("Adding user..."); - if (rows.length > 1) { - alert(__("Please select one user.")); - return; - } + xhrPost("backend.php", {op: "pref-users", method: "add", login: login}, (transport) => { + alert(transport.responseText); + Users.reload(); + }); - if (confirm(__("Reset password of selected user?"))) { - Notify.progress("Resetting password for selected user..."); + } + }, + edit: function(id) { + const query = "backend.php?op=pref-users&method=edit&id=" + + encodeURIComponent(id); + + if (dijit.byId("userEditDlg")) + dijit.byId("userEditDlg").destroyRecursive(); + + const dialog = new dijit.Dialog({ + id: "userEditDlg", + title: __("User Editor"), + style: "width: 600px", + execute: function () { + if (this.validate()) { + Notify.progress("Saving data...", true); + + xhrPost("backend.php", dojo.formToObject("user_edit_form"), (/* transport */) => { + dialog.hide(); + Users.reload(); + }); + } + }, + href: query + }); + + dialog.show(); + }, + resetSelected: function() { + const rows = this.getSelection(); + + if (rows.length == 0) { + alert(__("No users selected.")); + return; + } - const id = rows[0]; + if (rows.length > 1) { + alert(__("Please select one user.")); + return; + } - xhrPost("backend.php", {op: "pref-users", method: "resetPass", id: id}, (transport) => { - Notify.close(); - Notify.info(transport.responseText, true); - }); + if (confirm(__("Reset password of selected user?"))) { + Notify.progress("Resetting password for selected user..."); - } - }, - removeSelected: function() { - const sel_rows = this.getSelection(); + const id = rows[0]; - if (sel_rows.length > 0) { - if (confirm(__("Remove selected users? Neither default admin nor your account will be removed."))) { - Notify.progress("Removing selected users..."); + xhrPost("backend.php", {op: "pref-users", method: "resetPass", id: id}, (transport) => { + Notify.close(); + Notify.info(transport.responseText, true); + }); - const query = { - op: "pref-users", method: "remove", - ids: sel_rows.toString() - }; + } + }, + removeSelected: function() { + const sel_rows = this.getSelection(); - xhrPost("backend.php", query, () => { - this.reload(); - }); - } + if (sel_rows.length > 0) { + if (confirm(__("Remove selected users? Neither default admin nor your account will be removed."))) { + Notify.progress("Removing selected users..."); - } else { - alert(__("No users selected.")); - } - }, - editSelected: function() { - const rows = this.getSelection(); + const query = { + op: "pref-users", method: "remove", + ids: sel_rows.toString() + }; - if (rows.length == 0) { - alert(__("No users selected.")); - return; + xhrPost("backend.php", query, () => { + this.reload(); + }); } - if (rows.length > 1) { - alert(__("Please select one user.")); - return; - } + } else { + alert(__("No users selected.")); + } + }, + editSelected: function() { + const rows = this.getSelection(); - this.edit(rows[0]); - }, - getSelection :function() { - return Tables.getSelected("prefUserList"); + if (rows.length == 0) { + alert(__("No users selected.")); + return; } - } - return Users; -}); + if (rows.length > 1) { + alert(__("Please select one user.")); + return; + } + this.edit(rows[0]); + }, + getSelection :function() { + return Tables.getSelected("prefUserList"); + } +} diff --git a/js/Toolbar.js b/js/Toolbar.js index 6d2c20058..d4993e713 100755 --- a/js/Toolbar.js +++ b/js/Toolbar.js @@ -1,10 +1,11 @@ -/* global dijit */ +/* global dijit, define */ + define(["dojo/_base/declare", "dijit/Toolbar"], function (declare) { return declare("fox.Toolbar", dijit.Toolbar, { - _onContainerKeydown: function(/* Event */ e) { + _onContainerKeydown: function(/* Event */ /* e */) { return; // Stop dijit.Toolbar from interpreting keystrokes }, - _onContainerKeypress: function(/* Event */ e) { + _onContainerKeypress: function(/* Event */ /* e */) { return; // Stop dijit.Toolbar from interpreting keystrokes }, focus: function() { diff --git a/js/common.js b/js/common.js index 69b528a1c..c17e8bc45 100755 --- a/js/common.js +++ b/js/common.js @@ -1,21 +1,19 @@ -'use strict' -/* global dijit, __ */ +'use strict'; -let LABEL_BASE_INDEX = -1024; /* not const because it's assigned at least once (by backend) */ -let loading_progress = 0; +/* global dijit, __, App, Ajax */ /* error reporting shim */ - // TODO: deprecated; remove -function exception_error(e, e_compat, filename, lineno, colno) { +/* function exception_error(e, e_compat, filename, lineno, colno) { if (typeof e == "string") e = e_compat; App.Error.report(e, {filename: filename, lineno: lineno, colno: colno}); -} +} */ /* xhr shorthand helpers */ +/* exported xhrPost */ function xhrPost(url, params, complete) { console.log("xhrPost:", params); @@ -31,6 +29,7 @@ function xhrPost(url, params, complete) { }); } +/* exported xhrJson */ function xhrJson(url, params, complete) { return new Promise((resolve, reject) => { return xhrPost(url, params).then((reply) => { @@ -58,6 +57,7 @@ Array.prototype.remove = function(s) { /* common helpers not worthy of separate Dojo modules */ +/* exported Lists */ const Lists = { onRowChecked: function(elem) { const checked = elem.domNode ? elem.attr("checked") : elem.checked; @@ -87,7 +87,7 @@ const Lists = { }, }; -// noinspection JSUnusedGlobalSymbols +/* exported Tables */ const Tables = { onRowChecked: function(elem) { // account for dojo checkboxes @@ -133,6 +133,7 @@ const Tables = { } }; +/* exported Cookie */ const Cookie = { set: function (name, value, lifetime) { const d = new Date(); @@ -152,12 +153,12 @@ const Cookie = { }, delete: function(name) { const expires = "expires=Thu, 01-Jan-1970 00:00:01 GMT"; - document.cookie = name + "=" + "" + "; " + expires; + document.cookie = name + "=; " + expires; } }; /* runtime notifications */ - +/* exported Notify */ const Notify = { KIND_GENERIC: 0, KIND_INFO: 1, @@ -237,30 +238,8 @@ const Notify = { } }; -// noinspection JSUnusedGlobalSymbols -function displayIfChecked(checkbox, elemId) { - if (checkbox.checked) { - Effect.Appear(elemId, {duration : 0.5}); - } else { - Effect.Fade(elemId, {duration : 0.5}); - } -} - -/* function strip_tags(s) { - return s.replace(/<\/?[^>]+(>|$)/g, ""); -} */ - -// noinspection JSUnusedGlobalSymbols -function label_to_feed_id(label) { - return LABEL_BASE_INDEX - 1 - Math.abs(label); -} - -// noinspection JSUnusedGlobalSymbols -function feed_to_label_id(feed) { - return LABEL_BASE_INDEX - 1 + Math.abs(feed); -} - // http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac +/* exported getSelectionText */ function getSelectionText() { let text = ""; @@ -281,36 +260,3 @@ function getSelectionText() { return text.stripTags(); } - -// noinspection JSUnusedGlobalSymbols -function popupOpenUrl(url) { - const w = window.open(""); - - w.opener = null; - w.location = url; -} - -// noinspection JSUnusedGlobalSymbols -function popupOpenArticle(id) { - const w = window.open("", - "ttrss_article_popup", - "height=900,width=900,resizable=yes,status=no,location=no,menubar=no,directories=no,scrollbars=yes,toolbar=no"); - - if (w) { - w.opener = null; - w.location = "backend.php?op=article&method=view&mode=raw&html=1&zoom=1&id=" + id + "&csrf_token=" + App.getInitParam("csrf_token"); - } -} - -// htmlspecialchars()-alike for headlines data-content attribute -function escapeHtml(text) { - const map = { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''' - }; - - return text.replace(/[&<>"']/g, function(m) { return map[m]; }); -} diff --git a/js/form/ValidationTextArea.js b/js/form/ValidationTextArea.js new file mode 100644 index 000000000..a7993f716 --- /dev/null +++ b/js/form/ValidationTextArea.js @@ -0,0 +1,33 @@ +// https://stackoverflow.com/questions/19317258/how-to-use-dijit-textarea-validation-dojo-1-9 + +define(["dojo/_base/declare", "dojo/_base/lang", "dijit/form/SimpleTextarea", "dijit/form/ValidationTextBox"], + function(declare, lang, SimpleTextarea, ValidationTextBox) { + + return declare('fox.form.ValidationTextArea', [SimpleTextarea, ValidationTextBox], { + constructor: function(params){ + this.constraints = {}; + this.baseClass += ' dijitValidationTextArea'; + }, + templateString: "<textarea ${!nameAttrSetting} data-dojo-attach-point='focusNode,containerNode,textbox' autocomplete='off'></textarea>", + validator: function(value, constraints) { + //console.log(this, value, constraints); + + if (this.required && this._isEmpty(value)) + return false; + + if (this.validregexp) { + try { + new RegExp("/" + value + "/"); + } catch (e) { + return false; + } + } + + return value.match(new RegExp(this._computeRegexp(constraints))); + + /*return (new RegExp("^(?:" + this._computeRegexp(constraints) + ")"+(this.required?"":"?")+"$",["m"])).test(value) && + (!this.required || !this._isEmpty(value)) && + (this._isEmpty(value) || this.parse(value, constraints) !== undefined); // Boolean*/ + } + }) + }); diff --git a/js/prefs.js b/js/prefs.js index 944e49258..a71b4f39e 100755 --- a/js/prefs.js +++ b/js/prefs.js @@ -1,19 +1,15 @@ 'use strict' -/* global dijit, __ */ -let App; -let CommonDialogs; -let Filters; -let Users; -let Helpers; +/* global require, App */ +/* exported Plugins */ const Plugins = {}; require(["dojo/_base/kernel", "dojo/_base/declare", "dojo/ready", "dojo/parser", - "fox/AppBase", + "fox/App", "dojo/_base/loader", "dojo/_base/html", "dijit/ColorPalette", @@ -55,109 +51,16 @@ require(["dojo/_base/kernel", "fox/PrefFilterTree", "fox/PrefLabelTree", "fox/Toolbar", + "fox/form/ValidationTextArea", "fox/form/Select", "fox/form/ComboButton", - "fox/form/DropDownButton"], function (dojo, declare, ready, parser, AppBase) { + "fox/form/DropDownButton"], function (dojo, declare, ready, parser) { ready(function () { try { - const _App = declare("fox.App", AppBase, { - constructor: function() { - this.setupNightModeDetection(() => { - parser.parse(); - - this.setLoadingProgress(50); - - const clientTzOffset = new Date().getTimezoneOffset() * 60; - const params = {op: "rpc", method: "sanityCheck", clientTzOffset: clientTzOffset}; - - xhrPost("backend.php", params, (transport) => { - try { - this.backendSanityCallback(transport); - } catch (e) { - this.Error.report(e); - } - }); - }); - }, - initSecondStage: function() { - this.enableCsrfSupport(); - - document.onkeydown = (event) => { return App.hotkeyHandler(event) }; - document.onkeypress = (event) => { return App.hotkeyHandler(event) }; - App.setLoadingProgress(50); - Notify.close(); - - let tab = App.urlParam('tab'); - - if (tab) { - tab = dijit.byId(tab + "Tab"); - if (tab) { - dijit.byId("pref-tabs").selectChild(tab); - - switch (App.urlParam('method')) { - case "editfeed": - window.setTimeout(function () { - CommonDialogs.editFeed(App.urlParam('methodparam')) - }, 100); - break; - default: - console.warn("initSecondStage, unknown method:", App.urlParam("method")); - } - } - } else { - let tab = localStorage.getItem("ttrss:prefs-tab"); - - if (tab) { - tab = dijit.byId(tab); - if (tab) { - dijit.byId("pref-tabs").selectChild(tab); - } - } - } - - dojo.connect(dijit.byId("pref-tabs"), "selectChild", function (elem) { - localStorage.setItem("ttrss:prefs-tab", elem.id); - }); - - }, - hotkeyHandler: function (event) { - if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return; - - // Arrow buttons and escape are not reported via keypress, handle them via keydown. - // escape = 27, left = 37, up = 38, right = 39, down = 40 - if (event.type == "keydown" && event.which != 27 && (event.which < 37 || event.which > 40)) return; - - const action_name = App.keyeventToAction(event); - - if (action_name) { - switch (action_name) { - case "feed_subscribe": - CommonDialogs.quickAddFeed(); - return false; - case "create_label": - CommonDialogs.addLabel(); - return false; - case "create_filter": - Filters.quickAddFilter(); - return false; - case "help_dialog": - App.helpDialog("main"); - return false; - default: - console.log("unhandled action: " + action_name + "; keycode: " + event.which); - } - } - }, - isPrefs: function() { - return true; - } - }); - - App = new _App(); - + App.init(parser, true); } catch (e) { - if (App && App.Error) + if (typeof App != "undefined" && App.Error) App.Error.report(e); else alert(e + "\n\n" + e.stack); diff --git a/js/tt-rss.js b/js/tt-rss.js index d45dd5748..83c6681cd 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -1,21 +1,15 @@ 'use strict' -/* global dijit,__ */ -let App; -let CommonDialogs; -let Filters; -let Feeds; -let Headlines; -let Article; -let PluginHost; +/* global require, App */ +/* exported Plugins */ const Plugins = {}; require(["dojo/_base/kernel", "dojo/_base/declare", "dojo/ready", "dojo/parser", - "fox/AppBase", + "fox/App", "dojo/_base/loader", "dojo/_base/html", "dojo/query", @@ -56,549 +50,16 @@ require(["dojo/_base/kernel", "fox/FeedStoreModel", "fox/FeedTree", "fox/Toolbar", + "fox/form/ValidationTextArea", "fox/form/Select", "fox/form/ComboButton", - "fox/form/DropDownButton"], function (dojo, declare, ready, parser, AppBase) { + "fox/form/DropDownButton"], function (dojo, declare, ready, parser) { ready(function () { try { - const _App = declare("fox.App", AppBase, { - global_unread: -1, - _widescreen_mode: false, - hotkey_actions: {}, - constructor: function () { - this.setupNightModeDetection(() => { - parser.parse(); - - if (!this.checkBrowserFeatures()) - return; - - this.setLoadingProgress(30); - this.initHotkeyActions(); - - const a = document.createElement('audio'); - const hasAudio = !!a.canPlayType; - const hasSandbox = "sandbox" in document.createElement("iframe"); - const hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, '')); - const clientTzOffset = new Date().getTimezoneOffset() * 60; - - const params = { - op: "rpc", method: "sanityCheck", hasAudio: hasAudio, - hasMp3: hasMp3, - clientTzOffset: clientTzOffset, - hasSandbox: hasSandbox - }; - - xhrPost("backend.php", params, (transport) => { - try { - App.backendSanityCallback(transport); - } catch (e) { - App.Error.report(e); - } - }); - }); - }, - checkBrowserFeatures: function() { - let errorMsg = ""; - - ['MutationObserver'].each(function(wf) { - if (! (wf in window)) { - errorMsg = `Browser feature check failed: <code>window.${wf}</code> not found.`; - throw $break; - } - }); - - if (errorMsg) { - this.Error.fatal(errorMsg, {info: navigator.userAgent}); - } - - return errorMsg == ""; - }, - initSecondStage: function () { - this.enableCsrfSupport(); - - Feeds.reload(); - Article.close(); - - if (parseInt(Cookie.get("ttrss_fh_width")) > 0) { - dijit.byId("feeds-holder").domNode.setStyle( - {width: Cookie.get("ttrss_fh_width") + "px"}); - } - - dijit.byId("main").resize(); - - dojo.connect(dijit.byId('feeds-holder'), 'resize', - function (args) { - if (args && args.w >= 0) { - Cookie.set("ttrss_fh_width", args.w, App.getInitParam("cookie_lifetime")); - } - }); - - dojo.connect(dijit.byId('content-insert'), 'resize', - function (args) { - if (args && args.w >= 0 && args.h >= 0) { - Cookie.set("ttrss_ci_width", args.w, App.getInitParam("cookie_lifetime")); - Cookie.set("ttrss_ci_height", args.h, App.getInitParam("cookie_lifetime")); - } - }); - - const toolbar = document.forms["toolbar-main"]; - - dijit.getEnclosingWidget(toolbar.view_mode).attr('value', - App.getInitParam("default_view_mode")); - - dijit.getEnclosingWidget(toolbar.order_by).attr('value', - App.getInitParam("default_view_order_by")); - - App.setLoadingProgress(50); - - this._widescreen_mode = App.getInitParam("widescreen"); - this.switchPanelMode(this._widescreen_mode); - - Headlines.initScrollHandler(); - - if (App.getInitParam("simple_update")) { - console.log("scheduling simple feed updater..."); - window.setInterval(() => { Feeds.updateRandom() }, 30 * 1000); - } - - if (App.getInitParam('check_for_updates')) { - window.setInterval(() => { - App.checkForUpdates(); - }, 3600 * 1000); - } - - console.log("second stage ok"); - - PluginHost.run(PluginHost.HOOK_INIT_COMPLETE, null); - - }, - checkForUpdates: function() { - console.log('checking for updates...'); - - xhrJson("backend.php", {op: 'rpc', method: 'checkforupdates'}) - .then((reply) => { - console.log('update reply', reply); - - if (reply.id) { - $("updates-available").show(); - } else { - $("updates-available").hide(); - } - }); - }, - updateTitle: function() { - let tmp = "Tiny Tiny RSS"; - - if (this.global_unread > 0) { - tmp = "(" + this.global_unread + ") " + tmp; - } - - document.title = tmp; - }, - onViewModeChanged: function() { - const view_mode = document.forms["toolbar-main"].view_mode.value; - - $$("body")[0].setAttribute("view-mode", view_mode); - - return Feeds.reloadCurrent(''); - }, - isCombinedMode: function() { - return App.getInitParam("combined_display_mode"); - }, - hotkeyHandler: function(event) { - if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return; - - // Arrow buttons and escape are not reported via keypress, handle them via keydown. - // escape = 27, left = 37, up = 38, right = 39, down = 40, pgup = 33, pgdn = 34 - if (event.type == "keydown" && event.which != 27 && (event.which < 33 || event.which > 40)) return; - - const action_name = App.keyeventToAction(event); - - if (action_name) { - const action_func = this.hotkey_actions[action_name]; - - if (action_func != null) { - action_func(event); - event.stopPropagation(); - return false; - } - } - }, - switchPanelMode: function(wide) { - //if (App.isCombinedMode()) return; - - const article_id = Article.getActive(); - - if (wide) { - dijit.byId("headlines-wrap-inner").attr("design", 'sidebar'); - dijit.byId("content-insert").attr("region", "trailing"); - - dijit.byId("content-insert").domNode.setStyle({width: '50%', - height: 'auto', - borderTopWidth: '0px' }); - - if (parseInt(Cookie.get("ttrss_ci_width")) > 0) { - dijit.byId("content-insert").domNode.setStyle( - {width: Cookie.get("ttrss_ci_width") + "px" }); - } - - $("headlines-frame").setStyle({ borderBottomWidth: '0px' }); - $("headlines-frame").addClassName("wide"); - - } else { - - dijit.byId("content-insert").attr("region", "bottom"); - - dijit.byId("content-insert").domNode.setStyle({width: 'auto', - height: '50%', - borderTopWidth: '0px'}); - - if (parseInt(Cookie.get("ttrss_ci_height")) > 0) { - dijit.byId("content-insert").domNode.setStyle( - {height: Cookie.get("ttrss_ci_height") + "px" }); - } - - $("headlines-frame").setStyle({ borderBottomWidth: '1px' }); - $("headlines-frame").removeClassName("wide"); - - } - - Article.close(); - - if (article_id) Article.view(article_id); - - xhrPost("backend.php", {op: "rpc", method: "setpanelmode", wide: wide ? 1 : 0}); - }, - initHotkeyActions: function() { - this.hotkey_actions["next_feed"] = function () { - const rv = dijit.byId("feedTree").getNextFeed( - Feeds.getActive(), Feeds.activeIsCat()); - - if (rv) Feeds.open({feed: rv[0], is_cat: rv[1], delayed: true}) - }; - this.hotkey_actions["prev_feed"] = function () { - const rv = dijit.byId("feedTree").getPreviousFeed( - Feeds.getActive(), Feeds.activeIsCat()); - - if (rv) Feeds.open({feed: rv[0], is_cat: rv[1], delayed: true}) - }; - this.hotkey_actions["next_article_or_scroll"] = function (event) { - Headlines.move('next', {event: event}); - }; - this.hotkey_actions["prev_article_or_scroll"] = function (event) { - Headlines.move('prev', {event: event}); - }; - this.hotkey_actions["next_article_noscroll"] = function (event) { - Headlines.move('next', {noscroll: true, event: event}); - }; - this.hotkey_actions["prev_article_noscroll"] = function (event) { - Headlines.move('prev', {noscroll: true, event: event}); - }; - this.hotkey_actions["next_article_noexpand"] = function (event) { - Headlines.move('next', {noscroll: true, noexpand: true, event: event}); - }; - this.hotkey_actions["prev_article_noexpand"] = function (event) { - Headlines.move('prev', {noscroll: true, noexpand: true, event: event}); - }; - this.hotkey_actions["search_dialog"] = function () { - Feeds.search(); - }; - this.hotkey_actions["toggle_mark"] = function () { - Headlines.selectionToggleMarked(); - }; - this.hotkey_actions["toggle_publ"] = function () { - Headlines.selectionTogglePublished(); - }; - this.hotkey_actions["toggle_unread"] = function () { - Headlines.selectionToggleUnread({no_error: 1}); - }; - this.hotkey_actions["edit_tags"] = function () { - const id = Article.getActive(); - if (id) { - Article.editTags(id); - } - }; - this.hotkey_actions["open_in_new_window"] = function () { - if (Article.getActive()) { - Article.openInNewWindow(Article.getActive()); - } - }; - this.hotkey_actions["catchup_below"] = function () { - Headlines.catchupRelativeTo(1); - }; - this.hotkey_actions["catchup_above"] = function () { - Headlines.catchupRelativeTo(0); - }; - this.hotkey_actions["article_scroll_down"] = function (event) { - const ctr = App.isCombinedMode() ? $("headlines-frame") : $("content-insert"); - - if (ctr) - Article.scroll(ctr.offsetHeight / 2, event); - }; - this.hotkey_actions["article_scroll_up"] = function (event) { - const ctr = App.isCombinedMode() ? $("headlines-frame") : $("content-insert"); - - if (ctr) - Article.scroll(-ctr.offsetHeight / 2, event); - }; - this.hotkey_actions["next_article_page"] = function (event) { - Headlines.scrollByPages(1, event); - }; - this.hotkey_actions["prev_article_page"] = function (event) { - Headlines.scrollByPages(-1, event); - }; - this.hotkey_actions["article_page_down"] = function (event) { - Article.scrollByPages(1, event); - }; - this.hotkey_actions["article_page_up"] = function (event) { - Article.scrollByPages(-1, event); - }; - this.hotkey_actions["close_article"] = function () { - if (App.isCombinedMode()) { - Article.cdmUnsetActive(); - } else { - Article.close(); - } - }; - this.hotkey_actions["email_article"] = function () { - if (typeof Plugins.Mail != "undefined") { - Plugins.Mail.onHotkey(Headlines.getSelected()); - } else { - alert(__("Please enable mail or mailto plugin first.")); - } - }; - this.hotkey_actions["select_all"] = function () { - Headlines.select('all'); - }; - this.hotkey_actions["select_unread"] = function () { - Headlines.select('unread'); - }; - this.hotkey_actions["select_marked"] = function () { - Headlines.select('marked'); - }; - this.hotkey_actions["select_published"] = function () { - Headlines.select('published'); - }; - this.hotkey_actions["select_invert"] = function () { - Headlines.select('invert'); - }; - this.hotkey_actions["select_none"] = function () { - Headlines.select('none'); - }; - this.hotkey_actions["feed_refresh"] = function () { - if (typeof Feeds.getActive() != "undefined") { - Feeds.open({feed: Feeds.getActive(), is_cat: Feeds.activeIsCat()}); - } - }; - this.hotkey_actions["feed_unhide_read"] = function () { - Feeds.toggleUnread(); - }; - this.hotkey_actions["feed_subscribe"] = function () { - CommonDialogs.quickAddFeed(); - }; - this.hotkey_actions["feed_debug_update"] = function () { - if (!Feeds.activeIsCat() && parseInt(Feeds.getActive()) > 0) { - window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + Feeds.getActive() + - "&csrf_token=" + App.getInitParam("csrf_token")); - } else { - alert("You can't debug this kind of feed."); - } - }; - - this.hotkey_actions["feed_debug_viewfeed"] = function () { - Feeds.open({feed: Feeds.getActive(), is_cat: Feeds.activeIsCat(), viewfeed_debug: true}); - }; - - this.hotkey_actions["feed_edit"] = function () { - if (Feeds.activeIsCat()) - alert(__("You can't edit this kind of feed.")); - else - CommonDialogs.editFeed(Feeds.getActive()); - }; - this.hotkey_actions["feed_catchup"] = function () { - if (typeof Feeds.getActive() != "undefined") { - Feeds.catchupCurrent(); - } - }; - this.hotkey_actions["feed_reverse"] = function () { - Headlines.reverse(); - }; - this.hotkey_actions["feed_toggle_vgroup"] = function () { - xhrPost("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => { - Feeds.reloadCurrent(); - }) - }; - this.hotkey_actions["catchup_all"] = function () { - Feeds.catchupAll(); - }; - this.hotkey_actions["cat_toggle_collapse"] = function () { - if (Feeds.activeIsCat()) { - dijit.byId("feedTree").collapseCat(Feeds.getActive()); - } - }; - this.hotkey_actions["goto_read"] = function () { - Feeds.open({feed: -6}); - }; - this.hotkey_actions["goto_all"] = function () { - Feeds.open({feed: -4}); - }; - this.hotkey_actions["goto_fresh"] = function () { - Feeds.open({feed: -3}); - }; - this.hotkey_actions["goto_marked"] = function () { - Feeds.open({feed: -1}); - }; - this.hotkey_actions["goto_published"] = function () { - Feeds.open({feed: -2}); - }; - this.hotkey_actions["goto_tagcloud"] = function () { - App.displayDlg(__("Tag cloud"), "printTagCloud"); - }; - this.hotkey_actions["goto_prefs"] = function () { - document.location.href = "prefs.php"; - }; - this.hotkey_actions["select_article_cursor"] = function () { - const id = Article.getUnderPointer(); - if (id) { - const row = $("RROW-" + id); - - if (row) - row.toggleClassName("Selected"); - } - }; - this.hotkey_actions["create_label"] = function () { - CommonDialogs.addLabel(); - }; - this.hotkey_actions["create_filter"] = function () { - Filters.quickAddFilter(); - }; - this.hotkey_actions["collapse_sidebar"] = function () { - Feeds.toggle(); - }; - this.hotkey_actions["toggle_full_text"] = function () { - if (typeof Plugins.Af_Readability != "undefined") { - if (Article.getActive()) - Plugins.Af_Readability.embed(Article.getActive()); - } else { - alert(__("Please enable af_readability first.")); - } - }; - this.hotkey_actions["toggle_widescreen"] = function () { - if (!App.isCombinedMode()) { - App._widescreen_mode = !App._widescreen_mode; - - // reset stored sizes because geometry changed - Cookie.set("ttrss_ci_width", 0); - Cookie.set("ttrss_ci_height", 0); - - App.switchPanelMode(App._widescreen_mode); - } else { - alert(__("Widescreen is not available in combined mode.")); - } - }; - this.hotkey_actions["help_dialog"] = function () { - App.helpDialog("main"); - }; - this.hotkey_actions["toggle_combined_mode"] = function () { - const value = App.isCombinedMode() ? "false" : "true"; - - xhrPost("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => { - App.setInitParam("combined_display_mode", - !App.getInitParam("combined_display_mode")); - - Article.close(); - Headlines.renderAgain(); - }) - }; - this.hotkey_actions["toggle_cdm_expanded"] = function () { - const value = App.getInitParam("cdm_expanded") ? "false" : "true"; - - xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => { - App.setInitParam("cdm_expanded", !App.getInitParam("cdm_expanded")); - Headlines.renderAgain(); - }); - }; - }, - onActionSelected: function(opid) { - switch (opid) { - case "qmcPrefs": - document.location.href = "prefs.php"; - break; - case "qmcLogout": - document.location.href = "backend.php?op=logout"; - break; - case "qmcTagCloud": - App.displayDlg(__("Tag cloud"), "printTagCloud"); - break; - case "qmcSearch": - Feeds.search(); - break; - case "qmcAddFeed": - CommonDialogs.quickAddFeed(); - break; - case "qmcDigest": - window.location.href = "backend.php?op=digest"; - break; - case "qmcEditFeed": - if (Feeds.activeIsCat()) - alert(__("You can't edit this kind of feed.")); - else - CommonDialogs.editFeed(Feeds.getActive()); - break; - case "qmcRemoveFeed": - const actid = Feeds.getActive(); - - if (!actid) { - alert(__("Please select some feed first.")); - return; - } - - if (Feeds.activeIsCat()) { - alert(__("You can't unsubscribe from the category.")); - return; - } - - const fn = Feeds.getName(actid); - - if (confirm(__("Unsubscribe from %s?").replace("%s", fn))) { - CommonDialogs.unsubscribeFeed(actid); - } - break; - case "qmcCatchupAll": - Feeds.catchupAll(); - break; - case "qmcShowOnlyUnread": - Feeds.toggleUnread(); - break; - case "qmcToggleWidescreen": - if (!App.isCombinedMode()) { - App._widescreen_mode = !App._widescreen_mode; - - // reset stored sizes because geometry changed - Cookie.set("ttrss_ci_width", 0); - Cookie.set("ttrss_ci_height", 0); - - App.switchPanelMode(App._widescreen_mode); - } else { - alert(__("Widescreen is not available in combined mode.")); - } - break; - case "qmcHKhelp": - App.helpDialog("main"); - break; - default: - console.log("quickMenuGo: unknown action: " + opid); - } - }, - isPrefs: function() { - return false; - } - }); - - App = new _App(); + App.init(parser, false); } catch (e) { - if (App && App.Error) + if (typeof App != "undefined" && App.Error) App.Error.report(e); else alert(e + "\n\n" + e.stack); @@ -606,11 +67,13 @@ require(["dojo/_base/kernel", }); }); +/* exported hash_get */ function hash_get(key) { const kv = window.location.hash.substring(1).toQueryParams(); return kv[key]; } +/* exported hash_set */ function hash_set(key, value) { const kv = window.location.hash.substring(1).toQueryParams(); kv[key] = value; diff --git a/js/utility.js b/js/utility.js index 2380f9823..eef1c6b61 100644 --- a/js/utility.js +++ b/js/utility.js @@ -1,4 +1,6 @@ -/* TODO: this should probably be something like night_mode.js since it does nothing specific to utility scripts */2 +/* global UtilityApp */ + +/* TODO: this should probably be something like night_mode.js since it does nothing specific to utility scripts */ Event.observe(window, "load", function() { const UtilityJS = { diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 000000000..da01bdd7c --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "ES6", + "module": "amd" + }, + "include": [ + "js/*.js", + "plugins/**/*.js" + ] +} diff --git a/lib/MiniTemplator.class.php b/lib/MiniTemplator.class.php index e70f0a470..728cdf260 100644 --- a/lib/MiniTemplator.class.php +++ b/lib/MiniTemplator.class.php @@ -1,922 +1,921 @@ -<?php
-/**
-* File MiniTemplator.class.php
-* @package MiniTemplator
-*/
-
-/**
-* A compact template engine for HTML files.
-*
-* Requires PHP 4.0.4 or newer.
-*
-* <pre>
-* Template syntax:
-*
-* Variables:
-* ${VariableName}
-*
-* Blocks:
-* <!-- $BeginBlock BlockName -->
-* ... block content ...
-* <!-- $EndBlock BlockName -->
-*
-* Include a subtemplate:
-* <!-- $Include RelativeFileName -->
-* </pre>
-*
-* <pre>
-* General remarks:
-* - Variable names and block names are case-insensitive.
-* - The same variable may be used multiple times within a template.
-* - Blocks can be nested.
-* - Multiple blocks with the same name may occur within a template.
-* </pre>
-*
-* <pre>
-* Public methods:
-* readTemplateFromFile - Reads the template from a file.
-* setTemplateString - Assigns a new template string.
-* setVariable - Sets a template variable.
-* setVariableEsc - Sets a template variable to an escaped string value.
-* variableExists - Checks whether a template variable exists.
-* addBlock - Adds an instance of a template block.
-* blockExists - Checks whether a block exists.
-* reset - Clears all variables and blocks.
-* generateOutput - Generates the HTML page and writes it to the PHP output stream.
-* generateOutputToFile - Generates the HTML page and writes it to a file.
-* generateOutputToString - Generates the HTML page and writes it to a string.
-* </pre>
-*
-* Home page: {@link http://www.source-code.biz/MiniTemplator}<br>
-* License: This module is released under the GNU/LGPL license ({@link http://www.gnu.org/licenses/lgpl.html}).<br>
-* Copyright 2003: Christian d'Heureuse, Inventec Informatik AG, Switzerland. All rights reserved.<br>
-* This product is provided "as is" without warranty of any kind.<br>
-*
-* Version history:<br>
-* 2001-10-24 Christian d'Heureuse (chdh): VBasic version created.<br>
-* 2002-01-26 Markus Angst: ported to PHP4.<br>
-* 2003-04-07 chdh: changes to adjust to Java version.<br>
-* 2003-07-08 chdh: Method variableExists added.
-* Method setVariable changed to trigger an error when the variable does not exist.<br>
-* 2004-04-07 chdh: Parameter isOptional added to method setVariable.
-* Licensing changed from GPL to LGPL.<br>
-* 2004-04-18 chdh: Method blockExists added.<br>
-* 2004-10-28 chdh:<br>
-* Method setVariableEsc added.<br>
-* Multiple blocks with the same name may now occur within a template.<br>
-* No error ("unknown command") is generated any more, if a HTML comment starts with "${".<br>
-* 2004-11-06 chdh:<br>
-* "$Include" command implemented.<br>
-* 2004-11-20 chdh:<br>
-* "$Include" command changed so that the command text is not copied to the output file.<br>
-*/
-
-class MiniTemplator {
-
-//--- public member variables ---------------------------------------------------------------------------------------
-
-/**
-* Base path for relative file names of subtemplates (for the $Include command).
-* This path is prepended to the subtemplate file names. It must be set before
-* readTemplateFromFile or setTemplateString.
-* @access public
-*/
-var $subtemplateBasePath;
-
-//--- private member variables --------------------------------------------------------------------------------------
-
-/**#@+
-* @access private
-*/
-
-var $maxNestingLevel = 50; // maximum number of block nestings
-var $maxInclTemplateSize = 1000000; // maximum length of template string when including subtemplates
-var $template; // Template file data
-var $varTab; // variables table, array index is variable no
- // Fields:
- // varName // variable name
- // varValue // variable value
-var $varTabCnt; // no of entries used in VarTab
-var $varNameToNoMap; // maps variable names to variable numbers
-var $varRefTab; // variable references table
- // Contains an entry for each variable reference in the template. Ordered by TemplatePos.
- // Fields:
- // varNo // variable no
- // tPosBegin // template position of begin of variable reference
- // tPosEnd // template position of end of variable reference
- // blockNo // block no of the (innermost) block that contains this variable reference
- // blockVarNo // block variable no. Index into BlockInstTab.BlockVarTab
-var $varRefTabCnt; // no of entries used in VarRefTab
-var $blockTab; // Blocks table, array index is block no
- // Contains an entry for each block in the template. Ordered by TPosBegin.
- // Fields:
- // blockName // block name
- // nextWithSameName; // block no of next block with same name or -1 (blocks are backward linked in relation to template position)
- // tPosBegin // template position of begin of block
- // tPosContentsBegin // template pos of begin of block contents
- // tPosContentsEnd // template pos of end of block contents
- // tPosEnd // template position of end of block
- // nestingLevel // block nesting level
- // parentBlockNo // block no of parent block
- // definitionIsOpen // true while $BeginBlock processed but no $EndBlock
- // instances // number of instances of this block
- // firstBlockInstNo // block instance no of first instance of this block or -1
- // lastBlockInstNo // block instance no of last instance of this block or -1
- // currBlockInstNo // current block instance no, used during generation of output file
- // blockVarCnt // no of variables in block
- // blockVarNoToVarNoMap // maps block variable numbers to variable numbers
- // firstVarRefNo // variable reference no of first variable of this block or -1
-var $blockTabCnt; // no of entries used in BlockTab
-var $blockNameToNoMap; // maps block names to block numbers
-var $openBlocksTab;
- // During parsing, this table contains the block numbers of the open parent blocks (nested outer blocks).
- // Indexed by the block nesting level.
-var $blockInstTab; // block instances table
- // This table contains an entry for each block instance that has been added.
- // Indexed by BlockInstNo.
- // Fields:
- // blockNo // block number
- // instanceLevel // instance level of this block
- // InstanceLevel is an instance counter per block.
- // (In contrast to blockInstNo, which is an instance counter over the instances of all blocks)
- // parentInstLevel // instance level of parent block
- // nextBlockInstNo // pointer to next instance of this block or -1
- // Forward chain for instances of same block.
- // blockVarTab // block instance variables
-var $blockInstTabCnt; // no of entries used in BlockInstTab
-
-var $currentNestingLevel; // Current block nesting level during parsing.
-var $templateValid; // true if a valid template is prepared
-var $outputMode; // 0 = to PHP output stream, 1 = to file, 2 = to string
-var $outputFileHandle; // file handle during writing of output file
-var $outputError; // true when an output error occurred
-var $outputString; // string buffer for the generated HTML page
-
-/**#@-*/
-
-//--- constructor ---------------------------------------------------------------------------------------------------
-
-/**
-* Constructs a MiniTemplator object.
-* @access public
-*/
-function __construct() {
- $this->templateValid = false; }
-
-//--- template string handling --------------------------------------------------------------------------------------
-
-/**
-* Reads the template from a file.
-* @param string $fileName name of the file that contains the template.
-* @return boolean true on success, false on error.
-* @access public
-*/
-function readTemplateFromFile ($fileName) {
- if (!$this->readFileIntoString($fileName,$s)) {
- $this->triggerError ("Error while reading template file " . $fileName . ".");
- return false; }
- if (!$this->setTemplateString($s)) return false;
- return true; }
-
-/**
-* Assigns a new template string.
-* @param string $templateString contents of the template file.
-* @return boolean true on success, false on error.
-* @access public
-*/
-function setTemplateString ($templateString) {
- $this->templateValid = false;
- $this->template = $templateString;
- if (!$this->parseTemplate()) return false;
- $this->reset();
- $this->templateValid = true;
- return true; }
-
-/**
-* Loads the template string for a subtemplate (used for the $Include command).
-* @return boolean true on success, false on error.
-* @access private
-*/
-function loadSubtemplate ($subtemplateName, &$s) {
- $subtemplateFileName = $this->combineFileSystemPath($this->subtemplateBasePath,$subtemplateName);
- if (!$this->readFileIntoString($subtemplateFileName,$s)) {
- $this->triggerError ("Error while reading subtemplate file " . $subtemplateFileName . ".");
- return false; }
- return true; }
-
-//--- template parsing ----------------------------------------------------------------------------------------------
-
-/**
-* Parses the template.
-* @return boolean true on success, false on error.
-* @access private
-*/
-function parseTemplate() {
- $this->initParsing();
- $this->beginMainBlock();
- if (!$this->parseTemplateCommands()) return false;
- $this->endMainBlock();
- if (!$this->checkBlockDefinitionsComplete()) return false;
- if (!$this->parseTemplateVariables()) return false;
- $this->associateVariablesWithBlocks();
- return true; }
-
-/**
-* @access private
-*/
-function initParsing() {
- $this->varTab = array();
- $this->varTabCnt = 0;
- $this->varNameToNoMap = array();
- $this->varRefTab = array();
- $this->varRefTabCnt = 0;
- $this->blockTab = array();
- $this->blockTabCnt = 0;
- $this->blockNameToNoMap = array();
- $this->openBlocksTab = array(); }
-
-/**
-* Registers the main block.
-* The main block is an implicitly defined block that covers the whole template.
-* @access private
-*/
-function beginMainBlock() {
- $blockNo = 0;
- $this->registerBlock('@@InternalMainBlock@@', $blockNo);
- $bte =& $this->blockTab[$blockNo];
- $bte['tPosBegin'] = 0;
- $bte['tPosContentsBegin'] = 0;
- $bte['nestingLevel'] = 0;
- $bte['parentBlockNo'] = -1;
- $bte['definitionIsOpen'] = true;
- $this->openBlocksTab[0] = $blockNo;
- $this->currentNestingLevel = 1; }
-
-/**
-* Completes the main block registration.
-* @access private
-*/
-function endMainBlock() {
- $bte =& $this->blockTab[0];
- $bte['tPosContentsEnd'] = strlen($this->template);
- $bte['tPosEnd'] = strlen($this->template);
- $bte['definitionIsOpen'] = false;
- $this->currentNestingLevel -= 1; }
-
-/**
-* Parses commands within the template in the format "<!-- $command parameters -->".
-* @return boolean true on success, false on error.
-* @access private
-*/
-function parseTemplateCommands() {
- $p = 0;
- while (true) {
- $p0 = strpos($this->template,'<!--',$p);
- if ($p0 === false) break;
- $p = strpos($this->template,'-->',$p0);
- if ($p === false) {
- $this->triggerError ("Invalid HTML comment in template at offset $p0.");
- return false; }
- $p += 3;
- $cmdL = substr($this->template,$p0+4,$p-$p0-7);
- if (!$this->processTemplateCommand($cmdL,$p0,$p,$resumeFromStart))
- return false;
- if ($resumeFromStart) $p = $p0; }
- return true; }
-
-/**
-* @return boolean true on success, false on error.
-* @access private
-*/
-function processTemplateCommand ($cmdL, $cmdTPosBegin, $cmdTPosEnd, &$resumeFromStart) {
- $resumeFromStart = false;
- $p = 0;
- $cmd = '';
- if (!$this->parseWord($cmdL,$p,$cmd)) return true;
- $parms = substr($cmdL,$p);
- switch (strtoupper($cmd)) {
- case '$BEGINBLOCK':
- if (!$this->processBeginBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd))
- return false;
- break;
- case '$ENDBLOCK':
- if (!$this->processEndBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd))
- return false;
- break;
- case '$INCLUDE':
- if (!$this->processincludeCmd($parms,$cmdTPosBegin,$cmdTPosEnd))
- return false;
- $resumeFromStart = true;
- break;
- default:
- if ($cmd{0} == '$' && !(strlen($cmd) >= 2 && $cmd{1} == '{')) {
- $this->triggerError ("Unknown command \"$cmd\" in template at offset $cmdTPosBegin.");
- return false; }}
- return true; }
-
-/**
-* Processes the $BeginBlock command.
-* @return boolean true on success, false on error.
-* @access private
-*/
-function processBeginBlockCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) {
- $p = 0;
- if (!$this->parseWord($parms,$p,$blockName)) {
- $this->triggerError ("Missing block name in \$BeginBlock command in template at offset $cmdTPosBegin.");
- return false; }
- if (trim(substr($parms,$p)) != '') {
- $this->triggerError ("Extra parameter in \$BeginBlock command in template at offset $cmdTPosBegin.");
- return false; }
- $this->registerBlock ($blockName, $blockNo);
- $btr =& $this->blockTab[$blockNo];
- $btr['tPosBegin'] = $cmdTPosBegin;
- $btr['tPosContentsBegin'] = $cmdTPosEnd;
- $btr['nestingLevel'] = $this->currentNestingLevel;
- $btr['parentBlockNo'] = $this->openBlocksTab[$this->currentNestingLevel-1];
- $this->openBlocksTab[$this->currentNestingLevel] = $blockNo;
- $this->currentNestingLevel += 1;
- if ($this->currentNestingLevel > $this->maxNestingLevel) {
- $this->triggerError ("Block nesting overflow in template at offset $cmdTPosBegin.");
- return false; }
- return true; }
-
-/**
-* Processes the $EndBlock command.
-* @return boolean true on success, false on error.
-* @access private
-*/
-function processEndBlockCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) {
- $p = 0;
- if (!$this->parseWord($parms,$p,$blockName)) {
- $this->triggerError ("Missing block name in \$EndBlock command in template at offset $cmdTPosBegin.");
- return false; }
- if (trim(substr($parms,$p)) != '') {
- $this->triggerError ("Extra parameter in \$EndBlock command in template at offset $cmdTPosBegin.");
- return false; }
- if (!$this->lookupBlockName($blockName,$blockNo)) {
- $this->triggerError ("Undefined block name \"$blockName\" in \$EndBlock command in template at offset $cmdTPosBegin.");
- return false; }
- $this->currentNestingLevel -= 1;
- $btr =& $this->blockTab[$blockNo];
- if (!$btr['definitionIsOpen']) {
- $this->triggerError ("Multiple \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin.");
- return false; }
- if ($btr['nestingLevel'] != $this->currentNestingLevel) {
- $this->triggerError ("Block nesting level mismatch at \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin.");
- return false; }
- $btr['tPosContentsEnd'] = $cmdTPosBegin;
- $btr['tPosEnd'] = $cmdTPosEnd;
- $btr['definitionIsOpen'] = false;
- return true; }
-
-/**
-* @access private
-*/
-function registerBlock($blockName, &$blockNo) {
- $blockNo = $this->blockTabCnt++;
- $btr =& $this->blockTab[$blockNo];
- $btr = array();
- $btr['blockName'] = $blockName;
- if (!$this->lookupBlockName($blockName,$btr['nextWithSameName']))
- $btr['nextWithSameName'] = -1;
- $btr['definitionIsOpen'] = true;
- $btr['instances'] = 0;
- $btr['firstBlockInstNo'] = -1;
- $btr['lastBlockInstNo'] = -1;
- $btr['blockVarCnt'] = 0;
- $btr['firstVarRefNo'] = -1;
- $btr['blockVarNoToVarNoMap'] = array();
- $this->blockNameToNoMap[strtoupper($blockName)] = $blockNo; }
-
-/**
-* Checks that all block definitions are closed.
-* @return boolean true on success, false on error.
-* @access private
-*/
-function checkBlockDefinitionsComplete() {
- for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) {
- $btr =& $this->blockTab[$blockNo];
- if ($btr['definitionIsOpen']) {
- $this->triggerError ("Missing \$EndBlock command in template for block " . $btr['blockName'] . ".");
- return false; }}
- if ($this->currentNestingLevel != 0) {
- $this->triggerError ("Block nesting level error at end of template.");
- return false; }
- return true; }
-
-/**
-* Processes the $Include command.
-* @return boolean true on success, false on error.
-* @access private
-*/
-function processIncludeCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) {
- $p = 0;
- if (!$this->parseWordOrQuotedString($parms,$p,$subtemplateName)) {
- $this->triggerError ("Missing or invalid subtemplate name in \$Include command in template at offset $cmdTPosBegin.");
- return false; }
- if (trim(substr($parms,$p)) != '') {
- $this->triggerError ("Extra parameter in \$include command in template at offset $cmdTPosBegin.");
- return false; }
- return $this->insertSubtemplate($subtemplateName,$cmdTPosBegin,$cmdTPosEnd); }
-
-/**
-* Processes the $Include command.
-* @return boolean true on success, false on error.
-* @access private
-*/
-function insertSubtemplate ($subtemplateName, $tPos1, $tPos2) {
- if (strlen($this->template) > $this->maxInclTemplateSize) {
- $this->triggerError ("Subtemplate include aborted because the internal template string is longer than $this->maxInclTemplateSize characters.");
- return false; }
- if (!$this->loadSubtemplate($subtemplateName,$subtemplate)) return false;
- // (Copying the template to insert a subtemplate is a bit slow. In a future implementation of MiniTemplator,
- // a table could be used that contains references to the string fragments.)
- $this->template = substr($this->template,0,$tPos1) . $subtemplate . substr($this->template,$tPos2);
- return true; }
-
-/**
-* Parses variable references within the template in the format "${VarName}".
-* @return boolean true on success, false on error.
-* @access private
-*/
-function parseTemplateVariables() {
- $p = 0;
- while (true) {
- $p = strpos($this->template, '${', $p);
- if ($p === false) break;
- $p0 = $p;
- $p = strpos($this->template, '}', $p);
- if ($p === false) {
- $this->triggerError ("Invalid variable reference in template at offset $p0.");
- return false; }
- $p += 1;
- $varName = trim(substr($this->template, $p0+2, $p-$p0-3));
- if (strlen($varName) == 0) {
- $this->triggerError ("Empty variable name in template at offset $p0.");
- return false; }
- $this->registerVariableReference ($varName, $p0, $p); }
- return true; }
-
-/**
-* @access private
-*/
-function registerVariableReference ($varName, $tPosBegin, $tPosEnd) {
- if (!$this->lookupVariableName($varName,$varNo))
- $this->registerVariable($varName,$varNo);
- $varRefNo = $this->varRefTabCnt++;
- $vrtr =& $this->varRefTab[$varRefNo];
- $vrtr = array();
- $vrtr['tPosBegin'] = $tPosBegin;
- $vrtr['tPosEnd'] = $tPosEnd;
- $vrtr['varNo'] = $varNo; }
-
-/**
-* @access private
-*/
-function registerVariable ($varName, &$varNo) {
- $varNo = $this->varTabCnt++;
- $vtr =& $this->varTab[$varNo];
- $vtr = array();
- $vtr['varName'] = $varName;
- $vtr['varValue'] = '';
- $this->varNameToNoMap[strtoupper($varName)] = $varNo; }
-
-/**
-* Associates variable references with blocks.
-* @access private
-*/
-function associateVariablesWithBlocks() {
- $varRefNo = 0;
- $activeBlockNo = 0;
- $nextBlockNo = 1;
- while ($varRefNo < $this->varRefTabCnt) {
- $vrtr =& $this->varRefTab[$varRefNo];
- $varRefTPos = $vrtr['tPosBegin'];
- $varNo = $vrtr['varNo'];
- if ($varRefTPos >= $this->blockTab[$activeBlockNo]['tPosEnd']) {
- $activeBlockNo = $this->blockTab[$activeBlockNo]['parentBlockNo'];
- continue; }
- if ($nextBlockNo < $this->blockTabCnt) {
- if ($varRefTPos >= $this->blockTab[$nextBlockNo]['tPosBegin']) {
- $activeBlockNo = $nextBlockNo;
- $nextBlockNo += 1;
- continue; }}
- $btr =& $this->blockTab[$activeBlockNo];
- if ($varRefTPos < $btr['tPosBegin'])
- $this->programLogicError(1);
- $blockVarNo = $btr['blockVarCnt']++;
- $btr['blockVarNoToVarNoMap'][$blockVarNo] = $varNo;
- if ($btr['firstVarRefNo'] == -1)
- $btr['firstVarRefNo'] = $varRefNo;
- $vrtr['blockNo'] = $activeBlockNo;
- $vrtr['blockVarNo'] = $blockVarNo;
- $varRefNo += 1; }}
-
-//--- build up (template variables and blocks) ----------------------------------------------------------------------
-
-/**
-* Clears all variables and blocks.
-* This method can be used to produce another HTML page with the same
-* template. It is faster than creating another MiniTemplator object,
-* because the template does not have to be parsed again.
-* All variable values are cleared and all added block instances are deleted.
-* @access public
-*/
-function reset() {
- for ($varNo=0; $varNo<$this->varTabCnt; $varNo++)
- $this->varTab[$varNo]['varValue'] = '';
- for ($blockNo=0; $blockNo<$this->blockTabCnt; $blockNo++) {
- $btr =& $this->blockTab[$blockNo];
- $btr['instances'] = 0;
- $btr['firstBlockInstNo'] = -1;
- $btr['lastBlockInstNo'] = -1; }
- $this->blockInstTab = array();
- $this->blockInstTabCnt = 0; }
-
-/**
-* Sets a template variable.
-* For variables that are used in blocks, the variable value
-* must be set before {@link addBlock} is called.
-* @param string $variableName the name of the variable to be set.
-* @param string $variableValue the new value of the variable.
-* @param boolean $isOptional Specifies whether an error should be
-* generated when the variable does not exist in the template. If
-* $isOptional is false and the variable does not exist, an error is
-* generated.
-* @return boolean true on success, or false on error (e.g. when no
-* variable with the specified name exists in the template and
-* $isOptional is false).
-* @access public
-*/
-function setVariable ($variableName, $variableValue, $isOptional=false) {
- if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
- if (!$this->lookupVariableName($variableName,$varNo)) {
- if ($isOptional) return true;
- $this->triggerError ("Variable \"$variableName\" not defined in template.");
- return false; }
- $this->varTab[$varNo]['varValue'] = $variableValue;
- return true; }
-
-/**
-* Sets a template variable to an escaped string.
-* This method is identical to (@link setVariable), except that
-* the characters <, >, &, ' and " of variableValue are
-* replaced by their corresponding HTML/XML character entity codes.
-* For variables that are used in blocks, the variable value
-* must be set before {@link addBlock} is called.
-* @param string $variableName the name of the variable to be set.
-* @param string $variableValue the new value of the variable. Special HTML/XML characters are escaped.
-* @param boolean $isOptional Specifies whether an error should be
-* generated when the variable does not exist in the template. If
-* $isOptional is false and the variable does not exist, an error is
-* generated.
-* @return boolean true on success, or false on error (e.g. when no
-* variable with the specified name exists in the template and
-* $isOptional is false).
-* @access public
-*/
-function setVariableEsc ($variableName, $variableValue, $isOptional=false) {
- return $this->setVariable($variableName,htmlspecialchars($variableValue,ENT_QUOTES),$isOptional); }
-
-/**
-* Checks whether a variable with the specified name exists within the template.
-* @param string $variableName the name of the variable.
-* @return boolean true if the variable exists, or false when no
-* variable with the specified name exists in the template.
-* @access public
-*/
-function variableExists ($variableName) {
- if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
- return $this->lookupVariableName($variableName,$varNo); }
-
-/**
-* Adds an instance of a template block.
-* If the block contains variables, these variables must be set
-* before the block is added.
-* If the block contains subblocks (nested blocks), the subblocks
-* must be added before this block is added.
-* If multiple blocks exist with the specified name, an instance
-* is added for each block occurence.
-* @param string blockName the name of the block to be added.
-* @return boolean true on success, false on error (e.g. when no
-* block with the specified name exists in the template).
-* @access public
-*/
-function addBlock($blockName) {
- if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
- if (!$this->lookupBlockName($blockName,$blockNo)) {
- $this->triggerError ("Block \"$blockName\" not defined in template.");
- return false; }
- while ($blockNo != -1) {
- $this->addBlockByNo($blockNo);
- $blockNo = $this->blockTab[$blockNo]['nextWithSameName']; }
- return true; }
-
-/**
-* @access private
-*/
-function addBlockByNo ($blockNo) {
- $btr =& $this->blockTab[$blockNo];
- $this->registerBlockInstance ($blockInstNo);
- $bitr =& $this->blockInstTab[$blockInstNo];
- if ($btr['firstBlockInstNo'] == -1)
- $btr['firstBlockInstNo'] = $blockInstNo;
- if ($btr['lastBlockInstNo'] != -1)
- $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo;
- // set forward pointer of chain
- $btr['lastBlockInstNo'] = $blockInstNo;
- $parentBlockNo = $btr['parentBlockNo'];
- $blockVarCnt = $btr['blockVarCnt'];
- $bitr['blockNo'] = $blockNo;
- $bitr['instanceLevel'] = $btr['instances']++;
- if ($parentBlockNo == -1)
- $bitr['parentInstLevel'] = -1;
- else
- $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances'];
- $bitr['nextBlockInstNo'] = -1;
- $bitr['blockVarTab'] = array();
- // copy instance variables for this block
- for ($blockVarNo=0; $blockVarNo<$blockVarCnt; $blockVarNo++) {
- $varNo = $btr['blockVarNoToVarNoMap'][$blockVarNo];
- $bitr['blockVarTab'][$blockVarNo] = $this->varTab[$varNo]['varValue']; }}
-
-/**
-* @access private
-*/
-function registerBlockInstance (&$blockInstNo) {
- $blockInstNo = $this->blockInstTabCnt++; }
-
-/**
-* Checks whether a block with the specified name exists within the template.
-* @param string $blockName the name of the block.
-* @return boolean true if the block exists, or false when no
-* block with the specified name exists in the template.
-* @access public
-*/
-function blockExists ($blockName) {
- if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
- return $this->lookupBlockName($blockName,$blockNo); }
-
-//--- output generation ---------------------------------------------------------------------------------------------
-
-/**
-* Generates the HTML page and writes it to the PHP output stream.
-* @return boolean true on success, false on error.
-* @access public
-*/
-function generateOutput () {
- $this->outputMode = 0;
- if (!$this->generateOutputPage()) return false;
- return true; }
-
-/**
-* Generates the HTML page and writes it to a file.
-* @param string $fileName name of the output file.
-* @return boolean true on success, false on error.
-* @access public
-*/
-function generateOutputToFile ($fileName) {
- $fh = fopen($fileName,"wb");
- if ($fh === false) return false;
- $this->outputMode = 1;
- $this->outputFileHandle = $fh;
- $ok = $this->generateOutputPage();
- fclose ($fh);
- return $ok; }
-
-/**
-* Generates the HTML page and writes it to a string.
-* @param string $outputString variable that receives
-* the contents of the generated HTML page.
-* @return boolean true on success, false on error.
-* @access public
-*/
-function generateOutputToString (&$outputString) {
- $outputString = "Error";
- $this->outputMode = 2;
- $this->outputString = "";
- if (!$this->generateOutputPage()) return false;
- $outputString = $this->outputString;
- return true; }
-
-/**
-* @access private
-* @return boolean true on success, false on error.
-*/
-function generateOutputPage() {
- if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; }
- if ($this->blockTab[0]['instances'] == 0)
- $this->addBlockByNo (0); // add main block
- for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) {
- $btr =& $this->blockTab[$blockNo];
- $btr['currBlockInstNo'] = $btr['firstBlockInstNo']; }
- $this->outputError = false;
- $this->writeBlockInstances (0, -1);
- if ($this->outputError) return false;
- return true; }
-
-/**
-* Writes all instances of a block that are contained within a specific
-* parent block instance.
-* Called recursively.
-* @access private
-*/
-function writeBlockInstances ($blockNo, $parentInstLevel) {
- $btr =& $this->blockTab[$blockNo];
- while (!$this->outputError) {
- $blockInstNo = $btr['currBlockInstNo'];
- if ($blockInstNo == -1) break;
- $bitr =& $this->blockInstTab[$blockInstNo];
- if ($bitr['parentInstLevel'] < $parentInstLevel)
- $this->programLogicError (2);
- if ($bitr['parentInstLevel'] > $parentInstLevel) break;
- $this->writeBlockInstance ($blockInstNo);
- $btr['currBlockInstNo'] = $bitr['nextBlockInstNo']; }}
-
-/**
-* @access private
-*/
-function writeBlockInstance($blockInstNo) {
- $bitr =& $this->blockInstTab[$blockInstNo];
- $blockNo = $bitr['blockNo'];
- $btr =& $this->blockTab[$blockNo];
- $tPos = $btr['tPosContentsBegin'];
- $subBlockNo = $blockNo + 1;
- $varRefNo = $btr['firstVarRefNo'];
- while (!$this->outputError) {
- $tPos2 = $btr['tPosContentsEnd'];
- $kind = 0; // assume end-of-block
- if ($varRefNo != -1 && $varRefNo < $this->varRefTabCnt) { // check for variable reference
- $vrtr =& $this->varRefTab[$varRefNo];
- if ($vrtr['tPosBegin'] < $tPos) {
- $varRefNo += 1;
- continue; }
- if ($vrtr['tPosBegin'] < $tPos2) {
- $tPos2 = $vrtr['tPosBegin'];
- $kind = 1; }}
- if ($subBlockNo < $this->blockTabCnt) { // check for subblock
- $subBtr =& $this->blockTab[$subBlockNo];
- if ($subBtr['tPosBegin'] < $tPos) {
- $subBlockNo += 1;
- continue; }
- if ($subBtr['tPosBegin'] < $tPos2) {
- $tPos2 = $subBtr['tPosBegin'];
- $kind = 2; }}
- if ($tPos2 > $tPos)
- $this->writeString (substr($this->template,$tPos,$tPos2-$tPos));
- switch ($kind) {
- case 0: // end of block
- return;
- case 1: // variable
- $vrtr =& $this->varRefTab[$varRefNo];
- if ($vrtr['blockNo'] != $blockNo)
- $this->programLogicError (4);
- $variableValue = $bitr['blockVarTab'][$vrtr['blockVarNo']];
- $this->writeString ($variableValue);
- $tPos = $vrtr['tPosEnd'];
- $varRefNo += 1;
- break;
- case 2: // sub block
- $subBtr =& $this->blockTab[$subBlockNo];
- if ($subBtr['parentBlockNo'] != $blockNo)
- $this->programLogicError (3);
- $this->writeBlockInstances ($subBlockNo, $bitr['instanceLevel']); // recursive call
- $tPos = $subBtr['tPosEnd'];
- $subBlockNo += 1;
- break; }}}
-
-/**
-* @access private
-*/
-function writeString ($s) {
- if ($this->outputError) return;
- switch ($this->outputMode) {
- case 0: // output to PHP output stream
- if (!print($s))
- $this->outputError = true;
- break;
- case 1: // output to file
- $rc = fwrite($this->outputFileHandle, $s);
- if ($rc === false) $this->outputError = true;
- break;
- case 2: // output to string
- $this->outputString .= $s;
- break; }}
-
-//--- name lookup routines ------------------------------------------------------------------------------------------
-
-/**
-* Maps variable name to variable number.
-* @return boolean true on success, false if the variable is not found.
-* @access private
-*/
-function lookupVariableName ($varName, &$varNo) {
- $x =& $this->varNameToNoMap[strtoupper($varName)];
- if (!isset($x)) return false;
- $varNo = $x;
- return true; }
-
-/**
-* Maps block name to block number.
-* If there are multiple blocks with the same name, the block number of the last
-* registered block with that name is returned.
-* @return boolean true on success, false when the block is not found.
-* @access private
-*/
-function lookupBlockName ($blockName, &$blockNo) {
- $x =& $this->blockNameToNoMap[strtoupper($blockName)];
- if (!isset($x)) return false;
- $blockNo = $x;
- return true; }
-
-//--- general utility routines -----------------------------------------------------------------------------------------
-
-/**
-* Reads a file into a string.
-* @return boolean true on success, false on error.
-* @access private
-*/
-function readFileIntoString ($fileName, &$s) {
- if (function_exists('version_compare') && version_compare(phpversion(),"4.3.0",">=")) {
- $s = file_get_contents($fileName);
- if ($s === false) return false;
- return true; }
- $fh = fopen($fileName,"rb");
- if ($fh === false) return false;
- $fileSize = filesize($fileName);
- if ($fileSize === false) {fclose ($fh); return false; }
- $s = fread($fh,$fileSize);
- fclose ($fh);
- if (strlen($s) != $fileSize) return false;
- return true; }
-
-/**
-* @access private
-* @return boolean true on success, false when the end of the string is reached.
-*/
-function parseWord ($s, &$p, &$w) {
- $sLen = strlen($s);
- while ($p < $sLen && ord($s{$p}) <= 32) $p++;
- if ($p >= $sLen) return false;
- $p0 = $p;
- while ($p < $sLen && ord($s{$p}) > 32) $p++;
- $w = substr($s, $p0, $p - $p0);
- return true; }
-
-/**
-* @access private
-* @return boolean true on success, false on error.
-*/
-function parseQuotedString ($s, &$p, &$w) {
- $sLen = strlen($s);
- while ($p < $sLen && ord($s{$p}) <= 32) $p++;
- if ($p >= $sLen) return false;
- if (substr($s,$p,1) != '"') return false;
- $p++; $p0 = $p;
- while ($p < $sLen && $s{$p} != '"') $p++;
- if ($p >= $sLen) return false;
- $w = substr($s, $p0, $p - $p0);
- $p++;
- return true; }
-
-/**
-* @access private
-* @return boolean true on success, false on error.
-*/
-function parseWordOrQuotedString ($s, &$p, &$w) {
- $sLen = strlen($s);
- while ($p < $sLen && ord($s{$p}) <= 32) $p++;
- if ($p >= $sLen) return false;
- if (substr($s,$p,1) == '"')
- return $this->parseQuotedString($s,$p,$w);
- else
- return $this->parseWord($s,$p,$w); }
-
-/**
-* Combine two file system paths.
-* @access private
-*/
-function combineFileSystemPath ($path1, $path2) {
- if ($path1 == '' || $path2 == '') return $path2;
- $s = $path1;
- if (substr($s,-1) != '\\' && substr($s,-1) != '/') $s = $s . "/";
- if (substr($path2,0,1) == '\\' || substr($path2,0,1) == '/')
- $s = $s . substr($path2,1);
- else
- $s = $s . $path2;
- return $s; }
-
-/**
-* @access private
-*/
-function triggerError ($msg) {
- trigger_error ("MiniTemplator error: $msg", E_USER_ERROR); }
-
-/**
-* @access private
-*/
-function programLogicError ($errorId) {
- die ("MiniTemplator: Program logic error $errorId.\n"); }
-
-}
-?>
+<?php +/** +* File MiniTemplator.class.php +* @package MiniTemplator +*/ + +/** +* A compact template engine for HTML files. +* +* Requires PHP 4.0.4 or newer. +* +* <pre> +* Template syntax: +* +* Variables: +* ${VariableName} +* +* Blocks: +* <!-- $BeginBlock BlockName --> +* ... block content ... +* <!-- $EndBlock BlockName --> +* +* Include a subtemplate: +* <!-- $Include RelativeFileName --> +* </pre> +* +* <pre> +* General remarks: +* - Variable names and block names are case-insensitive. +* - The same variable may be used multiple times within a template. +* - Blocks can be nested. +* - Multiple blocks with the same name may occur within a template. +* </pre> +* +* <pre> +* Public methods: +* readTemplateFromFile - Reads the template from a file. +* setTemplateString - Assigns a new template string. +* setVariable - Sets a template variable. +* setVariableEsc - Sets a template variable to an escaped string value. +* variableExists - Checks whether a template variable exists. +* addBlock - Adds an instance of a template block. +* blockExists - Checks whether a block exists. +* reset - Clears all variables and blocks. +* generateOutput - Generates the HTML page and writes it to the PHP output stream. +* generateOutputToFile - Generates the HTML page and writes it to a file. +* generateOutputToString - Generates the HTML page and writes it to a string. +* </pre> +* +* Home page: {@link http://www.source-code.biz/MiniTemplator}<br> +* License: This module is released under the GNU/LGPL license ({@link http://www.gnu.org/licenses/lgpl.html}).<br> +* Copyright 2003: Christian d'Heureuse, Inventec Informatik AG, Switzerland. All rights reserved.<br> +* This product is provided "as is" without warranty of any kind.<br> +* +* Version history:<br> +* 2001-10-24 Christian d'Heureuse (chdh): VBasic version created.<br> +* 2002-01-26 Markus Angst: ported to PHP4.<br> +* 2003-04-07 chdh: changes to adjust to Java version.<br> +* 2003-07-08 chdh: Method variableExists added. +* Method setVariable changed to trigger an error when the variable does not exist.<br> +* 2004-04-07 chdh: Parameter isOptional added to method setVariable. +* Licensing changed from GPL to LGPL.<br> +* 2004-04-18 chdh: Method blockExists added.<br> +* 2004-10-28 chdh:<br> +* Method setVariableEsc added.<br> +* Multiple blocks with the same name may now occur within a template.<br> +* No error ("unknown command") is generated any more, if a HTML comment starts with "${".<br> +* 2004-11-06 chdh:<br> +* "$Include" command implemented.<br> +* 2004-11-20 chdh:<br> +* "$Include" command changed so that the command text is not copied to the output file.<br> +*/ + +class MiniTemplator { + +//--- public member variables --------------------------------------------------------------------------------------- + +/** +* Base path for relative file names of subtemplates (for the $Include command). +* This path is prepended to the subtemplate file names. It must be set before +* readTemplateFromFile or setTemplateString. +* @access public +*/ +var $subtemplateBasePath; + +//--- private member variables -------------------------------------------------------------------------------------- + +/**#@+ +* @access private +*/ + +var $maxNestingLevel = 50; // maximum number of block nestings +var $maxInclTemplateSize = 1000000; // maximum length of template string when including subtemplates +var $template; // Template file data +var $varTab; // variables table, array index is variable no + // Fields: + // varName // variable name + // varValue // variable value +var $varTabCnt; // no of entries used in VarTab +var $varNameToNoMap; // maps variable names to variable numbers +var $varRefTab; // variable references table + // Contains an entry for each variable reference in the template. Ordered by TemplatePos. + // Fields: + // varNo // variable no + // tPosBegin // template position of begin of variable reference + // tPosEnd // template position of end of variable reference + // blockNo // block no of the (innermost) block that contains this variable reference + // blockVarNo // block variable no. Index into BlockInstTab.BlockVarTab +var $varRefTabCnt; // no of entries used in VarRefTab +var $blockTab; // Blocks table, array index is block no + // Contains an entry for each block in the template. Ordered by TPosBegin. + // Fields: + // blockName // block name + // nextWithSameName; // block no of next block with same name or -1 (blocks are backward linked in relation to template position) + // tPosBegin // template position of begin of block + // tPosContentsBegin // template pos of begin of block contents + // tPosContentsEnd // template pos of end of block contents + // tPosEnd // template position of end of block + // nestingLevel // block nesting level + // parentBlockNo // block no of parent block + // definitionIsOpen // true while $BeginBlock processed but no $EndBlock + // instances // number of instances of this block + // firstBlockInstNo // block instance no of first instance of this block or -1 + // lastBlockInstNo // block instance no of last instance of this block or -1 + // currBlockInstNo // current block instance no, used during generation of output file + // blockVarCnt // no of variables in block + // blockVarNoToVarNoMap // maps block variable numbers to variable numbers + // firstVarRefNo // variable reference no of first variable of this block or -1 +var $blockTabCnt; // no of entries used in BlockTab +var $blockNameToNoMap; // maps block names to block numbers +var $openBlocksTab; + // During parsing, this table contains the block numbers of the open parent blocks (nested outer blocks). + // Indexed by the block nesting level. +var $blockInstTab; // block instances table + // This table contains an entry for each block instance that has been added. + // Indexed by BlockInstNo. + // Fields: + // blockNo // block number + // instanceLevel // instance level of this block + // InstanceLevel is an instance counter per block. + // (In contrast to blockInstNo, which is an instance counter over the instances of all blocks) + // parentInstLevel // instance level of parent block + // nextBlockInstNo // pointer to next instance of this block or -1 + // Forward chain for instances of same block. + // blockVarTab // block instance variables +var $blockInstTabCnt; // no of entries used in BlockInstTab + +var $currentNestingLevel; // Current block nesting level during parsing. +var $templateValid; // true if a valid template is prepared +var $outputMode; // 0 = to PHP output stream, 1 = to file, 2 = to string +var $outputFileHandle; // file handle during writing of output file +var $outputError; // true when an output error occurred +var $outputString; // string buffer for the generated HTML page + +/**#@-*/ + +//--- constructor --------------------------------------------------------------------------------------------------- + +/** +* Constructs a MiniTemplator object. +* @access public +*/ +function __construct() { + $this->templateValid = false; } + +//--- template string handling -------------------------------------------------------------------------------------- + +/** +* Reads the template from a file. +* @param string $fileName name of the file that contains the template. +* @return boolean true on success, false on error. +* @access public +*/ +function readTemplateFromFile ($fileName) { + if (!$this->readFileIntoString($fileName,$s)) { + $this->triggerError ("Error while reading template file " . $fileName . "."); + return false; } + if (!$this->setTemplateString($s)) return false; + return true; } + +/** +* Assigns a new template string. +* @param string $templateString contents of the template file. +* @return boolean true on success, false on error. +* @access public +*/ +function setTemplateString ($templateString) { + $this->templateValid = false; + $this->template = $templateString; + if (!$this->parseTemplate()) return false; + $this->reset(); + $this->templateValid = true; + return true; } + +/** +* Loads the template string for a subtemplate (used for the $Include command). +* @return boolean true on success, false on error. +* @access private +*/ +function loadSubtemplate ($subtemplateName, &$s) { + $subtemplateFileName = $this->combineFileSystemPath($this->subtemplateBasePath,$subtemplateName); + if (!$this->readFileIntoString($subtemplateFileName,$s)) { + $this->triggerError ("Error while reading subtemplate file " . $subtemplateFileName . "."); + return false; } + return true; } + +//--- template parsing ---------------------------------------------------------------------------------------------- + +/** +* Parses the template. +* @return boolean true on success, false on error. +* @access private +*/ +function parseTemplate() { + $this->initParsing(); + $this->beginMainBlock(); + if (!$this->parseTemplateCommands()) return false; + $this->endMainBlock(); + if (!$this->checkBlockDefinitionsComplete()) return false; + if (!$this->parseTemplateVariables()) return false; + $this->associateVariablesWithBlocks(); + return true; } + +/** +* @access private +*/ +function initParsing() { + $this->varTab = array(); + $this->varTabCnt = 0; + $this->varNameToNoMap = array(); + $this->varRefTab = array(); + $this->varRefTabCnt = 0; + $this->blockTab = array(); + $this->blockTabCnt = 0; + $this->blockNameToNoMap = array(); + $this->openBlocksTab = array(); } + +/** +* Registers the main block. +* The main block is an implicitly defined block that covers the whole template. +* @access private +*/ +function beginMainBlock() { + $blockNo = 0; + $this->registerBlock('@@InternalMainBlock@@', $blockNo); + $bte =& $this->blockTab[$blockNo]; + $bte['tPosBegin'] = 0; + $bte['tPosContentsBegin'] = 0; + $bte['nestingLevel'] = 0; + $bte['parentBlockNo'] = -1; + $bte['definitionIsOpen'] = true; + $this->openBlocksTab[0] = $blockNo; + $this->currentNestingLevel = 1; } + +/** +* Completes the main block registration. +* @access private +*/ +function endMainBlock() { + $bte =& $this->blockTab[0]; + $bte['tPosContentsEnd'] = strlen($this->template); + $bte['tPosEnd'] = strlen($this->template); + $bte['definitionIsOpen'] = false; + $this->currentNestingLevel -= 1; } + +/** +* Parses commands within the template in the format "<!-- $command parameters -->". +* @return boolean true on success, false on error. +* @access private +*/ +function parseTemplateCommands() { + $p = 0; + while (true) { + $p0 = strpos($this->template,'<!--',$p); + if ($p0 === false) break; + $p = strpos($this->template,'-->',$p0); + if ($p === false) { + $this->triggerError ("Invalid HTML comment in template at offset $p0."); + return false; } + $p += 3; + $cmdL = substr($this->template,$p0+4,$p-$p0-7); + if (!$this->processTemplateCommand($cmdL,$p0,$p,$resumeFromStart)) + return false; + if ($resumeFromStart) $p = $p0; } + return true; } + +/** +* @return boolean true on success, false on error. +* @access private +*/ +function processTemplateCommand ($cmdL, $cmdTPosBegin, $cmdTPosEnd, &$resumeFromStart) { + $resumeFromStart = false; + $p = 0; + $cmd = ''; + if (!$this->parseWord($cmdL,$p,$cmd)) return true; + $parms = substr($cmdL,$p); + switch (strtoupper($cmd)) { + case '$BEGINBLOCK': + if (!$this->processBeginBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) + return false; + break; + case '$ENDBLOCK': + if (!$this->processEndBlockCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) + return false; + break; + case '$INCLUDE': + if (!$this->processincludeCmd($parms,$cmdTPosBegin,$cmdTPosEnd)) + return false; + $resumeFromStart = true; + break; + default: + if ($cmd[0] == '$' && !(strlen($cmd) >= 2 && $cmd[1] == '{')) { + $this->triggerError ("Unknown command \"$cmd\" in template at offset $cmdTPosBegin."); + return false; }} + return true; } + +/** +* Processes the $BeginBlock command. +* @return boolean true on success, false on error. +* @access private +*/ +function processBeginBlockCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) { + $p = 0; + if (!$this->parseWord($parms,$p,$blockName)) { + $this->triggerError ("Missing block name in \$BeginBlock command in template at offset $cmdTPosBegin."); + return false; } + if (trim(substr($parms,$p)) != '') { + $this->triggerError ("Extra parameter in \$BeginBlock command in template at offset $cmdTPosBegin."); + return false; } + $this->registerBlock ($blockName, $blockNo); + $btr =& $this->blockTab[$blockNo]; + $btr['tPosBegin'] = $cmdTPosBegin; + $btr['tPosContentsBegin'] = $cmdTPosEnd; + $btr['nestingLevel'] = $this->currentNestingLevel; + $btr['parentBlockNo'] = $this->openBlocksTab[$this->currentNestingLevel-1]; + $this->openBlocksTab[$this->currentNestingLevel] = $blockNo; + $this->currentNestingLevel += 1; + if ($this->currentNestingLevel > $this->maxNestingLevel) { + $this->triggerError ("Block nesting overflow in template at offset $cmdTPosBegin."); + return false; } + return true; } + +/** +* Processes the $EndBlock command. +* @return boolean true on success, false on error. +* @access private +*/ +function processEndBlockCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) { + $p = 0; + if (!$this->parseWord($parms,$p,$blockName)) { + $this->triggerError ("Missing block name in \$EndBlock command in template at offset $cmdTPosBegin."); + return false; } + if (trim(substr($parms,$p)) != '') { + $this->triggerError ("Extra parameter in \$EndBlock command in template at offset $cmdTPosBegin."); + return false; } + if (!$this->lookupBlockName($blockName,$blockNo)) { + $this->triggerError ("Undefined block name \"$blockName\" in \$EndBlock command in template at offset $cmdTPosBegin."); + return false; } + $this->currentNestingLevel -= 1; + $btr =& $this->blockTab[$blockNo]; + if (!$btr['definitionIsOpen']) { + $this->triggerError ("Multiple \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin."); + return false; } + if ($btr['nestingLevel'] != $this->currentNestingLevel) { + $this->triggerError ("Block nesting level mismatch at \$EndBlock command for block \"$blockName\" in template at offset $cmdTPosBegin."); + return false; } + $btr['tPosContentsEnd'] = $cmdTPosBegin; + $btr['tPosEnd'] = $cmdTPosEnd; + $btr['definitionIsOpen'] = false; + return true; } + +/** +* @access private +*/ +function registerBlock($blockName, &$blockNo) { + $blockNo = $this->blockTabCnt++; + $btr =& $this->blockTab[$blockNo]; + $btr = array(); + $btr['blockName'] = $blockName; + if (!$this->lookupBlockName($blockName,$btr['nextWithSameName'])) + $btr['nextWithSameName'] = -1; + $btr['definitionIsOpen'] = true; + $btr['instances'] = 0; + $btr['firstBlockInstNo'] = -1; + $btr['lastBlockInstNo'] = -1; + $btr['blockVarCnt'] = 0; + $btr['firstVarRefNo'] = -1; + $btr['blockVarNoToVarNoMap'] = array(); + $this->blockNameToNoMap[strtoupper($blockName)] = $blockNo; } + +/** +* Checks that all block definitions are closed. +* @return boolean true on success, false on error. +* @access private +*/ +function checkBlockDefinitionsComplete() { + for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) { + $btr =& $this->blockTab[$blockNo]; + if ($btr['definitionIsOpen']) { + $this->triggerError ("Missing \$EndBlock command in template for block " . $btr['blockName'] . "."); + return false; }} + if ($this->currentNestingLevel != 0) { + $this->triggerError ("Block nesting level error at end of template."); + return false; } + return true; } + +/** +* Processes the $Include command. +* @return boolean true on success, false on error. +* @access private +*/ +function processIncludeCmd ($parms, $cmdTPosBegin, $cmdTPosEnd) { + $p = 0; + if (!$this->parseWordOrQuotedString($parms,$p,$subtemplateName)) { + $this->triggerError ("Missing or invalid subtemplate name in \$Include command in template at offset $cmdTPosBegin."); + return false; } + if (trim(substr($parms,$p)) != '') { + $this->triggerError ("Extra parameter in \$include command in template at offset $cmdTPosBegin."); + return false; } + return $this->insertSubtemplate($subtemplateName,$cmdTPosBegin,$cmdTPosEnd); } + +/** +* Processes the $Include command. +* @return boolean true on success, false on error. +* @access private +*/ +function insertSubtemplate ($subtemplateName, $tPos1, $tPos2) { + if (strlen($this->template) > $this->maxInclTemplateSize) { + $this->triggerError ("Subtemplate include aborted because the internal template string is longer than $this->maxInclTemplateSize characters."); + return false; } + if (!$this->loadSubtemplate($subtemplateName,$subtemplate)) return false; + // (Copying the template to insert a subtemplate is a bit slow. In a future implementation of MiniTemplator, + // a table could be used that contains references to the string fragments.) + $this->template = substr($this->template,0,$tPos1) . $subtemplate . substr($this->template,$tPos2); + return true; } + +/** +* Parses variable references within the template in the format "${VarName}". +* @return boolean true on success, false on error. +* @access private +*/ +function parseTemplateVariables() { + $p = 0; + while (true) { + $p = strpos($this->template, '${', $p); + if ($p === false) break; + $p0 = $p; + $p = strpos($this->template, '}', $p); + if ($p === false) { + $this->triggerError ("Invalid variable reference in template at offset $p0."); + return false; } + $p += 1; + $varName = trim(substr($this->template, $p0+2, $p-$p0-3)); + if (strlen($varName) == 0) { + $this->triggerError ("Empty variable name in template at offset $p0."); + return false; } + $this->registerVariableReference ($varName, $p0, $p); } + return true; } + +/** +* @access private +*/ +function registerVariableReference ($varName, $tPosBegin, $tPosEnd) { + if (!$this->lookupVariableName($varName,$varNo)) + $this->registerVariable($varName,$varNo); + $varRefNo = $this->varRefTabCnt++; + $vrtr =& $this->varRefTab[$varRefNo]; + $vrtr = array(); + $vrtr['tPosBegin'] = $tPosBegin; + $vrtr['tPosEnd'] = $tPosEnd; + $vrtr['varNo'] = $varNo; } + +/** +* @access private +*/ +function registerVariable ($varName, &$varNo) { + $varNo = $this->varTabCnt++; + $vtr =& $this->varTab[$varNo]; + $vtr = array(); + $vtr['varName'] = $varName; + $vtr['varValue'] = ''; + $this->varNameToNoMap[strtoupper($varName)] = $varNo; } + +/** +* Associates variable references with blocks. +* @access private +*/ +function associateVariablesWithBlocks() { + $varRefNo = 0; + $activeBlockNo = 0; + $nextBlockNo = 1; + while ($varRefNo < $this->varRefTabCnt) { + $vrtr =& $this->varRefTab[$varRefNo]; + $varRefTPos = $vrtr['tPosBegin']; + $varNo = $vrtr['varNo']; + if ($varRefTPos >= $this->blockTab[$activeBlockNo]['tPosEnd']) { + $activeBlockNo = $this->blockTab[$activeBlockNo]['parentBlockNo']; + continue; } + if ($nextBlockNo < $this->blockTabCnt) { + if ($varRefTPos >= $this->blockTab[$nextBlockNo]['tPosBegin']) { + $activeBlockNo = $nextBlockNo; + $nextBlockNo += 1; + continue; }} + $btr =& $this->blockTab[$activeBlockNo]; + if ($varRefTPos < $btr['tPosBegin']) + $this->programLogicError(1); + $blockVarNo = $btr['blockVarCnt']++; + $btr['blockVarNoToVarNoMap'][$blockVarNo] = $varNo; + if ($btr['firstVarRefNo'] == -1) + $btr['firstVarRefNo'] = $varRefNo; + $vrtr['blockNo'] = $activeBlockNo; + $vrtr['blockVarNo'] = $blockVarNo; + $varRefNo += 1; }} + +//--- build up (template variables and blocks) ---------------------------------------------------------------------- + +/** +* Clears all variables and blocks. +* This method can be used to produce another HTML page with the same +* template. It is faster than creating another MiniTemplator object, +* because the template does not have to be parsed again. +* All variable values are cleared and all added block instances are deleted. +* @access public +*/ +function reset() { + for ($varNo=0; $varNo<$this->varTabCnt; $varNo++) + $this->varTab[$varNo]['varValue'] = ''; + for ($blockNo=0; $blockNo<$this->blockTabCnt; $blockNo++) { + $btr =& $this->blockTab[$blockNo]; + $btr['instances'] = 0; + $btr['firstBlockInstNo'] = -1; + $btr['lastBlockInstNo'] = -1; } + $this->blockInstTab = array(); + $this->blockInstTabCnt = 0; } + +/** +* Sets a template variable. +* For variables that are used in blocks, the variable value +* must be set before {@link addBlock} is called. +* @param string $variableName the name of the variable to be set. +* @param string $variableValue the new value of the variable. +* @param boolean $isOptional Specifies whether an error should be +* generated when the variable does not exist in the template. If +* $isOptional is false and the variable does not exist, an error is +* generated. +* @return boolean true on success, or false on error (e.g. when no +* variable with the specified name exists in the template and +* $isOptional is false). +* @access public +*/ +function setVariable ($variableName, $variableValue, $isOptional=false) { + if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; } + if (!$this->lookupVariableName($variableName,$varNo)) { + if ($isOptional) return true; + $this->triggerError ("Variable \"$variableName\" not defined in template."); + return false; } + $this->varTab[$varNo]['varValue'] = $variableValue; + return true; } + +/** +* Sets a template variable to an escaped string. +* This method is identical to (@link setVariable), except that +* the characters <, >, &, ' and " of variableValue are +* replaced by their corresponding HTML/XML character entity codes. +* For variables that are used in blocks, the variable value +* must be set before {@link addBlock} is called. +* @param string $variableName the name of the variable to be set. +* @param string $variableValue the new value of the variable. Special HTML/XML characters are escaped. +* @param boolean $isOptional Specifies whether an error should be +* generated when the variable does not exist in the template. If +* $isOptional is false and the variable does not exist, an error is +* generated. +* @return boolean true on success, or false on error (e.g. when no +* variable with the specified name exists in the template and +* $isOptional is false). +* @access public +*/ +function setVariableEsc ($variableName, $variableValue, $isOptional=false) { + return $this->setVariable($variableName,htmlspecialchars($variableValue,ENT_QUOTES),$isOptional); } + +/** +* Checks whether a variable with the specified name exists within the template. +* @param string $variableName the name of the variable. +* @return boolean true if the variable exists, or false when no +* variable with the specified name exists in the template. +* @access public +*/ +function variableExists ($variableName) { + if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; } + return $this->lookupVariableName($variableName,$varNo); } + +/** +* Adds an instance of a template block. +* If the block contains variables, these variables must be set +* before the block is added. +* If the block contains subblocks (nested blocks), the subblocks +* must be added before this block is added. +* If multiple blocks exist with the specified name, an instance +* is added for each block occurence. +* @param string blockName the name of the block to be added. +* @return boolean true on success, false on error (e.g. when no +* block with the specified name exists in the template). +* @access public +*/ +function addBlock($blockName) { + if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; } + if (!$this->lookupBlockName($blockName,$blockNo)) { + $this->triggerError ("Block \"$blockName\" not defined in template."); + return false; } + while ($blockNo != -1) { + $this->addBlockByNo($blockNo); + $blockNo = $this->blockTab[$blockNo]['nextWithSameName']; } + return true; } + +/** +* @access private +*/ +function addBlockByNo ($blockNo) { + $btr =& $this->blockTab[$blockNo]; + $this->registerBlockInstance ($blockInstNo); + $bitr =& $this->blockInstTab[$blockInstNo]; + if ($btr['firstBlockInstNo'] == -1) + $btr['firstBlockInstNo'] = $blockInstNo; + if ($btr['lastBlockInstNo'] != -1) + $this->blockInstTab[$btr['lastBlockInstNo']]['nextBlockInstNo'] = $blockInstNo; + // set forward pointer of chain + $btr['lastBlockInstNo'] = $blockInstNo; + $parentBlockNo = $btr['parentBlockNo']; + $blockVarCnt = $btr['blockVarCnt']; + $bitr['blockNo'] = $blockNo; + $bitr['instanceLevel'] = $btr['instances']++; + if ($parentBlockNo == -1) + $bitr['parentInstLevel'] = -1; + else + $bitr['parentInstLevel'] = $this->blockTab[$parentBlockNo]['instances']; + $bitr['nextBlockInstNo'] = -1; + $bitr['blockVarTab'] = array(); + // copy instance variables for this block + for ($blockVarNo=0; $blockVarNo<$blockVarCnt; $blockVarNo++) { + $varNo = $btr['blockVarNoToVarNoMap'][$blockVarNo]; + $bitr['blockVarTab'][$blockVarNo] = $this->varTab[$varNo]['varValue']; }} + +/** +* @access private +*/ +function registerBlockInstance (&$blockInstNo) { + $blockInstNo = $this->blockInstTabCnt++; } + +/** +* Checks whether a block with the specified name exists within the template. +* @param string $blockName the name of the block. +* @return boolean true if the block exists, or false when no +* block with the specified name exists in the template. +* @access public +*/ +function blockExists ($blockName) { + if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; } + return $this->lookupBlockName($blockName,$blockNo); } + +//--- output generation --------------------------------------------------------------------------------------------- + +/** +* Generates the HTML page and writes it to the PHP output stream. +* @return boolean true on success, false on error. +* @access public +*/ +function generateOutput () { + $this->outputMode = 0; + if (!$this->generateOutputPage()) return false; + return true; } + +/** +* Generates the HTML page and writes it to a file. +* @param string $fileName name of the output file. +* @return boolean true on success, false on error. +* @access public +*/ +function generateOutputToFile ($fileName) { + $fh = fopen($fileName,"wb"); + if ($fh === false) return false; + $this->outputMode = 1; + $this->outputFileHandle = $fh; + $ok = $this->generateOutputPage(); + fclose ($fh); + return $ok; } + +/** +* Generates the HTML page and writes it to a string. +* @param string $outputString variable that receives +* the contents of the generated HTML page. +* @return boolean true on success, false on error. +* @access public +*/ +function generateOutputToString (&$outputString) { + $outputString = "Error"; + $this->outputMode = 2; + $this->outputString = ""; + if (!$this->generateOutputPage()) return false; + $outputString = $this->outputString; + return true; } + +/** +* @access private +* @return boolean true on success, false on error. +*/ +function generateOutputPage() { + if (!$this->templateValid) {$this->triggerError ("Template not valid."); return false; } + if ($this->blockTab[0]['instances'] == 0) + $this->addBlockByNo (0); // add main block + for ($blockNo=0; $blockNo < $this->blockTabCnt; $blockNo++) { + $btr =& $this->blockTab[$blockNo]; + $btr['currBlockInstNo'] = $btr['firstBlockInstNo']; } + $this->outputError = false; + $this->writeBlockInstances (0, -1); + if ($this->outputError) return false; + return true; } + +/** +* Writes all instances of a block that are contained within a specific +* parent block instance. +* Called recursively. +* @access private +*/ +function writeBlockInstances ($blockNo, $parentInstLevel) { + $btr =& $this->blockTab[$blockNo]; + while (!$this->outputError) { + $blockInstNo = $btr['currBlockInstNo']; + if ($blockInstNo == -1) break; + $bitr =& $this->blockInstTab[$blockInstNo]; + if ($bitr['parentInstLevel'] < $parentInstLevel) + $this->programLogicError (2); + if ($bitr['parentInstLevel'] > $parentInstLevel) break; + $this->writeBlockInstance ($blockInstNo); + $btr['currBlockInstNo'] = $bitr['nextBlockInstNo']; }} + +/** +* @access private +*/ +function writeBlockInstance($blockInstNo) { + $bitr =& $this->blockInstTab[$blockInstNo]; + $blockNo = $bitr['blockNo']; + $btr =& $this->blockTab[$blockNo]; + $tPos = $btr['tPosContentsBegin']; + $subBlockNo = $blockNo + 1; + $varRefNo = $btr['firstVarRefNo']; + while (!$this->outputError) { + $tPos2 = $btr['tPosContentsEnd']; + $kind = 0; // assume end-of-block + if ($varRefNo != -1 && $varRefNo < $this->varRefTabCnt) { // check for variable reference + $vrtr =& $this->varRefTab[$varRefNo]; + if ($vrtr['tPosBegin'] < $tPos) { + $varRefNo += 1; + continue; } + if ($vrtr['tPosBegin'] < $tPos2) { + $tPos2 = $vrtr['tPosBegin']; + $kind = 1; }} + if ($subBlockNo < $this->blockTabCnt) { // check for subblock + $subBtr =& $this->blockTab[$subBlockNo]; + if ($subBtr['tPosBegin'] < $tPos) { + $subBlockNo += 1; + continue; } + if ($subBtr['tPosBegin'] < $tPos2) { + $tPos2 = $subBtr['tPosBegin']; + $kind = 2; }} + if ($tPos2 > $tPos) + $this->writeString (substr($this->template,$tPos,$tPos2-$tPos)); + switch ($kind) { + case 0: // end of block + return; + case 1: // variable + $vrtr =& $this->varRefTab[$varRefNo]; + if ($vrtr['blockNo'] != $blockNo) + $this->programLogicError (4); + $variableValue = $bitr['blockVarTab'][$vrtr['blockVarNo']]; + $this->writeString ($variableValue); + $tPos = $vrtr['tPosEnd']; + $varRefNo += 1; + break; + case 2: // sub block + $subBtr =& $this->blockTab[$subBlockNo]; + if ($subBtr['parentBlockNo'] != $blockNo) + $this->programLogicError (3); + $this->writeBlockInstances ($subBlockNo, $bitr['instanceLevel']); // recursive call + $tPos = $subBtr['tPosEnd']; + $subBlockNo += 1; + break; }}} + +/** +* @access private +*/ +function writeString ($s) { + if ($this->outputError) return; + switch ($this->outputMode) { + case 0: // output to PHP output stream + print $s; + break; + case 1: // output to file + $rc = fwrite($this->outputFileHandle, $s); + if ($rc === false) $this->outputError = true; + break; + case 2: // output to string + $this->outputString .= $s; + break; }} + +//--- name lookup routines ------------------------------------------------------------------------------------------ + +/** +* Maps variable name to variable number. +* @return boolean true on success, false if the variable is not found. +* @access private +*/ +function lookupVariableName ($varName, &$varNo) { + $x =& $this->varNameToNoMap[strtoupper($varName)]; + if (!isset($x)) return false; + $varNo = $x; + return true; } + +/** +* Maps block name to block number. +* If there are multiple blocks with the same name, the block number of the last +* registered block with that name is returned. +* @return boolean true on success, false when the block is not found. +* @access private +*/ +function lookupBlockName ($blockName, &$blockNo) { + $x =& $this->blockNameToNoMap[strtoupper($blockName)]; + if (!isset($x)) return false; + $blockNo = $x; + return true; } + +//--- general utility routines ----------------------------------------------------------------------------------------- + +/** +* Reads a file into a string. +* @return boolean true on success, false on error. +* @access private +*/ +function readFileIntoString ($fileName, &$s) { + if (function_exists('version_compare') && version_compare(phpversion(),"4.3.0",">=")) { + $s = file_get_contents($fileName); + if ($s === false) return false; + return true; } + $fh = fopen($fileName,"rb"); + if ($fh === false) return false; + $fileSize = filesize($fileName); + if ($fileSize === false) {fclose ($fh); return false; } + $s = fread($fh,$fileSize); + fclose ($fh); + if (strlen($s) != $fileSize) return false; + return true; } + +/** +* @access private +* @return boolean true on success, false when the end of the string is reached. +*/ +function parseWord ($s, &$p, &$w) { + $sLen = strlen($s); + while ($p < $sLen && ord($s[$p]) <= 32) $p++; + if ($p >= $sLen) return false; + $p0 = $p; + while ($p < $sLen && ord($s[$p]) > 32) $p++; + $w = substr($s, $p0, $p - $p0); + return true; } + +/** +* @access private +* @return boolean true on success, false on error. +*/ +function parseQuotedString ($s, &$p, &$w) { + $sLen = strlen($s); + while ($p < $sLen && ord($s[$p]) <= 32) $p++; + if ($p >= $sLen) return false; + if (substr($s,$p,1) != '"') return false; + $p++; $p0 = $p; + while ($p < $sLen && $s[$p] != '"') $p++; + if ($p >= $sLen) return false; + $w = substr($s, $p0, $p - $p0); + $p++; + return true; } + +/** +* @access private +* @return boolean true on success, false on error. +*/ +function parseWordOrQuotedString ($s, &$p, &$w) { + $sLen = strlen($s); + while ($p < $sLen && ord($s[$p]) <= 32) $p++; + if ($p >= $sLen) return false; + if (substr($s,$p,1) == '"') + return $this->parseQuotedString($s,$p,$w); + else + return $this->parseWord($s,$p,$w); } + +/** +* Combine two file system paths. +* @access private +*/ +function combineFileSystemPath ($path1, $path2) { + if ($path1 == '' || $path2 == '') return $path2; + $s = $path1; + if (substr($s,-1) != '\\' && substr($s,-1) != '/') $s = $s . "/"; + if (substr($path2,0,1) == '\\' || substr($path2,0,1) == '/') + $s = $s . substr($path2,1); + else + $s = $s . $path2; + return $s; } + +/** +* @access private +*/ +function triggerError ($msg) { + trigger_error ("MiniTemplator error: $msg", E_USER_ERROR); } + +/** +* @access private +*/ +function programLogicError ($errorId) { + die ("MiniTemplator: Program logic error $errorId.\n"); } + +} +?> diff --git a/lib/gettext/gettext.inc b/lib/gettext/gettext.inc.php index c9f7dc016..ed5be6bbd 100644 --- a/lib/gettext/gettext.inc +++ b/lib/gettext/gettext.inc.php @@ -69,10 +69,10 @@ function get_list_of_locales($locale) { * sr_CS.UTF-8@latin, sr_CS@latin, sr@latin, sr_CS.UTF-8, sr_CS, sr. */ $locale_names = array(); - $lang = NULL; - $country = NULL; - $charset = NULL; - $modifier = NULL; + $lang = null; + $country = null; + $charset = null; + $modifier = null; if ($locale) { if (preg_match("/^(?P<lang>[a-z]{2,3})" // language code ."(?:_(?P<country>[A-Z]{2}))?" // country code diff --git a/lib/gettext/gettext.php b/lib/gettext/gettext.php index edbd93304..173d4c448 100755 --- a/lib/gettext/gettext.php +++ b/lib/gettext/gettext.php @@ -21,6 +21,8 @@ */ +require('plurals.php'); + /** * Provides a simple gettext replacement that works independently from * the system's gettext abilities. @@ -39,16 +41,16 @@ class gettext_reader { //private: var $BYTEORDER = 0; // 0: low endian, 1: big endian - var $STREAM = NULL; + var $STREAM = null; var $short_circuit = false; var $enable_cache = false; - var $originals = NULL; // offset of original table - var $translations = NULL; // offset of translation table - var $pluralheader = NULL; // cache header field for plural forms + var $originals = null; // offset of original table + var $translations = null; // offset of translation table + var $pluralheader = null; // cache header field for plural forms var $total = 0; // total string count - var $table_originals = NULL; // table for original strings (offsets) - var $table_translations = NULL; // table for translated strings (offsets) - var $cache_translations = NULL; // original -> translation mapping + var $table_originals = null; // table for original strings (offsets) + var $table_translations = null; // table for translated strings (offsets) + var $cache_translations = null; // original -> translation mapping /* Methods */ @@ -270,41 +272,6 @@ class gettext_reader { } /** - * Sanitize plural form expression for use in PHP eval call. - * - * @access private - * @return string sanitized plural form expression - */ - function sanitize_plural_expression($expr) { - // Get rid of disallowed characters. - $expr = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $expr); - - // Add parenthesis for tertiary '?' operator. - $expr .= ';'; - $res = ''; - $p = 0; - for ($i = 0; $i < strlen($expr); $i++) { - $ch = $expr[$i]; - switch ($ch) { - case '?': - $res .= ' ? ('; - $p++; - break; - case ':': - $res .= ') : ('; - break; - case ';': - $res .= str_repeat( ')', $p) . ';'; - $p = 0; - break; - default: - $res .= $ch; - } - } - return $res; - } - - /** * Parse full PO header and extract only plural forms line. * * @access private @@ -327,17 +294,17 @@ class gettext_reader { function get_plural_forms() { // lets assume message number 0 is header // this is true, right? - $this->load_tables(); + $this->load_tables(); // cache header field for plural forms - if (! is_string($this->pluralheader)) { + if ($this->pluralheader === null) { if ($this->enable_cache) { $header = $this->cache_translations[""]; } else { $header = $this->get_translation_string(0); } $expr = $this->extract_plural_forms_header_from_po_header($header); - $this->pluralheader = $this->sanitize_plural_expression($expr); + $this->pluralheader = new PluralHeader($expr); } return $this->pluralheader; } @@ -353,17 +320,14 @@ class gettext_reader { if (!is_int($n)) { throw new InvalidArgumentException( "Select_string only accepts integers: " . $n); - } - $string = $this->get_plural_forms(); - $string = str_replace('nplurals',"\$total",$string); - $string = str_replace("n",$n,$string); - $string = str_replace('plural',"\$plural",$string); + } + + $plural_header = $this->get_plural_forms(); + $plural = $plural_header->expression->evaluate($n); - $total = 0; - $plural = 0; + if ($plural < 0) $plural = 0; + if ($plural >= $plural_header->total) $plural = $plural_header->total - 1; - eval("$string"); - if ($plural >= $total) $plural = $total - 1; return $plural; } @@ -387,7 +351,7 @@ class gettext_reader { // find out the appropriate form $select = $this->select_string($number); - // this should contains all strings separated by NULLs + // this should contains all strings separated by nulls $key = $single . chr(0) . $plural; diff --git a/lib/gettext/plurals.php b/lib/gettext/plurals.php new file mode 100644 index 000000000..332f5e97c --- /dev/null +++ b/lib/gettext/plurals.php @@ -0,0 +1,461 @@ +<?php +/* + Copyright (c) 2020 Sunil Mohan Adapa <sunil at medhas dot org> + + Drop in replacement for native gettext. + + This file is part of PHP-gettext. + + PHP-gettext is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + PHP-gettext is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with PHP-gettext; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +/** + * Lexical analyzer for gettext plurals expression. Takes a string to parse + * during construction and returns a single token every time peek() or + * fetch_token() are called. The special string '__END__' is returned if there + * are no more tokens to be read. Spaces are ignored during tokenization. + */ +class PluralsLexer { + private $string; + private $position; + + /** + * Constructor + * + * @param string string Contains the value gettext plurals expression to + * analyze. + */ + public function __construct(string $string) { + $this->string = $string; + $this->position = 0; + } + + /** + * Return the next token and the length to advance the read position without + * actually advancing the read position. Tokens for operators and variables + * are simple strings containing the operator or variable. If there are no + * more token to provide, the special value ['__END__', 0] is returned. If + * there was an unexpected input an Exception is raised. + * + * @access private + * @throws Exception If there is unexpected input in the provided string. + * @return array The next token and length to advance the current position. + */ + private function _tokenize() { + $buf = $this->string; + + // Consume all spaces until the next token + $index = $this->position; + while ($index < strlen($buf) && $buf[$index] == ' ') { + $index++; + } + $this->position = $index; + + // Return special token if next of the string is reached. + if (strlen($buf) - $index == 0) { + return ['__END__', 0]; + } + + // Operators with two characters + $doubles = ['==', '!=', '>=', '<=', '&&', '||']; + $next = substr($buf, $index, 2); + if (in_array($next, $doubles)) { + return [$next, 2]; + } + + // Operators with single character or variable 'n'. + $singles = [ + 'n', '(', ')', '?', ':', '+', '-', '*', '/', '%', '!', '>', '<']; + if (in_array($buf[$index], $singles)) { + return [$buf[$index], 1]; + } + + // Whole number constants, return an integer. + $digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; + $pos = $index; + while ($pos < strlen($buf) && in_array($buf[$pos], $digits)) { + $pos++; + } + if ($pos != $index) { + $length = $pos - $index; + return [(int)substr($buf, $index, $length), $length]; + } + + // Throw and exception for all other unexpected input in the string. + throw new Exception('Lexical analysis failed'); + } + + /** + * Return the next token without actually advancing the read position. + * Tokens for operators and variables are simple strings containing the + * operator or variable. If there are no more tokens to provide, the special + * value '__END__' is returned. If there was an unexpected input an + * Exception is raised. + * + * @throws Exception If there is unexpected input in the provided string. + * @return string The next token. + */ + public function peek() { + list($token, $length) = $this->_tokenize(); + return $token; + } + + /** + * Return the next token after advancing the read position. Tokens for + * operators and variables are simple strings containing the operator or + * variable. If there are no more token to provide, the special value + * '__END__' is returned. If there was an unexpected input an Exception is + * raised. + * + * @throws Exception If there is unexpected input in the provided string. + * @return string The next token. + */ + public function fetch_token() { + list($token, $length) = $this->_tokenize(); + $this->position += $length; + return $token; + } +} + +/** + * A parsed representation of the gettext plural expression. This is a tree + * containing further expressions depending on how nested the given input is. + * Calling the evaluate() function computes the value of the expression if the + * variable 'n' is set a certain value. This is used to decide which plural + * string translation to use based on the number items at hand. + */ +class PluralsExpression { + private $operator; + private $operands; + + const BINARY_OPERATORS = [ + '==', '!=', '>=', '<=', '&&', '||', '+', '-', '*', '/', '%', '>', '<']; + const UNARY_OPERATORS = ['!']; + + /** + * Constructor + * + * @param string Operator for the expression. + * @param (int|string|PuralsExpression)[] Variable number of operands of the + * expression. One int operand is expected in case the operator is 'const'. + * One string operand with value 'n' is expected in case the operator is + * 'var'. For all other operators, the operands much be objects of type + * PluralExpression. Unary operators expect one operand, binary operators + * expect two operands and trinary operators expect three operands. + */ + public function __construct($operator, ...$operands) { + $this->operator = $operator; + $this->operands = $operands; + } + + /** + * Return a parenthesized string representation of the expression for + * debugging purposes. + * + * @return string A string representation of the expression. + */ + public function to_string() { + if ($this->operator == 'const' || $this->operator == 'var') { + return $this->operands[0]; + } elseif (in_array($this->operator, self::BINARY_OPERATORS)) { + return sprintf( + "(%s %s %s)", $this->operands[0]->to_string(), $this->operator, + $this->operands[1]->to_string()); + } elseif (in_array($this->operator, self::UNARY_OPERATORS)) { + return sprintf( + "(%s %s)", $this->operator, $this->operands[0]->to_string()); + } elseif ($this->operator == '?') { + return sprintf( + "(%s ? %s : %s)", $this->operands[0]->to_string(), + $this->operands[1]->to_string(), + $this->operands[2]->to_string()); + } + } + + /** + * Return the computed value of the expression if the variable 'n' is set to + * a certain value. + * + * @param int The value of the variable n to use when evaluating. + * @throws Exception If the expression has been constructed incorrectly. + * @return int The value of the expression after evaluation. + */ + public function evaluate($n) { + if (!in_array($this->operator, ['const', 'var'])) { + $operand1 = $this->operands[0]->evaluate($n); + } + if (in_array($this->operator, self::BINARY_OPERATORS) || + $this->operator == '?') { + $operand2 = $this->operands[1]->evaluate($n); + } + if ($this->operator == '?') { + $operand3 = $this->operands[2]->evaluate($n); + } + + switch ($this->operator) { + case 'const': + return $this->operands[0]; + case 'var': + return $n; + case '!': + return !($operand1); + case '==': + return $operand1 == $operand2; + case '!=': + return $operand1 != $operand2; + case '>=': + return $operand1 >= $operand2; + case '<=': + return $operand1 <= $operand2; + case '>': + return $operand1 > $operand2; + case '<': + return $operand1 < $operand2; + case '&&': + return $operand1 && $operand2; + case '||': + return $operand1 || $operand2; + case '+': + return $operand1 + $operand2; + case '-': + return $operand1 - $operand2; + case '*': + return $operand1 * $operand2; + case '/': + return (int)($operand1 / $operand2); + case '%': + return $operand1 % $operand2; + case '?': + return $operand1 ? $operand2 : $operand3; + default: + throw new Exception('Invalid expression'); + } + } +} + +/** + * A simple operator-precedence parser for gettext plural expressions. Takes a + * string during construction and returns a PluralsExpression tree when + * parse() is called. + */ +class PluralsParser { + private $lexer; + + /* + * Operator precedence. The parsing only happens with minimum precedence of + * 0. However, ':' and ')' exist here to make sure that parsing does not + * proceed beyond them when they are not to be parsed. + */ + const PREC = [ + ':' => -1, '?' => 0, '||' => 1, '&&' => 2, '==' => 3, '!=' => 3, + '>' => 4, '<' => 4, '>=' => 4, '<=' => 4, '+' => 5, '-' => 5, '*' => 6, + '/' => 6, '%' => 6, '!' => 7, '__END__' => -1, ')' => -1 + ]; + + // List of right associative operators + const RIGHT_ASSOC = ['?']; + + /** + * Constructor + * + * @param string string the plural expression to be parsed. + */ + public function __construct(string $string) { + $this->lexer = new PluralsLexer($string); + } + + /** + * Expect a primary next for parsing and return a PluralsExpression or throw + * and exception otherwise. A primary can be the variable 'n', an whole + * number constant, a unary operator expression string with '!', or a + * parenthesis expression. + * + * @throws Exception If the next token is not a primary or if parenthesis + * expression is not closes properly with ')'. + * @return PluralsExpression That is constructed from the parsed primary. + */ + private function _parse_primary() { + $token = $this->lexer->fetch_token(); + if ($token === 'n') { + return new PluralsExpression('var', 'n'); + } elseif (is_int($token)) { + return new PluralsExpression('const', (int)$token); + } elseif ($token === '!') { + return new PluralsExpression('!', $this->_parse_primary()); + } elseif ($token === '(') { + $result = $this->_parse($this->_parse_primary(), 0); + if ($this->lexer->fetch_token() != ')') { + throw new Exception('Mismatched parenthesis'); + } + return $result; + } + + throw new Exception('Primary expected'); + } + + /** + * Fetch an operator from the lexical analyzer and test for it. Optionally + * advance the position of the lexical analyzer to next token. Raise + * exception if the token retrieved is not an operator. + * + * @access private + * @param bool peek A flag to indicate whether the position of the lexical + * analyzer should *not* be advanced. If false, the lexical analyzer is + * advanced by one token. + * @throws Exception If the token read is not an operator. + * @return string The operator that has been fetched from the lexical + * analyzer. + */ + private function _parse_operator($peek) { + if ($peek) { + $token = $this->lexer->peek(); + } else { + $token = $this->lexer->fetch_token(); + } + + if ($token !== null && !array_key_exists($token, self::PREC)) { + throw new Exception('Operator expected'); + } + return $token; + } + + /** + * A parsing method suitable for recursion. + * + * @access private + * @param ParserExpression left_side A pre-parsed left-hand side expression + * of the file expression to be constructed. This helps with recursion. + * @param int min_precedence The minimum value of precedence for the + * operators to be considered for parsing. Parsing will stop and current + * expression is returned if an operator of a lower precedence is + * encountered. + * @throws Exception If the input string does not conform to the grammar of + * the gettext plural expression. + * @return ParserExpression A complete expression after parsing. + */ + private function _parse($left_side, $min_precedence) { + $next_token = $this->_parse_operator(true); + + while (self::PREC[$next_token] >= $min_precedence) { + $operator = $this->_parse_operator(false); + $right_side = $this->_parse_primary(); + + $next_token = $this->_parse_operator(true); + + /* + * Consume (recursively) into right hand side all expressions of higher + * precedence. + */ + while ((self::PREC[$operator] < self::PREC[$next_token]) || + ((self::PREC[$operator] == self::PREC[$next_token]) && + in_array($operator, self::RIGHT_ASSOC))) { + $right_side = $this->_parse( + $right_side, self::PREC[$next_token]); + $next_token = $this->_parse_operator(true); + } + + if ($operator != '?') { + /* + * Handling for all binary operators. Consume into left hand side all + * expressions of equal precedence. + */ + $left_side = new PluralsExpression($operator, $left_side, $right_side); + } else { + // Special handling for (a ? b : c) expression + $operator = $this->lexer->fetch_token(); + if ($operator != ':') { + throw new Exception('Invalid ? expression'); + } + + $right_side2 = $this->_parse( + $this->_parse_primary(), self::PREC[$operator] + 1); + $next_token = $this->_parse_operator(true); + $left_side = new PluralsExpression( + '?', $left_side, $right_side, $right_side2); + } + } + return $left_side; + } + + /** + * A simple implementation of an operator-precedence parser. See: + * https://en.wikipedia.org/wiki/Operator-precedence_parser for an analysis + * of the algorithm. + * + * @throws Exception If the input string does not conform to the grammar of + * the gettext plural expression. + * @return ParserExpression A complete expression after parsing. + */ + public function parse() { + $expression = $this->_parse($this->_parse_primary(), 0); + // Special handling for an extra ')' at the end. + if ($this->lexer->peek() != '__END__') { + throw new Exception('Could not parse completely'); + } + return $expression; + } +} + +/** + * Provides a class to parse the value of the 'Plural-Forms:' header in the + * gettext translation files. Holds the expression tree and the number of + * plurals after parsing. Parsing happens during construction which takes as + * its only argument the string to parse. Error during parsing are silently + * suppressed and the fallback behavior is used with the value for Germanic + * languages as follows: "nplurals=2; plural=n == 1 ? 0 : 1;". + */ +class PluralHeader { + public $total; + public $expression; + + /** + * Constructor + * + * @param string The value of the Plural-Forms: header as seen in .po files. + */ + function __construct($string) { + try { + list($total, $expression) = $this->parse($string); + } catch (Exception $e) { + $string = "nplurals=2; plural=n == 1 ? 0 : 1;"; + list($total, $expression) = $this->parse($string); + } + $this->total = $total; + $this->expression = $expression; + } + + /** + * Return the number of plural forms and the parsed expression tree. + * + * @access private + * @param string string The value of the Plural-Forms: header. + * @throws Exception If the string could not be parsed. + * @return array The number of plural forms and parsed expression tree. + */ + private function parse($string) { + $regex = "/^\s*nplurals\s*=\s*(\d+)\s*;\s*plural\s*=([^;]+);/i"; + if (preg_match($regex, $string, $matches)) { + $total = (int)$matches[1]; + $expression_string = $matches[2]; + } else { + throw new Exception('Invalid header value'); + } + + $parser = new PluralsParser($expression_string); + $expression = $parser->parse(); + return [$total, $expression]; + } +} diff --git a/package.json b/package.json new file mode 100644 index 000000000..d20c66112 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "tt-rss", + "version": "1.0.0", + "description": "", + "devDependencies": { + "eslint": "^7.9.0", + "gulp": "^4.0.2", + "gulp-less": "^4.0.1", + "less": "^3.12.2" + } +} diff --git a/plugins/af_comics/filters/af_comics_cad.php b/plugins/af_comics/filters/af_comics_cad.php index d2eb38caf..5da82ae3f 100644 --- a/plugins/af_comics/filters/af_comics_cad.php +++ b/plugins/af_comics/filters/af_comics_cad.php @@ -6,14 +6,14 @@ class Af_Comics_Cad extends Af_ComicFilter { } function process(&$article) { - if (strpos($article["link"], "cad-comic.com") !== FALSE) { - if (strpos($article["title"], "News:") === FALSE) { + if (strpos($article["link"], "cad-comic.com") !== false) { + if (strpos($article["title"], "News:") === false) { global $fetch_last_error_content; $doc = new DOMDocument(); - $res = fetch_file_contents($article["link"], false, false, false, + $res = UrlHelper::fetch($article["link"], false, false, false, false, false, 0, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); diff --git a/plugins/af_comics/filters/af_comics_comicclass.php b/plugins/af_comics/filters/af_comics_comicclass.php index b4b3a962c..ff32375d3 100644 --- a/plugins/af_comics/filters/af_comics_comicclass.php +++ b/plugins/af_comics/filters/af_comics_comicclass.php @@ -6,12 +6,12 @@ class Af_Comics_ComicClass extends Af_ComicFilter { } function process(&$article) { - if (strpos($article["guid"], "loadingartist.com") !== FALSE) { + if (strpos($article["guid"], "loadingartist.com") !== false) { // lol at people who block clients by user agent // oh noes my ad revenue Q_Q - $res = fetch_file_contents($article["link"], false, false, false, + $res = UrlHelper::fetch($article["link"], false, false, false, false, false, 0, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); diff --git a/plugins/af_comics/filters/af_comics_comicpress.php b/plugins/af_comics/filters/af_comics_comicpress.php index 7755bcb1a..29b064612 100755 --- a/plugins/af_comics/filters/af_comics_comicpress.php +++ b/plugins/af_comics/filters/af_comics_comicpress.php @@ -7,18 +7,18 @@ class Af_Comics_ComicPress extends Af_ComicFilter { } function process(&$article) { - if (strpos($article["guid"], "bunicomic.com") !== FALSE || - strpos($article["guid"], "buttersafe.com") !== FALSE || - strpos($article["guid"], "extrafabulouscomics.com") !== FALSE || - strpos($article["guid"], "happyjar.com") !== FALSE || - strpos($article["guid"], "nedroid.com") !== FALSE || - strpos($article["guid"], "stonetoss.com") !== FALSE || - strpos($article["guid"], "csectioncomics.com") !== FALSE) { + if (strpos($article["guid"], "bunicomic.com") !== false || + strpos($article["guid"], "buttersafe.com") !== false || + strpos($article["guid"], "extrafabulouscomics.com") !== false || + strpos($article["guid"], "happyjar.com") !== false || + strpos($article["guid"], "nedroid.com") !== false || + strpos($article["guid"], "stonetoss.com") !== false || + strpos($article["guid"], "csectioncomics.com") !== false) { // lol at people who block clients by user agent // oh noes my ad revenue Q_Q - $res = fetch_file_contents(["url" => $article["link"], + $res = UrlHelper::fetch(["url" => $article["link"], "useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]); $doc = new DOMDocument(); @@ -37,7 +37,7 @@ class Af_Comics_ComicPress extends Af_ComicFilter { if ($webtoon_link) { - $res = fetch_file_contents(["url" => $webtoon_link->getAttribute("href"), + $res = UrlHelper::fetch(["url" => $webtoon_link->getAttribute("href"), "useragent" => "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"]); if (@$doc->loadHTML($res)) { diff --git a/plugins/af_comics/filters/af_comics_darklegacy.php b/plugins/af_comics/filters/af_comics_darklegacy.php index 0882514d0..978545431 100644 --- a/plugins/af_comics/filters/af_comics_darklegacy.php +++ b/plugins/af_comics/filters/af_comics_darklegacy.php @@ -7,9 +7,9 @@ class Af_Comics_DarkLegacy extends Af_ComicFilter { function process(&$article) { - if (strpos($article["guid"], "darklegacycomics.com") !== FALSE) { + if (strpos($article["guid"], "darklegacycomics.com") !== false) { - $res = fetch_file_contents($article["link"], false, false, false, + $res = UrlHelper::fetch($article["link"], false, false, false, false, false, 0, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); diff --git a/plugins/af_comics/filters/af_comics_dilbert.php b/plugins/af_comics/filters/af_comics_dilbert.php index a40f8a9ba..31a72d88d 100644 --- a/plugins/af_comics/filters/af_comics_dilbert.php +++ b/plugins/af_comics/filters/af_comics_dilbert.php @@ -7,10 +7,10 @@ class Af_Comics_Dilbert extends Af_ComicFilter { } function process(&$article) { - if (strpos($article["link"], "dilbert.com") !== FALSE || - strpos($article["link"], "/DilbertDailyStrip") !== FALSE) { + if (strpos($article["link"], "dilbert.com") !== false || + strpos($article["link"], "/DilbertDailyStrip") !== false) { - $res = fetch_file_contents($article["link"], false, false, false, + $res = UrlHelper::fetch($article["link"], false, false, false, false, false, 0, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0"); diff --git a/plugins/af_comics/filters/af_comics_explosm.php b/plugins/af_comics/filters/af_comics_explosm.php index c47014da4..bfe38e53b 100644 --- a/plugins/af_comics/filters/af_comics_explosm.php +++ b/plugins/af_comics/filters/af_comics_explosm.php @@ -7,11 +7,11 @@ class Af_Comics_Explosm extends Af_ComicFilter { function process(&$article) { - if (strpos($article["link"], "explosm.net/comics") !== FALSE) { + if (strpos($article["link"], "explosm.net/comics") !== false) { $doc = new DOMDocument(); - if (@$doc->loadHTML(fetch_file_contents($article["link"]))) { + if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) { $xpath = new DOMXPath($doc); $basenode = $xpath->query('(//img[@id="main-comic"])')->item(0); diff --git a/plugins/af_comics/filters/af_comics_gocomics.php b/plugins/af_comics/filters/af_comics_gocomics.php index 791dc07d3..949b7a235 100644 --- a/plugins/af_comics/filters/af_comics_gocomics.php +++ b/plugins/af_comics/filters/af_comics_gocomics.php @@ -29,15 +29,13 @@ class Af_Comics_Gocomics extends Af_ComicFilter { $article_link = $site_url . date('/Y/m/d'); - $body = fetch_file_contents(array('url' => $article_link, 'type' => 'text/html', 'followlocation' => false)); - - require_once 'lib/MiniTemplator.class.php'; + $body = UrlHelper::fetch(array('url' => $article_link, 'type' => 'text/html', 'followlocation' => false)); $feed_title = htmlspecialchars($comic[1]); $site_url = htmlspecialchars($site_url); $article_link = htmlspecialchars($article_link); - $tpl = new MiniTemplator(); + $tpl = new Templator(); $tpl->readTemplateFromFile('templates/generated_feed.txt'); diff --git a/plugins/af_comics/filters/af_comics_gocomics_farside.php b/plugins/af_comics/filters/af_comics_gocomics_farside.php index 783907e17..9663da8f9 100644 --- a/plugins/af_comics/filters/af_comics_gocomics_farside.php +++ b/plugins/af_comics/filters/af_comics_gocomics_farside.php @@ -25,11 +25,10 @@ class Af_Comics_Gocomics_FarSide extends Af_ComicFilter { public function on_fetch($url) { if (preg_match("#^https?://www\.thefarside\.com#", $url)) { - require_once 'lib/MiniTemplator.class.php'; $article_link = htmlspecialchars("https://www.thefarside.com" . date('/Y/m/d')); - $tpl = new MiniTemplator(); + $tpl = new Templator(); $tpl->readTemplateFromFile('templates/generated_feed.txt'); @@ -38,7 +37,7 @@ class Af_Comics_Gocomics_FarSide extends Af_ComicFilter { $tpl->setVariable('FEED_URL', htmlspecialchars($url), true); $tpl->setVariable('SELF_URL', htmlspecialchars($url), true); - $body = fetch_file_contents(['url' => $article_link, 'type' => 'text/html', 'followlocation' => false]); + $body = UrlHelper::fetch(['url' => $article_link, 'type' => 'text/html', 'followlocation' => false]); if ($body) { $doc = new DOMDocument(); diff --git a/plugins/af_comics/filters/af_comics_pa.php b/plugins/af_comics/filters/af_comics_pa.php index 7a60feabb..380e84596 100644 --- a/plugins/af_comics/filters/af_comics_pa.php +++ b/plugins/af_comics/filters/af_comics_pa.php @@ -6,11 +6,11 @@ class Af_Comics_Pa extends Af_ComicFilter { } function process(&$article) { - if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "Comic:") !== FALSE) { + if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "Comic:") !== false) { $doc = new DOMDocument(); - if ($doc->loadHTML(fetch_file_contents($article["link"]))) { + if ($doc->loadHTML(UrlHelper::fetch($article["link"]))) { $xpath = new DOMXPath($doc); $basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0); @@ -22,10 +22,10 @@ class Af_Comics_Pa extends Af_ComicFilter { return true; } - if (strpos($article["link"], "penny-arcade.com") !== FALSE && strpos($article["title"], "News Post:") !== FALSE) { + if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "News Post:") !== false) { $doc = new DOMDocument(); - if ($doc->loadHTML(fetch_file_contents($article["link"]))) { + if ($doc->loadHTML(UrlHelper::fetch($article["link"]))) { $xpath = new DOMXPath($doc); $entries = $xpath->query('(//div[@class="post"])'); diff --git a/plugins/af_comics/filters/af_comics_pvp.php b/plugins/af_comics/filters/af_comics_pvp.php index cf0b79d78..105d3f490 100644 --- a/plugins/af_comics/filters/af_comics_pvp.php +++ b/plugins/af_comics/filters/af_comics_pvp.php @@ -6,9 +6,9 @@ class Af_Comics_Pvp extends Af_ComicFilter { } function process(&$article) { - if (strpos($article["guid"], "pvponline.com") !== FALSE) { + if (strpos($article["guid"], "pvponline.com") !== false) { - $res = fetch_file_contents($article["link"], false, false, false, + $res = UrlHelper::fetch($article["link"], false, false, false, false, false, 0, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); diff --git a/plugins/af_comics/filters/af_comics_tfd.php b/plugins/af_comics/filters/af_comics_tfd.php index 376ec0714..e0216705c 100644 --- a/plugins/af_comics/filters/af_comics_tfd.php +++ b/plugins/af_comics/filters/af_comics_tfd.php @@ -6,9 +6,9 @@ class Af_Comics_Tfd extends Af_ComicFilter { } function process(&$article) { - if (strpos($article["link"], "toothpastefordinner.com") !== FALSE || - strpos($article["link"], "marriedtothesea.com") !== FALSE) { - $res = fetch_file_contents($article["link"], false, false, false, + if (strpos($article["link"], "toothpastefordinner.com") !== false || + strpos($article["link"], "marriedtothesea.com") !== false) { + $res = UrlHelper::fetch($article["link"], false, false, false, false, false, 0, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); @@ -16,7 +16,7 @@ class Af_Comics_Tfd extends Af_ComicFilter { $doc = new DOMDocument(); - if (@$doc->loadHTML(fetch_file_contents($article["link"]))) { + if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) { $xpath = new DOMXPath($doc); $basenode = $xpath->query('//img[contains(@src, ".gif")]')->item(0); diff --git a/plugins/af_comics/filters/af_comics_twp.php b/plugins/af_comics/filters/af_comics_twp.php index f53b89b63..38a8ca32b 100644 --- a/plugins/af_comics/filters/af_comics_twp.php +++ b/plugins/af_comics/filters/af_comics_twp.php @@ -7,11 +7,11 @@ class Af_Comics_Twp extends Af_ComicFilter { function process(&$article) { - if (strpos($article["link"], "threewordphrase.com") !== FALSE) { + if (strpos($article["link"], "threewordphrase.com") !== false) { $doc = new DOMDocument(); - if (@$doc->loadHTML(fetch_file_contents($article["link"]))) { + if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) { $xpath = new DOMXpath($doc); $basenode = $xpath->query("//td/center/img")->item(0); diff --git a/plugins/af_comics/filters/af_comics_whomp.php b/plugins/af_comics/filters/af_comics_whomp.php index d574bf5d3..021a2952a 100644 --- a/plugins/af_comics/filters/af_comics_whomp.php +++ b/plugins/af_comics/filters/af_comics_whomp.php @@ -6,9 +6,9 @@ class Af_Comics_Whomp extends Af_ComicFilter { } function process(&$article) { - if (strpos($article["guid"], "whompcomic.com") !== FALSE) { + if (strpos($article["guid"], "whompcomic.com") !== false) { - $res = fetch_file_contents($article["link"], false, false, false, + $res = UrlHelper::fetch($article["link"], false, false, false, false, false, 0, "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"); diff --git a/plugins/af_comics/init.php b/plugins/af_comics/init.php index d07220894..c99d4b1d8 100755 --- a/plugins/af_comics/init.php +++ b/plugins/af_comics/init.php @@ -27,7 +27,7 @@ class Af_Comics extends Plugin { foreach ($filters as $file) { $filter_name = preg_replace("/\..*$/", "", basename($file)); - if (array_search($filter_name, $names) === FALSE) { + if (array_search($filter_name, $names) === false) { if (!class_exists($filter_name)) { require_once $file; } diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php index 80100160d..2d9ae59b5 100644 --- a/plugins/af_proxy_http/init.php +++ b/plugins/af_proxy_http/init.php @@ -28,6 +28,9 @@ class Af_Proxy_Http extends Plugin { $host->add_hook($host::HOOK_ENCLOSURE_ENTRY, $this); $host->add_hook($host::HOOK_PREFS_TAB, $this); + + if (!$_SESSION['af_proxy_http_token']) + $_SESSION['af_proxy_http_token'] = bin2hex(get_random_bytes(16)); } function hook_enclosure_entry($enc) { @@ -45,11 +48,10 @@ class Af_Proxy_Http extends Plugin { } public function imgproxy() { - - $url = rewrite_relative_url(get_self_url_prefix(), $_REQUEST["url"]); + $url = UrlHelper::validate(clean($_REQUEST["url"])); // called without user context, let's just redirect to original URL - if (!$_SESSION["uid"]) { + if (!$_SESSION["uid"] || $_REQUEST['af_proxy_http_token'] != $_SESSION['af_proxy_http_token']) { header("Location: $url"); return; } @@ -59,22 +61,14 @@ class Af_Proxy_Http extends Plugin { if ($this->cache->exists($local_filename)) { header("Location: " . $this->cache->getUrl($local_filename)); return; - //$this->cache->send($local_filename); } else { - $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); + $data = UrlHelper::fetch(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); if ($data) { - - $disable_cache = $this->host->get($this, "disable_cache"); - - if (!$disable_cache) { - if ($this->cache->put($local_filename, $data)) { - header("Location: " . $this->cache->getUrl($local_filename)); - return; - } + if ($this->cache->put($local_filename, $data)) { + header("Location: " . $this->cache->getUrl($local_filename)); + return; } - - print $data; } else { global $fetch_last_error; global $fetch_last_error_code; @@ -97,14 +91,13 @@ class Af_Proxy_Http extends Plugin { imagedestroy($img); } else { - header("Content-type: text/html"); + header("Content-type: text/plain"); http_response_code(400); - print "<h1>Proxy request failed.</h1>"; - print "<p>Fetch error $fetch_last_error ($fetch_last_error_code)</p>"; - print "<p>URL: $url</p>"; - print "<textarea cols='80' rows='25'>" . htmlspecialchars($fetch_last_error_content) . "</textarea>"; + print "Proxy request failed.\n". + "Fetch error $fetch_last_error ($fetch_last_error_code)\n". + "Requested URL: $url"; } } } @@ -132,7 +125,7 @@ class Af_Proxy_Http extends Plugin { foreach (explode(" " , $this->ssl_known_whitelist) as $host) { if (substr(strtolower($parts['host']), -strlen($host)) === strtolower($host)) { $parts['scheme'] = 'https'; - $url = build_url($parts); + $url = UrlHelper::build_url($parts); if ($all_remote && $is_remote) { break; } else { @@ -141,7 +134,8 @@ class Af_Proxy_Http extends Plugin { } } - return $this->host->get_public_method_url($this, "imgproxy", ["url" => $url]); + return $this->host->get_public_method_url($this, "imgproxy", + ["url" => $url, "af_proxy_http_token" => $_SESSION["af_proxy_http_token"]]); } } } @@ -208,7 +202,7 @@ class Af_Proxy_Http extends Plugin { function hook_prefs_tab($args) { if ($args != "prefFeeds") return; - print "<div dojoType=\"dijit.layout.AccordionPane\" + print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"<i class='material-icons'>extension</i> ".__('Image proxy settings (af_proxy_http)')."\">"; print "<form dojoType=\"dijit.form.Form\">"; @@ -235,10 +229,6 @@ class Af_Proxy_Http extends Plugin { print_checkbox("proxy_all", $proxy_all); print " <label for=\"proxy_all\">" . __("Enable proxy for all remote images.") . "</label><br/>"; - $disable_cache = $this->host->get($this, "disable_cache"); - print_checkbox("disable_cache", $disable_cache); - print " <label for=\"disable_cache\">" . __("Don't cache files locally.") . "</label>"; - print "<p>"; print_button("submit", __("Save")); print "</form>"; @@ -248,10 +238,8 @@ class Af_Proxy_Http extends Plugin { function save() { $proxy_all = checkbox_to_sql_bool($_POST["proxy_all"]); - $disable_cache = checkbox_to_sql_bool($_POST["disable_cache"]); $this->host->set($this, "proxy_all", $proxy_all, false); - $this->host->set($this, "disable_cache", $disable_cache); echo __("Configuration saved"); } diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index dbc99cfe4..20e3981ce 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -98,7 +98,7 @@ class Af_Psql_Trgm extends Plugin { print "</div>"; - print "<div style='text-align : right' class='text-muted'>" . smart_date_time(strtotime($line["updated"])) . "</div>"; + print "<div style='text-align : right' class='text-muted'>" . TimeHelper::smart_date_time(strtotime($line["updated"])) . "</div>"; print "</li>"; } @@ -123,7 +123,7 @@ class Af_Psql_Trgm extends Plugin { function hook_prefs_tab($args) { if ($args != "prefFeeds") return; - print "<div dojoType=\"dijit.layout.AccordionPane\" + print "<div dojoType=\"dijit.layout.AccordionPane\" title=\"<i class='material-icons'>extension</i> ".__('Mark similar articles as read')."\">"; if (DB_TYPE != "pgsql") { @@ -228,7 +228,7 @@ class Af_Psql_Trgm extends Plugin { if (!array($enabled_feeds)) $enabled_feeds = array(); $key = array_search($feed_id, $enabled_feeds); - $checked = $key !== FALSE ? "checked" : ""; + $checked = $key !== false ? "checked" : ""; print "<fieldset>"; @@ -248,11 +248,11 @@ class Af_Psql_Trgm extends Plugin { $key = array_search($feed_id, $enabled_feeds); if ($enable) { - if ($key === FALSE) { + if ($key === false) { array_push($enabled_feeds, $feed_id); } } else { - if ($key !== FALSE) { + if ($key !== false) { unset($enabled_feeds[$key]); } } @@ -272,7 +272,7 @@ class Af_Psql_Trgm extends Plugin { if (!$enable_globally) { $enabled_feeds = $this->host->get($this, "enabled_feeds"); $key = array_search($article["feed"]["id"], $enabled_feeds); - if ($key === FALSE) return $article; + if ($key === false) return $article; } $similarity = (float) $this->host->get($this, "similarity"); diff --git a/plugins/af_readability/init.js b/plugins/af_readability/init.js index 644dff9fe..3155475cc 100644 --- a/plugins/af_readability/init.js +++ b/plugins/af_readability/init.js @@ -9,7 +9,7 @@ Plugins.Af_Readability = { content.innerHTML = content.getAttribute(self.orig_attr_name); content.removeAttribute(self.orig_attr_name); - if (App.isCombinedMode()) Article.cdmScrollToId(id); + if (App.isCombinedMode()) Article.cdmMoveToId(id); return; } @@ -23,7 +23,7 @@ Plugins.Af_Readability = { content.innerHTML = reply.content; Notify.close(); - if (App.isCombinedMode()) Article.cdmScrollToId(id); + if (App.isCombinedMode()) Article.cdmMoveToId(id); } else { Notify.error("Unable to fetch full text for this article"); diff --git a/plugins/af_readability/init.php b/plugins/af_readability/init.php index 9c62a4772..111462c4b 100755 --- a/plugins/af_readability/init.php +++ b/plugins/af_readability/init.php @@ -133,7 +133,7 @@ class Af_Readability extends Plugin { if (!is_array($enabled_feeds)) $enabled_feeds = array(); $key = array_search($feed_id, $enabled_feeds); - $checked = $key !== FALSE ? "checked" : ""; + $checked = $key !== false ? "checked" : ""; print "<fieldset>"; @@ -153,11 +153,11 @@ class Af_Readability extends Plugin { $key = array_search($feed_id, $enabled_feeds); if ($enable) { - if ($key === FALSE) { + if ($key === false) { array_push($enabled_feeds, $feed_id); } } else { - if ($key !== FALSE) { + if ($key !== false) { unset($enabled_feeds[$key]); } } @@ -176,7 +176,7 @@ class Af_Readability extends Plugin { global $fetch_effective_url; - $tmp = fetch_file_contents([ + $tmp = UrlHelper::fetch([ "url" => $url, "http_accept" => "text/*", "type" => "text/html"]); @@ -235,7 +235,7 @@ class Af_Readability extends Plugin { $extracted_content = $this->extract_content($article["link"]); # let's see if there's anything of value in there - $content_test = trim(strip_tags(sanitize($extracted_content))); + $content_test = trim(strip_tags(Sanitizer::sanitize($extracted_content))); if ($content_test) { $article["content"] = $extracted_content; @@ -250,7 +250,7 @@ class Af_Readability extends Plugin { if (!is_array($enabled_feeds)) return $article; $key = array_search($article["feed"]["id"], $enabled_feeds); - if ($key === FALSE) return $article; + if ($key === false) return $article; return $this->process_article($article); @@ -264,7 +264,7 @@ class Af_Readability extends Plugin { $extracted_content = $this->extract_content($link); # let's see if there's anything of value in there - $content_test = trim(strip_tags(sanitize($extracted_content))); + $content_test = trim(strip_tags(Sanitizer::sanitize($extracted_content))); if ($content_test) { return $extracted_content; @@ -303,7 +303,7 @@ class Af_Readability extends Plugin { $ret = []; if ($row = $sth->fetch()) { - $ret["content"] = sanitize($this->extract_content($row["link"])); + $ret["content"] = Sanitizer::sanitize($this->extract_content($row["link"])); } print json_encode($ret); diff --git a/plugins/af_redditimgur/init.php b/plugins/af_redditimgur/init.php index d28e072f4..2c213c10b 100755 --- a/plugins/af_redditimgur/init.php +++ b/plugins/af_redditimgur/init.php @@ -94,7 +94,7 @@ class Af_RedditImgur extends Plugin { //$debug = 1; foreach ($entries as $entry) { - if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === FALSE) { + if ($entry->hasAttribute("href") && strpos($entry->getAttribute("href"), "reddit.com") === false) { Debug::log("processing href: " . $entry->getAttribute("href"), Debug::$LOG_VERBOSE); @@ -103,7 +103,7 @@ class Af_RedditImgur extends Plugin { if (!$found && preg_match("/^https?:\/\/twitter.com\/(.*?)\/status\/(.*)/", $entry->getAttribute("href"), $matches)) { Debug::log("handling as twitter: " . $matches[1] . " " . $matches[2], Debug::$LOG_VERBOSE); - $oembed_result = fetch_file_contents("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href"))); + $oembed_result = UrlHelper::fetch("https://publish.twitter.com/oembed?url=" . urlencode($entry->getAttribute("href"))); if ($oembed_result) { $oembed_result = json_decode($oembed_result, true); @@ -140,7 +140,7 @@ class Af_RedditImgur extends Plugin { $content_type = $this->get_content_type($source_stream); - if (strpos($content_type, "video/") !== FALSE) { + if (strpos($content_type, "video/") !== false) { $this->handle_as_video($doc, $entry, $source_stream, $poster_url); $found = 1; } @@ -165,7 +165,7 @@ class Af_RedditImgur extends Plugin { $source_stream = false; if ($source_article_url) { - $j = json_decode(fetch_file_contents($source_article_url.".json"), true); + $j = json_decode(UrlHelper::fetch($source_article_url.".json"), true); if ($j) { foreach ($j as $listing) { @@ -195,7 +195,7 @@ class Af_RedditImgur extends Plugin { Debug::log("Handling as Streamable", Debug::$LOG_VERBOSE); - $tmp = fetch_file_contents($entry->getAttribute("href")); + $tmp = UrlHelper::fetch($entry->getAttribute("href")); if ($tmp) { $tmpdoc = new DOMDocument(); @@ -230,7 +230,7 @@ class Af_RedditImgur extends Plugin { $source_stream = str_replace(".gifv", ".mp4", $entry->getAttribute("href")); - if (strpos($source_stream, "imgur.com") !== FALSE) + if (strpos($source_stream, "imgur.com") !== false) $poster_url = str_replace(".mp4", "h.jpg", $source_stream); $this->handle_as_video($doc, $entry, $source_stream, $poster_url); @@ -265,8 +265,8 @@ class Af_RedditImgur extends Plugin { } if (!$found && (preg_match("/\.(jpg|jpeg|gif|png)(\?[0-9][0-9]*)?[$\?]/i", $entry->getAttribute("href")) || - mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== FALSE || - mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== FALSE)) { + mb_strpos($entry->getAttribute("href"), "i.reddituploads.com") !== false || + mb_strpos($this->get_content_type($entry->getAttribute("href")), "image/") !== false)) { Debug::log("Handling as a picture", Debug::$LOG_VERBOSE); @@ -285,7 +285,7 @@ class Af_RedditImgur extends Plugin { Debug::log("handling as imgur page/whatever", Debug::$LOG_VERBOSE); - $content = fetch_file_contents(["url" => $entry->getAttribute("href"), + $content = UrlHelper::fetch(["url" => $entry->getAttribute("href"), "http_accept" => "text/*"]); if ($content) { @@ -331,7 +331,7 @@ class Af_RedditImgur extends Plugin { if (!$found) { Debug::log("looking for meta og:image", Debug::$LOG_VERBOSE); - $content = fetch_file_contents(["url" => $entry->getAttribute("href"), + $content = UrlHelper::fetch(["url" => $entry->getAttribute("href"), "http_accept" => "text/*"]); if ($content) { @@ -393,7 +393,7 @@ class Af_RedditImgur extends Plugin { function hook_article_filter($article) { - if (strpos($article["link"], "reddit.com/r/") !== FALSE) { + if (strpos($article["link"], "reddit.com/r/") !== false) { $doc = new DOMDocument(); @$doc->loadHTML($article["content"]); $xpath = new DOMXPath($doc); @@ -437,6 +437,7 @@ class Af_RedditImgur extends Plugin { if ($node && $found) { $article["content"] = $doc->saveHTML($node); + $article["enclosures"] = []; } else if ($content_link) { $article = $this->readability($article, $content_link->getAttribute("href"), $doc, $xpath); } @@ -470,11 +471,11 @@ class Af_RedditImgur extends Plugin { $entry->parentNode->insertBefore($video, $entry); $entry->parentNode->insertBefore($br, $entry); - $img = $doc->createElement('img'); + /*$img = $doc->createElement('img'); $img->setAttribute("src", "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D"); - $entry->parentNode->insertBefore($img, $entry); + $entry->parentNode->insertBefore($img, $entry);*/ } function testurl() { @@ -542,7 +543,7 @@ class Af_RedditImgur extends Plugin { // do not try to embed posts linking back to other reddit posts // readability.php requires PHP 5.6 - if ($url && strpos($url, "reddit.com") === FALSE && version_compare(PHP_VERSION, '5.6.0', '>=')) { + if ($url && strpos($url, "reddit.com") === false && version_compare(PHP_VERSION, '5.6.0', '>=')) { /* link may lead to a huge video file or whatever, we need to check content type before trying to parse it which p much requires curl */ @@ -550,7 +551,7 @@ class Af_RedditImgur extends Plugin { $useragent_compat = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"; $content_type = $this->get_content_type($url, $useragent_compat); - if ($content_type && strpos($content_type, "text/html") !== FALSE) { + if ($content_type && strpos($content_type, "text/html") !== false) { foreach ($this->host->get_hooks(PluginHost::HOOK_GET_FULL_TEXT) as $p) { $extracted_content = $p->hook_get_full_text($url); diff --git a/plugins/af_unburn/init.php b/plugins/af_unburn/init.php index bfd0f66e1..d867e83be 100755 --- a/plugins/af_unburn/init.php +++ b/plugins/af_unburn/init.php @@ -24,9 +24,9 @@ class Af_Unburn extends Plugin { if (defined('NO_CURL') || !function_exists("curl_init") || ini_get("open_basedir")) return $article; - if ((strpos($article["link"], "feedproxy.google.com") !== FALSE || - strpos($article["link"], "/~r/") !== FALSE || - strpos($article["link"], "feedsportal.com") !== FALSE)) { + if ((strpos($article["link"], "feedproxy.google.com") !== false || + strpos($article["link"], "/~r/") !== false || + strpos($article["link"], "feedsportal.com") !== false)) { $ch = curl_init($article["link"]); @@ -52,7 +52,7 @@ class Af_Unburn extends Plugin { $query = parse_url($real_url, PHP_URL_QUERY); - if ($query && strpos($query, "utm_source") !== FALSE) { + if ($query && strpos($query, "utm_source") !== false) { $args = array(); parse_str($query, $args); diff --git a/plugins/auth_internal/init.php b/plugins/auth_internal/init.php index 8dbc37fb3..0ad3e9436 100644 --- a/plugins/auth_internal/init.php +++ b/plugins/auth_internal/init.php @@ -22,7 +22,7 @@ class Auth_Internal extends Plugin implements IAuthModule { $pwd_hash1 = encrypt_password($password); $pwd_hash2 = encrypt_password($password, $login); - $otp = $_REQUEST["otp"]; + $otp = (int)$_REQUEST["otp"]; if (get_schema_version() > 96) { @@ -52,7 +52,7 @@ class Auth_Internal extends Plugin implements IAuthModule { $totp_legacy = new \OTPHP\TOTP($secret_legacy); $otp_check_legacy = $totp_legacy->now(); - if ($otp != $otp_check && $otp != $otp_check_legacy) { + if ($otp !== $otp_check && $otp !== $otp_check_legacy) { return false; } } else { @@ -235,11 +235,9 @@ class Auth_Internal extends Plugin implements IAuthModule { if ($row = $sth->fetch()) { $mailer = new Mailer(); - require_once "lib/MiniTemplator.class.php"; + $tpl = new Templator(); - $tpl = new MiniTemplator; - - $tpl->readTemplateFromFile("templates/password_change_template.txt"); + $tpl->readTemplateFromFile("password_change_template.txt"); $tpl->setVariable('LOGIN', $row["login"]); $tpl->setVariable('TTRSS_HOST', SELF_URL_PATH); @@ -262,8 +260,8 @@ class Auth_Internal extends Plugin implements IAuthModule { } private function check_app_password($login, $password, $service) { - $sth = $this->pdo->prepare("SELECT p.id, p.pwd_hash, u.id AS uid - FROM ttrss_app_passwords p, ttrss_users u + $sth = $this->pdo->prepare("SELECT p.id, p.pwd_hash, u.id AS uid + FROM ttrss_app_passwords p, ttrss_users u WHERE p.owner_uid = u.id AND u.login = ? AND service = ?"); $sth->execute([$login, $service]); diff --git a/plugins/cache_starred_images/init.php b/plugins/cache_starred_images/init.php index ae369f56e..5fe963e32 100755 --- a/plugins/cache_starred_images/init.php +++ b/plugins/cache_starred_images/init.php @@ -40,16 +40,16 @@ class Cache_Starred_Images extends Plugin { Debug::log("caching media of starred articles for user " . $this->host->get_owner_uid() . "..."); - $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title, + $sth = $this->pdo->prepare("SELECT content, ttrss_entries.title, ttrss_user_entries.owner_uid, link, site_url, ttrss_entries.id, plugin_data FROM ttrss_entries, ttrss_user_entries LEFT JOIN ttrss_feeds ON (ttrss_user_entries.feed_id = ttrss_feeds.id) WHERE ref_id = ttrss_entries.id AND marked = true AND - site_url != '' AND + site_url != '' AND ttrss_user_entries.owner_uid = ? AND plugin_data NOT LIKE '%starred_cache_images%' - ORDER BY ".sql_random_function()." LIMIT 100"); + ORDER BY ".Db::sql_random_function()." LIMIT 100"); if ($sth->execute([$this->host->get_owner_uid()])) { @@ -139,7 +139,7 @@ class Cache_Starred_Images extends Plugin { if (!$this->cache->exists($local_filename)) { Debug::log("cache_images: downloading: $url to $local_filename", Debug::$LOG_VERBOSE); - $data = fetch_file_contents(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); + $data = UrlHelper::fetch(["url" => $url, "max_size" => MAX_CACHE_FILE_SIZE]); if ($data) return $this->cache->put($local_filename, $data);; diff --git a/plugins/hotkeys_force_top/init.js b/plugins/hotkeys_force_top/init.js new file mode 100644 index 000000000..8d6280fc9 --- /dev/null +++ b/plugins/hotkeys_force_top/init.js @@ -0,0 +1,6 @@ +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { + ready(function () { + Headlines.default_force_to_top = true; + }); +}); + diff --git a/plugins/hotkeys_force_top/init.php b/plugins/hotkeys_force_top/init.php new file mode 100644 index 000000000..faddc9148 --- /dev/null +++ b/plugins/hotkeys_force_top/init.php @@ -0,0 +1,24 @@ +<?php +class Hotkeys_Force_Top extends Plugin { + private $host; + + function about() { + return array(1.0, + "Force open article to the top", + "itsamenathan"); + } + + function init($host) { + $this->host = $host; + + } + + function get_js() { + return file_get_contents(__DIR__ . "/init.js"); + } + + function api_version() { + return 2; + } + +} diff --git a/plugins/hotkeys_noscroll/init.php b/plugins/hotkeys_noscroll/init.php index 2038997f5..b31ee92ae 100644 --- a/plugins/hotkeys_noscroll/init.php +++ b/plugins/hotkeys_noscroll/init.php @@ -4,7 +4,7 @@ class Hotkeys_Noscroll extends Plugin { function about() { return array(1.0, - "n/p hotkeys move between articles without scrolling", + "n/p (and up/down) hotkeys move between articles without scrolling", "fox"); } diff --git a/plugins/swap_jk/init.php b/plugins/hotkeys_swap_jk/init.php index d85149ef3..b1e3dbe04 100644 --- a/plugins/swap_jk/init.php +++ b/plugins/hotkeys_swap_jk/init.php @@ -1,5 +1,5 @@ <?php -class Swap_JK extends Plugin { +class Hotkeys_Swap_JK extends Plugin { private $host; @@ -27,4 +27,4 @@ class Swap_JK extends Plugin { return 2; } -}
\ No newline at end of file +} diff --git a/plugins/mail/init.php b/plugins/mail/init.php index e85053566..40d147fc9 100644 --- a/plugins/mail/init.php +++ b/plugins/mail/init.php @@ -92,18 +92,20 @@ class Mail extends Plugin { if ($row = $sth->fetch()) { $user_email = htmlspecialchars($row['email']); $user_name = htmlspecialchars($row['full_name']); + } else { + $user_name = ""; + $user_email = ""; } - if (!$user_name) $user_name = $_SESSION['name']; + if (!$user_name) + $user_name = $_SESSION['name']; print_hidden("from_email", "$user_email"); print_hidden("from_name", "$user_name"); - require_once "lib/MiniTemplator.class.php"; - - $tpl = new MiniTemplator; + $tpl = new Templator(); - $tpl->readTemplateFromFile("templates/email_article_template.txt"); + $tpl->readTemplateFromFile("email_article_template.txt"); $tpl->setVariable('USER_NAME', $_SESSION["name"], true); $tpl->setVariable('USER_EMAIL', $user_email, true); @@ -116,6 +118,8 @@ class Mail extends Plugin { if (count($ids) > 1) { $subject = __("[Forwarded]") . " " . __("Multiple articles"); + } else { + $subject = ""; } while ($line = $sth->fetch()) { diff --git a/plugins/mailto/init.php b/plugins/mailto/init.php index 421d5fd59..390984b71 100644 --- a/plugins/mailto/init.php +++ b/plugins/mailto/init.php @@ -29,11 +29,9 @@ class MailTo extends Plugin { $ids = explode(",", $_REQUEST['param']); $ids_qmarks = arr_qmarks($ids); - require_once "lib/MiniTemplator.class.php"; + $tpl = new Templator(); - $tpl = new MiniTemplator; - - $tpl->readTemplateFromFile("templates/email_article_template.txt"); + $tpl->readTemplateFromFile("email_article_template.txt"); $tpl->setVariable('USER_NAME', $_SESSION["name"], true); //$tpl->setVariable('USER_EMAIL', $user_email, true); diff --git a/plugins/no_iframes/init.php b/plugins/no_iframes/init.php index 18cc3ba17..9711eeb24 100644 --- a/plugins/no_iframes/init.php +++ b/plugins/no_iframes/init.php @@ -23,7 +23,7 @@ class No_Iframes extends Plugin { $entries = $xpath->query('//iframe'); foreach ($entries as $entry) { - if (!iframe_whitelisted($entry)) + if (!Sanitizer::iframe_whitelisted($entry)) $entry->parentNode->removeChild($entry); } @@ -34,4 +34,4 @@ class No_Iframes extends Plugin { return 2; } -}
\ No newline at end of file +} diff --git a/plugins/shorten_expanded/init.js b/plugins/shorten_expanded/init.js index 6371bd1c6..587fcea42 100644 --- a/plugins/shorten_expanded/init.js +++ b/plugins/shorten_expanded/init.js @@ -42,8 +42,6 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { ${__("Click to expand article")}</button>`; dojo.parser.parse(c_inner); - - Headlines.unpackVisible(); } } }, 150); @@ -21,7 +21,7 @@ if (!init_plugins()) return; - login_sequence(); + UserHelper::login_sequence(); header('Content-Type: text/html; charset=utf-8'); ?> @@ -31,7 +31,7 @@ <title>Tiny Tiny RSS : <?php echo __("Preferences") ?></title> <meta name="viewport" content="initial-scale=1,width=device-width" /> - <?php if ($_SESSION["uid"]) { + <?php if ($_SESSION["uid"] && !isset($_REQUEST["ignore-theme"])) { $theme = get_pref("USER_CSS_THEME", false, false); if ($theme && theme_exists("$theme")) { echo stylesheet_tag(get_theme_path($theme), 'theme_css'); @@ -39,7 +39,11 @@ } ?> - <?php print_user_stylesheet() ?> + <script type="text/javascript"> + const __csrf_token = "<?php echo $_SESSION["csrf_token"]; ?>"; + </script> + + <?php UserHelper::print_user_stylesheet() ?> <link rel="shortcut icon" type="image/png" href="images/favicon.png"/> <link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png" /> @@ -159,11 +163,11 @@ </div> <?php $version = get_version($git_commit, $git_timestamp, $last_error); ?> <div id="footer" dojoType="dijit.layout.ContentPane" region="bottom"> - <a class="text-muted" target="_blank" href="http://tt-rss.org/">Tiny Tiny RSS</a> + <a class="text-muted" target="_blank" href="https://tt-rss.org/">Tiny Tiny RSS</a> <span title="<?php echo htmlspecialchars($last_error) ?>">v<?php echo $version ?></span> © 2005-<?php echo date('Y') ?> <a class="text-muted" target="_blank" - href="http://fakecake.org/">Andrew Dolgov</a> + href="https://fakecake.org/">Andrew Dolgov</a> </div> <!-- footer --> </div> diff --git a/public.php b/public.php index e37c44172..36308e25e 100644 --- a/public.php +++ b/public.php @@ -32,7 +32,14 @@ if (implements_interface($handler, "IHandler") && $handler->before($method)) { if ($method && method_exists($handler, $method)) { - $handler->$method(); + $reflection = new ReflectionMethod($handler, $method); + + if ($reflection->getNumberOfRequiredParameters() == 0) { + $handler->$method(); + } else { + header("Content-Type: text/json"); + print error_json(6); + } } else if (method_exists($handler, 'index')) { $handler->index(); } diff --git a/register.php b/register.php index 027a0f2b8..47aa39a09 100644 --- a/register.php +++ b/register.php @@ -288,7 +288,7 @@ $new_uid = db_fetch_result($result, 0, "id"); - initialize_user( $new_uid); + Pref_Users::initialize_user($new_uid); $reg_text = "Hi!\n". "\n". diff --git a/schema/ttrss_schema_mysql.sql b/schema/ttrss_schema_mysql.sql index 60b121e37..95d01e721 100644 --- a/schema/ttrss_schema_mysql.sql +++ b/schema/ttrss_schema_mysql.sql @@ -130,6 +130,7 @@ create table ttrss_feeds (id integer not null auto_increment primary key, auth_pass_encrypted boolean not null default false, last_viewed datetime default null, last_update_started datetime default null, + last_successful_update datetime default null, always_display_enclosures boolean not null default false, update_method integer not null default 0, order_id integer not null default 0, @@ -296,7 +297,7 @@ create table ttrss_tags (id integer primary key auto_increment, create table ttrss_version (schema_version int not null) ENGINE=InnoDB DEFAULT CHARSET=UTF8; -insert into ttrss_version values (139); +insert into ttrss_version values (140); create table ttrss_enclosures (id integer primary key auto_increment, content_url text not null, diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index c818596b8..f73933ba1 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -98,6 +98,7 @@ create table ttrss_feeds (id serial not null primary key, cache_content boolean not null default false, last_viewed timestamp default null, last_update_started timestamp default null, + last_successful_update timestamp default null, update_method integer not null default 0, always_display_enclosures boolean not null default false, order_id integer not null default 0, @@ -278,7 +279,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 (139); +insert into ttrss_version values (140); create table ttrss_enclosures (id serial not null primary key, content_url text not null, diff --git a/schema/versions/mysql/140.sql b/schema/versions/mysql/140.sql new file mode 100644 index 000000000..91215eff1 --- /dev/null +++ b/schema/versions/mysql/140.sql @@ -0,0 +1,4 @@ +alter table ttrss_feeds add column last_successful_update datetime; +alter table ttrss_feeds alter column last_successful_update set default null; + +update ttrss_version set schema_version = 140; diff --git a/schema/versions/pgsql/140.sql b/schema/versions/pgsql/140.sql new file mode 100644 index 000000000..985e30241 --- /dev/null +++ b/schema/versions/pgsql/140.sql @@ -0,0 +1,4 @@ +alter table ttrss_feeds add column last_successful_update timestamp; +alter table ttrss_feeds alter column last_successful_update set default null; + +update ttrss_version set schema_version = 140; diff --git a/templates.local/index.html b/templates.local/index.html new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/templates.local/index.html diff --git a/templates/generated_feed.txt b/templates/generated_feed.txt index 5e35f9be1..617162652 100644 --- a/templates/generated_feed.txt +++ b/templates/generated_feed.txt @@ -1,5 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> -<?xml-stylesheet type="text/xsl" href="atom-to-html.xsl"?> <!-- $BeginBlock feed --> <feed xmlns="http://www.w3.org/2005/Atom"> <title>${FEED_TITLE}</title> diff --git a/themes/Makefile b/themes/Makefile new file mode 100644 index 000000000..b9298207c --- /dev/null +++ b/themes/Makefile @@ -0,0 +1,9 @@ +.PHONY: clean + +ALL: compact.css compact_night.css light.css night_blue.css night.css + +%.css: %.less light/*.less + lessc --source-map=$(patsubst %.less,%.css.map,${<}) ${<} ${@} + +clean: + rm -f *.css *.css.map diff --git a/themes/compact.css b/themes/compact.css index 00d6e22c6..c8323cbe4 100644 --- a/themes/compact.css +++ b/themes/compact.css @@ -70,12 +70,19 @@ body.ttrss_main div.post div.content video { max-width: 98%; height: auto; } -body.ttrss_main div.post div.content p { - hyphens: auto; +body.ttrss_main div.post div.content div.embed-responsive { + overflow: hidden; + padding-bottom: 56.25%; + position: relative; } -body.ttrss_main div.post div.content iframe { - min-width: 50%; - max-width: 98%; +body.ttrss_main div.post div.content div.embed-responsive iframe { + border: 0; + bottom: 0; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; } body.ttrss_main .inline-player { display: flex; @@ -661,13 +668,6 @@ body.ttrss_main #headlines-frame div.feed-title a { body.ttrss_main #headlines-frame div.feed-title a:hover { color: #257aa7; } -body.ttrss_main #headlines-frame.smooth-scroll { - scroll-behavior: smooth; -} -body.ttrss_main #headlines-frame.forbid-smooth-scroll, -body.ttrss_main #content-insert.forbid-smooth-scroll { - scroll-behavior: auto; -} body.ttrss_main #toolbar-frame_splitter { display: none; } @@ -754,7 +754,6 @@ body.ttrss_main #content-insert { line-height: 1.5; overflow: auto; -webkit-overflow-scrolling: touch; - scroll-behavior: smooth; } body.ttrss_main img.feed-icon, body.ttrss_main img.icon { @@ -865,6 +864,22 @@ body.ttrss_main #feedEditDlg img.feedIcon { height: auto; width: auto; } +body.ttrss_main .dijitTooltipContents { + background: #1c5c7d; + color: #f5f5f5; +} +body.ttrss_main .dijitTooltipRight .dijitTooltipConnector { + border-right-color: #1c5c7d; +} +body.ttrss_main .dijitTooltipLeft .dijitTooltipConnector { + border-left-color: #1c5c7d; +} +body.ttrss_main .dijitTooltipBelow .dijitTooltipConnector { + border-bottom-color: #1c5c7d; +} +body.ttrss_main .dijitTooltipAbove .dijitTooltipConnector { + border-top-color: #1c5c7d; +} body.ttrss_main .dijitDialog h1:first-of-type, body.ttrss_main .dijitDialog h2:first-of-type, body.ttrss_main .dijitDialog h3:first-of-type, @@ -877,10 +892,10 @@ body.ttrss_main[view-mode="marked"] #feeds-holder #feedTree .dijitTreeRow.Has_Ma body.ttrss_main[view-mode="marked"] #feeds-holder #feedTree .dijitTreeRow.Has_Marked .counterNode.marked { display: inline-block; } -body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.AlwaysVisible):not(.Special):not(.Has_Marked) { +body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.AlwaysVisible):not(.Special):not(.Has_Marked) { display: none; } -body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.AlwaysVisible):not(.Has_Marked) { +body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.AlwaysVisible):not(.Has_Marked) { display: none; } body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow.Unread .counterNode.unread { @@ -889,10 +904,10 @@ body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow. body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow.Has_Aux:not(.Unread) .counterNode.aux { display: inline-block; } -body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.Unread):not(.AlwaysVisible):not(.Special) { +body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.Unread):not(.AlwaysVisible):not(.Special) { display: none; } -body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.Unread):not(.AlwaysVisible) { +body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.Unread):not(.AlwaysVisible) { display: none; } body.ttrss_main #toolbar-headlines i.icon-syndicate { @@ -917,12 +932,10 @@ body.ttrss_main i.icon-no-feed { body.ttrss_main .dijitTreeRow.UpdatesDisabled .dijitTreeLabel { opacity: 0.5; } -body.ttrss_main #floatingTitle.marked i.marked-pic, body.ttrss_main .cdm.marked .left i.marked-pic, body.ttrss_main .hl.marked .left i.marked-pic { color: #ffc069; } -body.ttrss_main #floatingTitle.published i.pub-pic, body.ttrss_main .cdm.published .left i.pub-pic, body.ttrss_main .hl.published .left i.pub-pic { color: #ff7c4b; @@ -1116,6 +1129,11 @@ video::-webkit-media-controls-overlay-play-button { .cdm i.material-icons { color: #777; } +.cdm .header { + position: sticky; + top: 0; + z-index: 3; +} .cdm .header, .cdm .footer { display: flex; @@ -1128,6 +1146,9 @@ video::-webkit-media-controls-overlay-play-button { margin: 0px 4px; vertical-align: middle; } +.cdm .header-sticky-guard { + height: 0; +} .cdm .header { align-items: center; } @@ -1207,9 +1228,6 @@ video::-webkit-media-controls-overlay-play-button { margin-top: 0px; margin-bottom: 0px; } -div.cdm.expanded div.header { - background: transparent ! important; -} div.cdm.expanded div.header a.title { font-size: 16px; color: #999; @@ -1267,15 +1285,19 @@ div.cdm.vgrlf .feed { font-style: italic; font-size: 11px; } -.cdm div.content-inner p { - /*max-width : 650px;*/ - -webkit-hyphens: auto; - -moz-hyphens: auto; - hyphens: auto; +.cdm div.content-inner div.embed-responsive { + overflow: hidden; + padding-bottom: 56.25%; + position: relative; } -.cdm div.content-inner iframe { - min-width: 50%; - max-width: 98%; +.cdm div.content-inner div.embed-responsive iframe { + border: 0; + bottom: 0; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; } .cdm div.header span.author { white-space: nowrap; @@ -1288,115 +1310,6 @@ div.cdm.vgrlf .feed { display: inline-block; padding: 1px 4px 1px 4px; } -#main:not(.expandable) div#floatingTitle .collapse { - display: none; -} -div#floatingTitle { - position: absolute; - z-index: 5; - top: 0px; - right: 0px; - left: 0px; - border: 0px solid #ddd; - border-bottom-width: 1px; - background: white; - color: #555; - display: flex; - flex-direction: row; - flex-wrap: nowrap; - box-shadow: 0px 1px 1px -1px rgba(0, 0, 0, 0.1); - align-items: center; -} -div#floatingTitle > * { - white-space: nowrap; - padding: 4px; -} -div#floatingTitle .left, -div#floatingTitle .right { - display: flex; - align-items: center; -} -div#floatingTitle .left i.material-icons, -div#floatingTitle .right i.material-icons { - margin-left: 2px; - font-size: 21px; - padding: 2px; - user-select: none; -} -div#floatingTitle .left i.icon-anchor, -div#floatingTitle .right i.icon-anchor { - margin-left: 0px; - margin-right: 1px; - padding: 0px; - color: #ccc; - cursor: pointer; -} -div#floatingTitle .excerpt { - display: none; -} -div#floatingTitle .collapse i.material-icons { - color: #257aa7; - cursor: pointer; -} -div#floatingTitle span.author { - color: #555; - font-size: 11px; - font-weight: normal; -} -div#floatingTitle a.title { - font-size: 16px; - color: #999; - transition: color 0.2s, background 0.2s; - font-weight: 600; - text-rendering: optimizelegibility; - font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; -} -div#floatingTitle div.feed { - padding-right: 10px; - color: #555; - font-weight: normal; - font-style: italic; - font-size: 11px; - white-space: nowrap; -} -div#floatingTitle div.feed a { - border-radius: 4px; - display: inline-block; - padding: 1px 4px 1px 4px; -} -div#floatingTitle span.updated { - padding-right: 10px; - white-space: nowrap; - color: #555; - font-size: 11px; -} -div#floatingTitle div.feed a { - color: #555; -} -div#floatingTitle span.titleWrap { - width: 100%; - white-space: normal; -} -div#floatingTitle .feed-title > * { - display: table-cell; - vertical-align: middle; -} -div#floatingTitle .feed-title a.title { - width: 100%; -} -div#floatingTitle .feed-title a.catchup { - text-align: right; - color: #555; - padding-right: 10px; - font-size: 11px; - white-space: nowrap; -} -div#floatingTitle .feed-title a.catchup:hover { - color: #257aa7; -} -div#floatingTitle.Unread a.title { - color: black; -} .cdm.expandable { background-color: #f5f5f5; border: 0px solid #ddd; @@ -1469,6 +1382,15 @@ div.cdm.expandable:not(.active) .content, div.cdm.expandable:not(.active) .collapse { display: none; } +div.cdm.expandable.active .header[stuck], +div.cdm.expanded .header[stuck] { + box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.1); + border: 0 solid #ddd; + border-bottom-width: 1px; + background: white ! important; + opacity: 0.9; + backdrop-filter: blur(6px); +} body.ttrss_prefs { background-color: #f5f5f5; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; @@ -1594,12 +1516,12 @@ body.ttrss_prefs .phpinfo td.v { font-family: monospace; word-break: break-all; } -body.ttrss_prefs #filterNewRuleDlg .invalid, -body.ttrss_main #filterNewRuleDlg .invalid { +body.ttrss_prefs #filterNewRuleDlg .dijitValidationTextAreaError, +body.ttrss_main #filterNewRuleDlg .dijitValidationTextAreaError { background: #ffc0c0; } -body.ttrss_prefs #filterNewRuleDlg .valid, -body.ttrss_main #filterNewRuleDlg .valid { +body.ttrss_prefs #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError), +body.ttrss_main #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError) { background: #c0ffc0; } body.ttrss_prefs fieldset, @@ -1906,11 +1828,6 @@ body.ttrss_zoom div.post div.header .row { align-items: center; justify-content: space-between; } -body.ttrss_zoom div.post p { - -webkit-hyphens: auto; - -moz-hyphens: auto; - hyphens: auto; -} body.ttrss_zoom div.post div.content { font-size: 15px; line-height: 1.5; @@ -1962,8 +1879,6 @@ body.ttrss_main.ttrss_index.flat div[id*=RROW] i.material-icons { } body.ttrss_main.ttrss_index.flat .hl, body.ttrss_main.ttrss_index.flat .post .header .title, -body.ttrss_main.ttrss_index.flat #floatingTitle a.title, body.ttrss_main.ttrss_index.flat .cdm .title { font-size: 13px ! important; } -/*# sourceMappingURL=compact.css.map */
\ No newline at end of file diff --git a/themes/compact.css.map b/themes/compact.css.map deleted file mode 100644 index 717d60fbf..000000000 --- a/themes/compact.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["C:/Users/fox/Projects/tt-rss/css/default.less","C:/Users/fox/Projects/tt-rss/css/defines.less","C:/Users/fox/Projects/tt-rss/css/tt-rss.less","C:/Users/fox/Projects/tt-rss/css/cdm.less","C:/Users/fox/Projects/tt-rss/css/prefs.less","C:/Users/fox/Projects/tt-rss/css/utility.less","C:/Users/fox/Projects/tt-rss/css/dijit_basic.less","C:/Users/fox/Projects/tt-rss/css/dijit_light.less","C:/Users/fox/Projects/tt-rss/css/zoom.less","compact.less"],"names":[],"mappings":"QAGQ;ACcR,IAAI;AACJ,IAAI;AACJ;EACE,kBAAA;EACA,WAAA;EACA,YAAA;EACA,SAAA;EACA,UAAA;EACA,SAAA;;ACzBF,IAAI;EACH,iBAAA;EACA,YAAA;EACA,aAAa,8CAAb;EACA,eAAA;EACA,gBAAA;;AALD,IAAI,WAOH;EACC,aAAA;;AARF,IAAI,WAWH,IAAG;EACF,YAAA;EACA,eAAA;;AAbF,IAAI,WAWH,IAAG,KAIF,IAAG;EACF,YAAA;EACA,cAAA;EACA,sBAAA;EACA,wBAAA;EACA,mBAAA;;AApBH,IAAI,WAWH,IAAG,KAIF,IAAG,OAOF;AAtBH,IAAI,WAWH,IAAG,KAIF,IAAG,OAOK;EACN,aAAA;;AAvBJ,IAAI,WAWH,IAAG,KAIF,IAAG,OAWF;EACC,aAAA;EACA,kBAAA;EACA,iBAAA;EACA,mBAAA;EACA,8BAAA;;AA/BJ,IAAI,WAWH,IAAG,KAIF,IAAG,OAmBF;EACC,YAAA;;AAnCJ,IAAI,WAWH,IAAG,KAIF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AAA;EACA,WAAA;EACA,sBAAA;EACA,eAAA;EACA,sBAAA;EACA,mBAAA;EACA,cAAA;EACA,cAAA;EACA,cAAA;;;ACnEJ,IAAI,WAAW,YAAY,KAEzB,UAAS,UAAW;EAClB,2BAAA;;AAHJ,IAAI,WAAW,YAAY,KAMzB,WAAW;AANb,IAAI,WAAW,YAAY,KAOzB;AAPF,IAAI,WAAW,YAAY,KAQzB;AARF,IAAI,WAAW,YAAY,KASzB,KAAK;AATP,IAAI,WAAW,YAAY,KAUzB,MAAM;EACJ,2BAAA;;AAXJ,IAAI,WAAW,YAAY,KAczB,IAAG,UACD,EAAC;EACC,eAAA;;AAhBN,IAAI,WAAW,YAAY,KAoBzB;AApBF,IAAI,WAAW,YAAY,KAqBzB,MAAM,QAAQ;AArBhB,IAAI,WAAW,YAAY,KAsBzB,eAAe,EAAC;AAtBlB,IAAI,WAAW,YAAY,KAuBzB,KAAK;EACH,2BAAA","file":"compact.css"}
\ No newline at end of file diff --git a/themes/compact.less b/themes/compact.less index 3da095c54..2159d46a6 100644 --- a/themes/compact.less +++ b/themes/compact.less @@ -1,33 +1,2 @@ -@import "../css/default.less"; - -/* rules specific to compact.css */ - -body.ttrss_main.ttrss_index.flat { - - #feedTree.dijitTree .dijitTreeLabel { - font-size : 13px ! important; - } - - .dijitMenu .dijitMenuItemLabel, - .content-inner, - #content-insert, - .cdm .content, - .post .content { - font-size : 12px ! important; - } - - div[id*=RROW] { - i.material-icons { - font-size: 18px; - } - } - - .hl, - .post .header .title, - #floatingTitle a.title, - .cdm .title { - font-size : 13px ! important; - } - - -} +@import "light/light_base.less"; +@import "compact_base.less"; diff --git a/themes/compact_base.less b/themes/compact_base.less new file mode 100644 index 000000000..b3b48802b --- /dev/null +++ b/themes/compact_base.less @@ -0,0 +1,30 @@ +/* rules specific to compact.css */ + +body.ttrss_main.ttrss_index.flat { + + #feedTree.dijitTree .dijitTreeLabel { + font-size : 13px ! important; + } + + .dijitMenu .dijitMenuItemLabel, + .content-inner, + #content-insert, + .cdm .content, + .post .content { + font-size : 12px ! important; + } + + div[id*=RROW] { + i.material-icons { + font-size: 18px; + } + } + + .hl, + .post .header .title, + .cdm .title { + font-size : 13px ! important; + } + + +} diff --git a/themes/compact_night.css b/themes/compact_night.css new file mode 100644 index 000000000..b47a8821e --- /dev/null +++ b/themes/compact_night.css @@ -0,0 +1,2119 @@ +@import "../lib/flat-ttrss/flat_combined_dark.css"; +body.ttrss_main, +body.ttrss_prefs, +#main { + position: absolute; + width: 100%; + height: 100%; + border: 0; + padding: 0; + margin: 0; +} +body.ttrss_main { + background: #333; + color: #ccc; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 14px; + overflow: hidden; +} +body.ttrss_main :focus { + outline: none; +} +body.ttrss_main div.post { + padding: 0px; + font-size: 13px; +} +body.ttrss_main div.post div.header { + padding: 5px; + color: #909090; + border: 0px solid #222; + border-bottom-width: 1px; + background: #222; +} +body.ttrss_main div.post div.header .left, +body.ttrss_main div.post div.header .right { + display: flex; +} +body.ttrss_main div.post div.header .row { + display: flex; + margin-bottom: 4px; + flex-wrap: nowrap; + align-items: center; + justify-content: space-between; +} +body.ttrss_main div.post div.header .comments { + flex-grow: 2; +} +body.ttrss_main div.post div.header .date { + white-space: nowrap; +} +body.ttrss_main div.post div.header img, +body.ttrss_main div.post div.header i.material-icons { + margin: 0px 4px; + vertical-align: middle; + color: #777; +} +body.ttrss_main div.post div.header .title { + flex-grow: 2; + font-size: 15px; + font-weight: 600; + text-rendering: optimizelegibility; + font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; +} +body.ttrss_main div.post div.content { + padding: 10px; + font-size: 16px; +} +body.ttrss_main div.post div.content img, +body.ttrss_main div.post div.content video { + border-width: 0px; + max-width: 98%; + height: auto; +} +body.ttrss_main div.post div.content div.embed-responsive { + overflow: hidden; + padding-bottom: 56.25%; + position: relative; +} +body.ttrss_main div.post div.content div.embed-responsive iframe { + border: 0; + bottom: 0; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; +} +body.ttrss_main .inline-player { + display: flex; + align-items: center; +} +body.ttrss_main .inline-player audio { + margin-right: 8px; +} +body.ttrss_main .article-note { + background-color: #fff7d5; + margin: 5px; + border: 1px solid #e7d796; + color: #9a8c59; + display: flex; + align-items: center; +} +body.ttrss_main .article-note > * { + padding: 5px; +} +body.ttrss_main .article-note.editable { + cursor: pointer; +} +body.ttrss_main h1 { + font-size: 18px; + font-weight: 600; + text-rendering: optimizelegibility; +} +body.ttrss_main h2 { + font-size: 16px; + font-weight: 600; + text-rendering: optimizelegibility; +} +body.ttrss_main h3 { + font-size: 16px; + font-weight: 600; + text-rendering: optimizelegibility; +} +body.ttrss_main h4 { + font-size: 14px; + font-weight: 600; + text-rendering: optimizelegibility; +} +body.ttrss_main a { + color: #b87d2c; + text-decoration: none; +} +body.ttrss_main a:hover { + color: #664518; + text-decoration: underline; +} +body.ttrss_main #notify.visible { + opacity: 100; +} +body.ttrss_main #notify { + bottom: 20px; + right: 20px; + min-width: 200px; + max-width: 350px; + border-width: 1px; + border-style: solid; + position: fixed; + font-size: 14px; + z-index: 99; + display: flex; + opacity: 0; + align-items: center; + padding: 10px; + transition: opacity 0.2s linear; + box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1); +} +body.ttrss_main #notify img { + vertical-align: middle; +} +body.ttrss_main #notify .msg { + flex-grow: 2; + padding: 0 10px; + line-height: 20px; +} +body.ttrss_main #notify .icon-close { + cursor: pointer; +} +body.ttrss_main .notify { + border-color: #d7c47a; + background-color: #fff7d5; +} +body.ttrss_main .notify.notify_progress { + border-color: #d7c47a; + background-color: #fff7d5; +} +body.ttrss_main .notify.notify_info { + border-color: #b87d2c; + background-color: #faf3e9; +} +body.ttrss_main .notify.notify_info i.icon-notify { + color: #b87d2c; +} +body.ttrss_main .notify.notify_error { + background-color: #c00; + border-color: #900; + color: white; +} +body.ttrss_main .notify.notify_error i.icon-notify, +body.ttrss_main .notify.notify_error i.icon-close { + color: white; +} +body.ttrss_main .action-chooser .action-button .dijitButtonText { + vertical-align: unset; +} +body.ttrss_main .action-chooser .action-button .dijitArrowButtonInner { + display: none; +} +body.ttrss_main .hl { + border: 0px solid #222; + border-bottom-width: 1px; + transition: color 0.2s, background 0.2s; + display: flex; + flex-direction: row; + flex-wrap: nowrap; + background: #222; + align-items: center; + user-select: none; +} +body.ttrss_main .hl > * { + white-space: nowrap; + padding: 4px; +} +body.ttrss_main .hl img { + vertical-align: middle; +} +body.ttrss_main .hl .left, +body.ttrss_main .hl .right { + display: flex; + align-items: center; +} +body.ttrss_main .hl .left i.material-icons, +body.ttrss_main .hl .right i.material-icons { + margin-left: 2px; + padding: 2px; + transition: color 0.2s linear; + user-select: none; + font-size: 21px; +} +body.ttrss_main .hl .right i.material-icons { + color: #777; +} +body.ttrss_main .hl div.title { + cursor: pointer; + flex-grow: 2; + overflow: hidden; + text-overflow: ellipsis; +} +body.ttrss_main .hl span.author { + white-space: nowrap; + color: #ccc; + font-size: 11px; + font-weight: normal; +} +body.ttrss_main .hl div.right { + text-align: right; +} +body.ttrss_main .hl span.feed a { + border-radius: 4px; + display: inline-block; + padding: 1px 4px; + font-size: 11px; + font-style: italic; + font-weight: normal; + color: #ccc; +} +body.ttrss_main .hl span.feed a:hover { + color: #b87d2c; +} +body.ttrss_main .hl span.updated { + color: #ccc; + text-align: right; + font-size: 11px; + padding-left: 10px; +} +body.ttrss_main .hl span.updated div { + display: inline-block; +} +body.ttrss_main .hl div.left input { + margin: 0px 4px; +} +body.ttrss_main .hl div.left img, +body.ttrss_main .hl div.right img { + margin: 0px 4px; +} +body.ttrss_main .hl div.title a { + font-weight: 600; + text-rendering: optimizelegibility; + font-family: "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #555; +} +body.ttrss_main .hl a.title.high, +body.ttrss_main .hl span.hl-content.high .preview { + color: #00aa00; +} +body.ttrss_main .hl.vgrlf .feed { + display: none; +} +body.ttrss_main .hl.Unread { + background: white; +} +body.ttrss_main .hl.Unread div.title a { + color: black; +} +body.ttrss_main .hl.active div.title a { + color: #b87d2c; + /* text-shadow : 1px 1px 2px #fff; */ +} +body.ttrss_main .hl.active { + background: #b87d2c ! important; +} +body.ttrss_main .hl.active, +body.ttrss_main .hl.Selected { + color: white; + background: #9c7948; +} +body.ttrss_main .hl.active a, +body.ttrss_main .hl.Selected a, +body.ttrss_main .hl.active .feed a, +body.ttrss_main .hl.Selected .feed a, +body.ttrss_main .hl.active .hl-content a.title, +body.ttrss_main .hl.Selected .hl-content a.title, +body.ttrss_main .hl.active span, +body.ttrss_main .hl.Selected span { + color: white; +} +body.ttrss_main .hl.Grayed { + color: #909090; +} +body.ttrss_main #content-insert blockquote, +body.ttrss_main #headlines-frame blockquote, +body.ttrss_main .dijitContentPane blockquote { + margin: 5px 0px 5px 0px; + color: #ccc; + padding-left: 10px; + border: 0px solid #ccc; + border-left-width: 4px; +} +body.ttrss_main #content-insert code, +body.ttrss_main #headlines-frame code, +body.ttrss_main .dijitContentPane code { + color: #009900; + font-family: monospace; +} +body.ttrss_main #content-insert pre, +body.ttrss_main #headlines-frame pre, +body.ttrss_main .dijitContentPane pre { + margin: 5px 0px 5px 0px; + padding: 10px; + color: #ccc; + font-family: monospace; + font-size: 12px; + border: 0px solid #ccc; + background: #222; + display: block; + max-width: 98%; + overflow: auto; +} +body.ttrss_main div.prefHelp { + color: #ccc; + padding: 5px; +} +body.ttrss_main span.preview { + color: #999; + font-weight: normal; + font-size: 12px; + padding-left: 4px; +} +body.ttrss_main .label { + display: inline-block; + vertical-align: middle; + background-color: #fff7d5; + font-size: 9px; + color: #ccc; + font-weight: normal; + margin-left: 2px; + padding: 2px 4px; + white-space: nowrap; +} +body.ttrss_main i.marked-pic, +body.ttrss_main i.pub-pic { + cursor: pointer; + color: #ccc; +} +body.ttrss_main div.errorExplained { + border: 1px solid #222; + margin: 5px 0px 5px 0px; + padding: 5px; +} +body.ttrss_main ul.browseFeedList { + height: 300px; + width: 100%; + overflow: auto; + border-width: 0px 1px 1px 1px; + border-color: #222; + border-style: solid; + margin: 0px 0px 5px 0px; + background-color: white; + list-style-type: none; + padding: 0px; +} +body.ttrss_main ul.browseFeedList li { + display: flex; + align-items: center; +} +body.ttrss_main ul.browseFeedList li > * { + margin: 2px; +} +body.ttrss_main .browseFeedList span.subscribers { + color: #808080; +} +body.ttrss_main ul.compact { + list-style-type: none; + margin: 0px; + padding: 0px; +} +body.ttrss_main ul.compact li { + margin: 0px; + padding: 0px; +} +body.ttrss_main .noborder { + border-width: 0px; +} +body.ttrss_main #overlay { + background: #333; + left: 0; + top: 0; + height: 100%; + width: 100%; + z-index: 100; + position: absolute; +} +body.ttrss_main #overlay_inner { + font-weight: bold; + margin: 1em; +} +body.ttrss_main div.loadingPrompt { + padding: 1em; + text-align: center; + font-weight: bold; +} +body.ttrss_main div.whiteBox { + margin-left: 1px; + text-align: center; + padding: 1em 1em 0px 1em; + font-size: 11px; + border: 0px solid #222; + border-bottom-width: 1px; +} +body.ttrss_main div#headlines-frame.wide .title { + overflow: visible; + white-space: normal; +} +body.ttrss_main div#headlines-frame.wide .hl .feed { + display: none; +} +body.ttrss_main .dijitDialog header, +body.ttrss_main .dijitDialog .dlgSec, +body.ttrss_main .dijitDialog .dlgSecHoriz { + font-size: 16px; + font-weight: 600; + color: #ccc; + font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; +} +body.ttrss_main .dijitDialog section, +body.ttrss_main .dijitDialog .dlgSecCont { + margin: 10px 20px; +} +body.ttrss_main .dijitDialog header.horizontal + section, +body.ttrss_main .dijitDialog .dlgSecHoriz + .dlgSecCont { + margin: 10px 0; +} +body.ttrss_main .dijitDialog section.narrow { + margin: 0; +} +body.ttrss_main .dijitDialog section fieldset > label, +body.ttrss_main .dijitDialog div.dlgSecCont fieldset > label, +body.ttrss_main .dijitDialog div.dlgSecSimple fieldset > label { + font-weight: bold; + margin-right: 10px; + display: inline-block; + min-width: 140px; + text-align: right; +} +body.ttrss_main .dijitDialog section fieldset > label.checkbox, +body.ttrss_main .dijitDialog div.dlgSecCont fieldset > label.checkbox, +body.ttrss_main .dijitDialog div.dlgSecSimple fieldset > label.checkbox { + font-weight: normal; + display: inline; +} +body.ttrss_main .dijitDialog section fieldset > label.inline, +body.ttrss_main .dijitDialog div.dlgSecCont fieldset > label.inline, +body.ttrss_main .dijitDialog div.dlgSecSimple fieldset > label.inline { + display: inline; +} +body.ttrss_main .dijitDialog section fieldset, +body.ttrss_main .dijitDialog div.dlgSecCont fieldset, +body.ttrss_main .dijitDialog div.dlgSecSimple fieldset { + border-width: 0px; + padding: 5px 0px; +} +body.ttrss_main .dijitDialog section fieldset.narrow, +body.ttrss_main .dijitDialog div.dlgSecCont fieldset.narrow, +body.ttrss_main .dijitDialog div.dlgSecSimple fieldset.narrow { + padding: 2px 0px; +} +body.ttrss_main .dijitDialog section fieldset.align-right, +body.ttrss_main .dijitDialog div.dlgSecCont fieldset.align-right, +body.ttrss_main .dijitDialog div.dlgSecSimple fieldset.align-right { + text-align: right; +} +body.ttrss_main .dijitDialog footer, +body.ttrss_main .dijitDialog .dlgButtons { + margin-top: 5px; + text-align: right; +} +body.ttrss_main .dijitDialog footer.text-center { + text-align: center; +} +body.ttrss_main i.icon-label { + color: #fff7d5; +} +body.ttrss_main div#cmdline { + position: absolute; + left: 5px; + bottom: 5px; + font-size: 11px; + color: #ccc; + font-weight: bold; + background-color: #333; + border: 1px solid #b87d2c; + padding: 3px 5px 3px 5px; + z-index: 5; +} +body.ttrss_main #feed_browser_spinner { + vertical-align: middle; + height: 18px; + width: 18px; +} +body.ttrss_main #exceptionDlg .dijitDialogTitleBar { + background: red; + color: white; +} +body.ttrss_main #exceptionDlg .dijitDialogPaneContent { + background: #fcc; +} +body.ttrss_main #exceptionDlg .error-contents .message { + color: red; +} +body.ttrss_main #exceptionDlg .error-contents textarea { + width: 99%; + height: 200px; +} +body.ttrss_main #exceptionDlg .error-contents .dlgButtons { + text-align: center; +} +body.ttrss_main #content-wrap { + padding: 0px; + border-width: 0px; + margin: 0px; +} +body.ttrss_main #feeds-holder { + padding: 0px; + border: 0px solid #222; + overflow: hidden; + background: #222; + box-shadow: inset -1px 0px 2px -1px rgba(0, 0, 0, 0.1); + -webkit-overflow-scrolling: touch; +} +body.ttrss_main #feeds-holder #feedTree { + height: 100%; + overflow-x: hidden; + text-rendering: optimizelegibility; + font-family: "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; +} +body.ttrss_main #feeds-holder #feedTree .counterNode.aux, +body.ttrss_main #feeds-holder #feedTree .counterNode.marked { + background: #222; + color: #e6e6e6; + border-color: #080808; +} +body.ttrss_main #feeds-holder #feedTree .counterNode.marked { + border-color: #b87d2c; + background: #ffffff; +} +body.ttrss_main #feeds-holder #feedTree .counterNode { + font-weight: bold; + display: none; + font-size: 9px; + text-align: center; + border: 1px solid #cd8b31; + color: white; + background: #cd8b31; + border-radius: 4px; + vertical-align: middle; + float: right; + position: relative; + line-height: 14px; + margin-right: 8px; + margin-top: 2px; + min-width: 23px; + height: 14px; +} +body.ttrss_main #feeds-holder #feedTree .dijitTreeNode .loadingExpando { + left: -3px; + height: 22px; + position: relative; + top: -3px; +} +body.ttrss_main #feeds-holder #feedTree .dijitTreeRow .dijitTreeLabel.Unread { + font-weight: bold; +} +body.ttrss_main #feeds-holder #feedTree .dijitTreeRow.Error .dijitTreeLabel { + color: red; +} +body.ttrss_main #feeds-holder #feedTree .dijitTreeNode .dijitTreeRow { + border: 1px solid transparent; +} +body.ttrss_main #feeds-holder #feedTree .dijitTreeNode .dijitTreeRowSelected { + box-shadow: -1px 0px 2px -1px rgba(0, 0, 0, 0.1); + border-color: #222 transparent; + background: #333; + color: #333; +} +body.ttrss_main #feeds-holder #feedTree .dijitIcon.feed-icon { + margin-right: 2px; +} +body.ttrss_main #feeds-holder #feedTree i.icon.icon-inbox { + color: #555; +} +body.ttrss_main #feeds-holder #feedTree i.icon.icon-archive { + color: #c77b2e; +} +body.ttrss_main #feeds-holder #feedTree i.icon.icon-star { + position: relative; + color: #ffc069; + font-size: 21px; + left: -2px; +} +body.ttrss_main #feeds-holder #feedTree i.icon.icon-rss_feed { + color: #ff7c4b; +} +body.ttrss_main #feeds-holder #feedTree i.icon.icon-whatshot { + color: #69C671; +} +body.ttrss_main #feeds-holder #feedTree i.icon.icon-restore { + position: relative; + top: -1px; + font-weight: bold; + color: #b87d2c; +} +body.ttrss_main #headlines-wrap-inner { + padding: 0px; + margin: 0px; + border-width: 0px; +} +body.ttrss_main #headlines-frame[is-vfeed="0"] .header .feed { + display: none; +} +body.ttrss_main #headlines-frame { + padding: 0px; + border: 0px #222; + margin-top: 0px; + -webkit-overflow-scrolling: touch; + -webkit-transform: translateZ(0); + -webkit-backface-visibility: hidden; +} +body.ttrss_main #headlines-frame div.feed-title { + border: 0px solid #b87d2c; + border-bottom-width: 1px; + padding: 5px 8px; +} +body.ttrss_main #headlines-frame div.feed-title a.title { + color: #ccc; + font-weight: bold; +} +body.ttrss_main #headlines-frame div.feed-title a { + color: #ccc; +} +body.ttrss_main #headlines-frame div.feed-title a:hover { + color: #b87d2c; +} +body.ttrss_main #toolbar-frame_splitter { + display: none; +} +body.ttrss_main #toolbar-frame { + padding: 0px; + margin: 0px; + border-width: 0px; + white-space: nowrap; + font-size: 12px; +} +body.ttrss_main #toolbar-frame #toolbar { + background: white; + border: 0px solid #222; + border-bottom-width: 1px; + padding-left: 4px; + height: 32px; + display: flex; + flex-direction: row; + flex-wrap: nowrap; + color: #ccc; + font-size: 12px; + align-items: center; +} +body.ttrss_main #toolbar-frame #toolbar .dijitSelect, +body.ttrss_main #toolbar-frame #toolbar .dijitDropDownButton .dijitButtonNode, +body.ttrss_main #toolbar-frame #toolbar .dijitComboButton .dijitButtonNode { + border: 0px; +} +body.ttrss_main #toolbar-frame #toolbar i.net-alert, +body.ttrss_main #toolbar-frame #toolbar .left i.icon-error { + color: red; +} +body.ttrss_main #toolbar-frame #toolbar i.log-alert { + color: #ddba1c; +} +body.ttrss_main #toolbar-frame #toolbar #toolbar-headlines { + padding-right: 4px; + flex-grow: 2; + display: flex; +} +body.ttrss_main #toolbar-frame #toolbar #toolbar-headlines .left { + flex-grow: 2; + display: flex; + align-items: center; +} +body.ttrss_main #toolbar-frame #toolbar #toolbar-headlines .left img { + vertical-align: middle; + margin-right: 8px; +} +body.ttrss_main #toolbar-frame #toolbar #toolbar-headlines .right { + display: flex; + align-items: center; +} +body.ttrss_main #toolbar-frame #toolbar #updates-available { + color: #69C671; + padding-right: 4px; +} +body.ttrss_main #toolbar-frame #toolbar #selected_prompt { + font-style: italic; + text-align: right; + margin-right: 4px; + color: #b87d2c; +} +@media (max-width: 992px) { + body.ttrss_main #toolbar-frame #toolbar #selected_prompt { + display: none; + } +} +body.ttrss_main #header { + border-width: 0px; + text-align: right; + color: #ccc; + padding: 5px 5px 0px 0px; + margin: 0px; + position: absolute; + right: 0px; + top: 0px; + z-index: 5; +} +body.ttrss_main #content-insert { + padding: 0px; + border-color: #222; + border-width: 0px; + line-height: 1.5; + overflow: auto; + -webkit-overflow-scrolling: touch; +} +body.ttrss_main img.feed-icon, +body.ttrss_main img.icon { + width: 16px; + height: 16px; + line-height: 16px; + vertical-align: middle; + display: inline-block; +} +body.ttrss_main .player { + display: inline-block; + color: #ccc; + font-size: 11px; + font-family: sans-serif; + border: 1px solid #ccc; + padding: 0px 4px 0px 4px; + margin: 0px 2px 0px 2px; + width: 50px; + text-align: center; + background: #333; +} +body.ttrss_main .player.playing { + color: #00c000; + border-color: #00c000; +} +body.ttrss_main .player:hover { + background: #222; + cursor: pointer; +} +body.ttrss_main #headlines-frame.auto_catchup #headlines-spacer { + height: 100%; +} +body.ttrss_main #headlines-spacer { + margin-left: 1px; + text-align: center; + color: #ccc; + font-size: 11px; + font-style: italic; +} +body.ttrss_main #headlines-spacer a, +body.ttrss_main #headlines-spacer span { + color: #ccc; + padding: 10px; + display: block; +} +body.ttrss_main #headlines-spacer a:hover { + color: #b87d2c; +} +body.ttrss_main ul#filterDlg_Matches, +body.ttrss_main ul#filterDlg_Actions { + max-height: 100px; + overflow: auto; + list-style-type: none; + border-style: solid; + border-color: #222; + border-width: 1px 1px 1px 1px; + background-color: #333; + margin: 0px 0px 5px 0px; + padding: 4px; + min-height: 16px; +} +body.ttrss_main ul#filterDlg_Matches li, +body.ttrss_main ul#filterDlg_Actions li { + cursor: pointer; +} +body.ttrss_main ul#filterDlg_Matches li .dijitCheckBox, +body.ttrss_main ul#filterDlg_Actions li .dijitCheckBox { + margin-right: 4px; +} +body.ttrss_main ul.hotkeys-help li { + display: flex; +} +body.ttrss_main ul.hotkeys-help li.desc { + flex-grow: 2; +} +body.ttrss_main ul.hotkeys-help .hk { + color: #b87d2c; + width: 100px; +} +body.ttrss_main ul.hotkeys-help h3 { + margin: 8px 0px; +} +body.ttrss_main select.attachments { + display: block; + margin-top: 10px; + max-width: 120px; +} +body.ttrss_main #filterDlg_feeds select { + height: 150px; + width: 410px; +} +body.ttrss_main span.highlight { + background-color: #ffff00; + color: #cc90cc; +} +body.ttrss_main #headlines-frame .dijitCheckBox { + margin-right: 4px; +} +body.ttrss_main #editTagsDlg { + overflow: visible; +} +body.ttrss_main #feedEditDlg img.feedIcon { + border: 1px solid #ccc; + padding: 5px; + margin: 5px; + max-width: 20px; + max-height: 20px; + height: auto; + width: auto; +} +body.ttrss_main .dijitTooltipContents { + background: #d29745; + color: #222; +} +body.ttrss_main .dijitTooltipRight .dijitTooltipConnector { + border-right-color: #d29745; +} +body.ttrss_main .dijitTooltipLeft .dijitTooltipConnector { + border-left-color: #d29745; +} +body.ttrss_main .dijitTooltipBelow .dijitTooltipConnector { + border-bottom-color: #d29745; +} +body.ttrss_main .dijitTooltipAbove .dijitTooltipConnector { + border-top-color: #d29745; +} +body.ttrss_main .dijitDialog h1:first-of-type, +body.ttrss_main .dijitDialog h2:first-of-type, +body.ttrss_main .dijitDialog h3:first-of-type, +body.ttrss_main .dijitDialog h4:first-of-type { + margin-top: 0px; +} +body.ttrss_main[view-mode="marked"] #feeds-holder #feedTree .dijitTreeRow.Has_Marked .dijitTreeLabel { + color: #b87d2c; +} +body.ttrss_main[view-mode="marked"] #feeds-holder #feedTree .dijitTreeRow.Has_Marked .counterNode.marked { + display: inline-block; +} +body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.AlwaysVisible):not(.Special):not(.Has_Marked) { + display: none; +} +body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.AlwaysVisible):not(.Has_Marked) { + display: none; +} +body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow.Unread .counterNode.unread { + display: inline-block; +} +body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow.Has_Aux:not(.Unread) .counterNode.aux { + display: inline-block; +} +body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.Unread):not(.AlwaysVisible):not(.Special) { + display: none; +} +body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.Unread):not(.AlwaysVisible) { + display: none; +} +body.ttrss_main #toolbar-headlines i.icon-syndicate { + color: #ff7c4b; + margin-right: 8px; + border: 1px solid #ff7c4b; + border-radius: 4px; +} +body.ttrss_main #toolbar-headlines #feed_current_unread { + margin-left: 8px; + font-weight: bold; + text-align: center; + border: 1px solid #cd8b31; + color: white; + background: #cd8b31; + border-radius: 4px; + min-width: 23px; +} +body.ttrss_main i.icon-no-feed { + opacity: 0.2; +} +body.ttrss_main .dijitTreeRow.UpdatesDisabled .dijitTreeLabel { + opacity: 0.5; +} +body.ttrss_main .cdm.marked .left i.marked-pic, +body.ttrss_main .hl.marked .left i.marked-pic { + color: #ffc069; +} +body.ttrss_main .cdm.published .left i.pub-pic, +body.ttrss_main .hl.published .left i.pub-pic { + color: #ff7c4b; +} +body.ttrss_main .score-high i.icon-score { + color: #69C671; +} +body.ttrss_main .score-low i.icon-score { + color: #500; +} +body.ttrss_main .score-neutral i.icon-score { + opacity: 0.5; +} +body.ttrss_main i.icon-score { + cursor: pointer; +} +body.ttrss_main .panel { + border: 1px solid #222; + background: #222; + padding: 4px; +} +body.ttrss_main .dijitDialog .panel { + background: #333; +} +body.ttrss_main .panel-scrollable { + overflow: auto; + height: 200px; +} +body.ttrss_main ul.list li { + padding: 2px; +} +body.ttrss_main ul.list { + padding: 4px; +} +body.ttrss_main ul.list-unstyled { + list-style-type: none; +} +body.ttrss_main .text-center { + text-align: center; +} +body.ttrss_main #prefFilterTestResultList .preview { + margin: 8px; +} +body.ttrss_main #prefFilterTestResultList .title { + font-weight: bold; +} +body.ttrss_main #prefFilterTestResultList .feed { + color: #b87d2c; +} +body.ttrss_main .alert, +body.ttrss_utility .alert { + padding: 8px 35px 8px 14px; + margin-bottom: 10px; + /* text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); */ + background-color: #fcf8e3; + border: 1px solid #fbeed5; + border-radius: 4px; +} +body.ttrss_main .alert .close, +body.ttrss_utility .alert .close { + position: relative; + top: -2px; + right: -21px; + line-height: 20px; + cursor: pointer; +} +body.ttrss_main .pull-right, +body.ttrss_utility .pull-right { + float: right; +} +body.ttrss_main .pull-left, +body.ttrss_utility .pull-left { + float: left; +} +body.ttrss_main .text-error, +body.ttrss_utility .text-error { + color: #b94a48; +} +body.ttrss_main .text-info, +body.ttrss_utility .text-info { + color: #3a87ad; +} +body.ttrss_main .text-success, +body.ttrss_utility .text-success { + color: #468847; +} +body.ttrss_main .text-warning, +body.ttrss_utility .text-warning { + color: #a47e3c; +} +body.ttrss_main .alert, +body.ttrss_utility .alert, +body.ttrss_main .alert h4, +body.ttrss_utility .alert h4 { + color: #c09853; +} +body.ttrss_main .alert h4, +body.ttrss_utility .alert h4 { + margin: 0; +} +body.ttrss_main .alert-success, +body.ttrss_utility .alert-success { + color: #468847; + background-color: #dff0d8; + border-color: #d6e9c6; +} +body.ttrss_main .alert-success h4, +body.ttrss_utility .alert-success h4 { + color: #468847; +} +body.ttrss_main .alert-danger, +body.ttrss_utility .alert-danger, +body.ttrss_main .alert-error, +body.ttrss_utility .alert-error { + color: #b94a48; + background-color: #f2dede; + border-color: #eed3d7; +} +body.ttrss_main .alert-danger h4, +body.ttrss_utility .alert-danger h4, +body.ttrss_main .alert-error h4, +body.ttrss_utility .alert-error h4 { + color: #b94a48; +} +body.ttrss_main .alert-info, +body.ttrss_utility .alert-info { + color: #3a87ad; + background-color: #d9edf7; + border-color: #bce8f1; +} +body.ttrss_main .alert-info h4, +body.ttrss_utility .alert-info h4 { + color: #3a87ad; +} +body.ttrss_main hr, +body.ttrss_utility hr { + border: 0px solid #ccc; + border-bottom-width: 1px; +} +body.ttrss_main .text-muted, +body.ttrss_utility .text-muted { + color: #ccc; +} +body.ttrss_main .small, +body.ttrss_utility .small { + font-size: 11px; +} +body.ttrss_main div.autocomplete, +body.ttrss_utility div.autocomplete { + position: absolute; + width: 250px; + background-color: #333; + border: 1px solid #222; + margin: 0px; + padding: 0px; +} +body.ttrss_main div.autocomplete ul, +body.ttrss_utility div.autocomplete ul { + list-style-type: none; + margin: 0px; + padding: 0px; +} +body.ttrss_main div.autocomplete ul li.selected, +body.ttrss_utility div.autocomplete ul li.selected { + background-color: #1a1a1a; +} +body.ttrss_main div.autocomplete ul li, +body.ttrss_utility div.autocomplete ul li { + list-style-type: none; + display: block; + margin: 0; + padding: 2px; + cursor: pointer; +} +::selection { + background: #b87d2c; + color: #333; +} +::-webkit-scrollbar { + width: 4px; +} +::-webkit-scrollbar-thumb { + background-color: #b87d2c; +} +::-webkit-scrollbar-track { + background-color: #eee; +} +video::-webkit-media-controls-overlay-play-button { + display: none; +} +.cdm i.material-icons { + color: #777; +} +.cdm .header { + position: sticky; + top: 0; + z-index: 3; +} +.cdm .header, +.cdm .footer { + display: flex; + flex-direction: row; + flex-wrap: nowrap; +} +.cdm .header img, +.cdm .footer img, +.cdm .footer i.material-icons { + margin: 0px 4px; + vertical-align: middle; +} +.cdm .header-sticky-guard { + height: 0; +} +.cdm .header { + align-items: center; +} +.cdm .header > * { + padding: 4px; + white-space: nowrap; +} +.cdm .header .left, +.cdm .header .right { + display: flex; + align-items: center; +} +.cdm .header .left i.material-icons, +.cdm .header .right i.material-icons { + margin-left: 2px; + padding: 2px; + transition: color 0.2s linear; + user-select: none; + font-size: 21px; +} +.cdm .header .titleWrap { + flex-grow: 2; +} +.cdm .header span.updated { + color: #ccc; + font-weight: normal; + font-size: 11px; + white-space: nowrap; +} +.cdm .header input { + margin: 0px 4px; +} +.cdm .footer { + height: 30px; + padding-left: 5px; + font-weight: normal; + color: #ccc; + clear: both; + align-items: center; +} +.cdm .footer .left { + flex-grow: 2; +} +.cdm .intermediate { + margin-top: 10px; + margin-left: 10px; +} +.cdm .content-inner { + margin: 10px; + line-height: 1.5; + font-size: 16px; +} +.cdm .intermediate img, +.cdm .intermediate video, +.cdm .content-inner img, +.cdm .content-inner video { + border-width: 0px; + max-width: 98%; + height: auto; +} +.cdm.expanded { + /*margin-top : 4px; + margin-bottom : 4px;*/ +} +.cdm.expanded .collapse, +.cdm.expanded .excerpt { + display: none; +} +.cdm.expanded .titleWrap { + white-space: normal; +} +.cdm.expanded .footer { + border: 0px solid #222; + border-bottom-width: 1px; +} +.cdm.expanded > hr { + margin-top: 0px; + margin-bottom: 0px; +} +div.cdm.expanded div.header a.title { + font-size: 16px; + color: #999; + font-weight: 600; + transition: color 0.2s, background 0.2s; + text-rendering: optimizelegibility; + font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; +} +div.cdm.expanded.active { + background: white; +} +div.cdm.expanded.active div.header a.title { + color: #b87d2c; +} +div.cdm.expanded.Unread div.header a.title { + color: black; +} +div.cdm.expanded div.content { + color: #ccc; +} +div.cdm.expanded.Unread div.content { + color: black; +} +div.cdm.active div.content { + color: black; +} +div.cdm.vgrlf .feed { + display: none; +} +.cdm div.feed-title { + border: 0px solid #b87d2c; + border-bottom-width: 1px; + padding: 5px 3px 5px 5px; +} +.cdm div.feed-title a.title { + color: #ccc; + font-weight: bold; +} +.cdm div.feed-title a { + color: #ccc; +} +.cdm div.feed-title a:hover { + color: #b87d2c; +} +.cdm div.header span.feed { + float: right; + font-weight: normal; + font-style: italic; +} +.cdm div.header div.feed, +.cdm div.header div.feed a { + vertical-align: middle; + color: #ccc; + font-weight: normal; + font-style: italic; + font-size: 11px; +} +.cdm div.content-inner div.embed-responsive { + overflow: hidden; + padding-bottom: 56.25%; + position: relative; +} +.cdm div.content-inner div.embed-responsive iframe { + border: 0; + bottom: 0; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; +} +.cdm div.header span.author { + white-space: nowrap; + color: #ccc; + font-size: 11px; + font-weight: normal; +} +.cdm .feed a { + border-radius: 4px; + display: inline-block; + padding: 1px 4px 1px 4px; +} +.cdm.expandable { + background-color: #222; + border: 0px solid #222; + border-bottom-width: 1px; +} +.cdm.expandable > hr { + display: none; +} +.cdm.expandable div.header span.titleWrap { + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} +.cdm.expandable .excerpt { + white-space: nowrap; + font-size: 11px; + color: #999; + font-weight: normal; + cursor: pointer; +} +.cdm.expandable:not(.active) { + user-select: none; +} +.cdm.expandable.Unread { + background: white; +} +.cdm.expandable.Selected:not(.active) { + background: #9c7948; +} +.cdm.expandable.Selected:not(.active) a, +.cdm.expandable.Selected:not(.active) .header a.title, +.cdm.expandable.Selected:not(.active) span { + color: white; +} +.cdm.expandable.active { + background: white ! important; +} +div.cdm.expandable.active div.header span.titleWrap { + white-space: normal; +} +div.cdm.expandable div.header a.title { + font-weight: 600; + color: #ccc; + font-size: 14px; + transition: color 0.2s, background 0.2s; + text-rendering: optimizelegibility; + font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; +} +div.cdm.expandable.Unread div.header a.title { + color: black; +} +div.cdm.expandable.active .collapse i.material-icons { + color: #b87d2c; + cursor: pointer; +} +div.cdm.expandable.active .excerpt { + display: none; +} +div.cdm.expandable.active div.header a.title { + color: #b87d2c; + font-size: 16px; + font-weight: 600; + text-rendering: optimizelegibility; + font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; +} +div.cdm.expandable:not(.active) { + cursor: pointer; +} +div.cdm.expandable:not(.active) .content, +div.cdm.expandable:not(.active) .collapse { + display: none; +} +div.cdm.expandable.active .header[stuck], +div.cdm.expanded .header[stuck] { + box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.1); + border: 0 solid #222; + border-bottom-width: 1px; + background: #333 ! important; + opacity: 0.9; + backdrop-filter: blur(6px); +} +body.ttrss_prefs { + background-color: #222; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 14px; +} +body.ttrss_prefs h1, +body.ttrss_prefs h2, +body.ttrss_prefs h3, +body.ttrss_prefs h4 { + font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; + font-weight: 600; + color: #ccc; +} +body.ttrss_prefs .dijitContentPane h1:first-of-type, +body.ttrss_prefs .dijitContentPane h2:first-of-type, +body.ttrss_prefs .dijitContentPane h3:first-of-type { + margin-top: 0px; +} +body.ttrss_prefs #footer, +body.ttrss_prefs #header { + padding: 8px; + font-size: 13px; +} +body.ttrss_prefs #header { + float: right; +} +body.ttrss_prefs #footer_splitter { + display: none; +} +body.ttrss_prefs #footer { + background-color: #222; + font-size: 13px; + border: 0px; + text-align: center; +} +body.ttrss_prefs #header img { + vertical-align: middle; + cursor: pointer; +} +body.ttrss_prefs .dijitTree#filterTree .dijitTreeIcon, +body.ttrss_prefs .dijitTree#labelTree .dijitTreeIcon, +body.ttrss_prefs .dijitTree#filterTree .dijitTreeIcon { + display: none; +} +body.ttrss_prefs .dijitAccordionTitle i.material-icons { + top: -1px; + position: relative; +} +body.ttrss_prefs .dijitAccordionTitleSelected i.material-icons { + color: white; +} +body.ttrss_prefs .dijitDialog #pref-profiles-list .dijitInlineEditBoxDisplayMode { + padding: 0px; +} +body.ttrss_prefs div#feedlistLoading, +body.ttrss_prefs div#filterlistLoading, +body.ttrss_prefs div#labellistLoading { + text-align: center; + padding: 5px; + color: #ccc; +} +body.ttrss_prefs div#feedlistLoading img, +body.ttrss_prefs div#filterlistLoading img, +body.ttrss_prefs div#labellistLoading { + margin-right: 5px; +} +body.ttrss_prefs #errorButton { + color: red; +} +body.ttrss_prefs .user-css-editor { + height: 300px; + width: 575px; +} +body.ttrss_prefs fieldset.prefs { + min-height: 30px; +} +body.ttrss_prefs fieldset.prefs label:first-of-type { + min-width: 300px; +} +body.ttrss_prefs fieldset.prefs .help-text { + display: inline-block; + margin-left: 10px; +} +body.ttrss_prefs fieldset.plugin label.description { + width: 600px; + margin-right: 150px; + display: inline-block; +} +body.ttrss_prefs fieldset.plugin label.description .dijitCheckBox { + margin-right: 10px; +} +body.ttrss_prefs .prefErrorLog tr td { + font-size: 10px; +} +body.ttrss_prefs .prefErrorLog tr .errno { + font-style: italic; + font-weight: bold; + white-space: nowrap; +} +body.ttrss_prefs .prefErrorLog tr .errstr { + word-break: break-all; +} +body.ttrss_prefs .prefErrorLog tr .filename, +body.ttrss_prefs .prefErrorLog tr .login, +body.ttrss_prefs .prefErrorLog tr .timestamp { + color: #ccc; +} +body.ttrss_prefs hr { + border-color: #222; + max-width: 100%; +} +body.ttrss_prefs .phpinfo table { + border-collapse: collapse; +} +body.ttrss_prefs .phpinfo td.e, +body.ttrss_prefs .phpinfo td.v { + border: 1px solid #ccc; +} +body.ttrss_prefs .phpinfo td.e { + font-weight: bold; +} +body.ttrss_prefs .phpinfo td.v { + font-family: monospace; + word-break: break-all; +} +body.ttrss_prefs #filterNewRuleDlg .dijitValidationTextAreaError, +body.ttrss_main #filterNewRuleDlg .dijitValidationTextAreaError { + background: #ffc0c0; +} +body.ttrss_prefs #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError), +body.ttrss_main #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError) { + background: #c0ffc0; +} +body.ttrss_prefs fieldset, +body.ttrss_utility fieldset { + border-width: 0px; + padding: 5px 0px; +} +body.ttrss_prefs fieldset.narrow, +body.ttrss_utility fieldset.narrow { + padding: 2px 0px; +} +body.ttrss_prefs fieldset.align-right, +body.ttrss_utility fieldset.align-right { + text-align: right; +} +body.ttrss_prefs fieldset > label:first-of-type, +body.ttrss_utility fieldset > label:first-of-type { + min-width: 140px; + margin-right: 20px; + display: inline-block; + text-align: right; + font-weight: bold; +} +body.ttrss_prefs fieldset > label.checkbox, +body.ttrss_utility fieldset > label.checkbox { + display: inline; + font-weight: normal; +} +.flat li { + padding: 2px; +} +.flat #feedTree .dijitTreeContent .dijitInline { + vertical-align: baseline; +} +.flat .dijitButton i.material-icons { + position: relative; + top: -1px; +} +.flat .tabLabel > i.material-icons { + position: relative; + top: -1px; +} +.flat #filterDlg_Matches span.filterRule { + color: green; +} +.flat #filterTree .filterRules li.inverse, +.flat #filterDlg_Matches span.filterRule.inverse { + color: red; +} +.flat .dijitToolbar { + font-size: 13px; + padding: 0px; +} +.flat .dijitAccordionContainer { + box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.1); +} +.flat .dijitCheckBox.dijitCheckBoxChecked { + background-color: #69C671; + border-color: #45b74f; +} +.flat .dijitMenu .dijitMenuItem .dijitMenuItemLabel { + padding: 4px 8px; + font-size: 13px; +} +.flat .dijitMenu .dijitMenuItem.dijitDisabled:not(.dijitMenuItemSelected) .dijitMenuItemLabel { + color: #d29745; +} +.flat .dijitMenu .dijitMenuItem td { + padding: 0px; +} +.flat .dijitCheckBox { + margin: 1px; +} +.flat .dijitCheckBox:before { + font-family: "flat-icon"; + content: "\f00c"; + color: white; +} +.flat .dijitTab i.material-icons, +.flat .dijitAccordionInnerContainer:not(.dijitSelected) i.material-icons { + color: #b87d2c; +} +.flat .dijitTree .dijitFolderClosed, +.flat .dijitTree .dijitFolderOpened { + display: none; +} +.flat .dijitTree .dijitTreeRowSelected .filterRules li { + color: white; +} +.flat .dijitTree .dijitTreeRowSelected .dijitTreeExpando { + color: #b87d2c; +} +.flat .dijitTree .dijitTreeNode .dijitTreeRow.dijitTreeRowSelected { + color: white; +} +.flat .dijitTree .dijitTreeRow .dijitTreeExpando { + position: relative; + top: -2px; +} +.flat .dijitTree .labelParam { + float: right; + margin-right: 16px; +} +.flat .dijitTree .dijitTreeRow.filterDisabled { + opacity: 0.5; +} +.flat .dijitTree .dijitTreeRow.filterDisabled .filterRules { + filter: saturate(0%); +} +.flat .dijitTree .feedParam { + float: right; +} +.flat .dijitTree .filterRules { + font-size: 12px; + line-height: normal; + white-space: normal; + margin-left: 28px; +} +.flat .dijitTree .filterRules li { + color: green; +} +.flat .dijitTree .dijitTreeContainer { + max-width: 100%; +} +.flat .dijitTree .dijitTreeRow { + overflow: hidden; + -moz-user-select: none; + text-overflow: ellipsis; +} +.flat label.dijitButton { + border: 1px solid #ccc; + padding: 6px; + border-radius: 4px; + cursor: pointer; + position: relative; + top: 1px; +} +.flat label.dijitButton:hover { + background-color: #222; +} +.flat .dijitTree .dijitTreeNode .dijitTreeRow { + padding: 4px 0px 4px; + border-width: 1px; + color: #ccc; +} +@font-face { + font-family: 'Material Icons'; + font-style: normal; + font-weight: 400; + src: url(../lib/iconfont/MaterialIcons-Regular.eot); + /* For IE6-8 */ + src: local('Material Icons'), local('MaterialIcons-Regular'), url(../lib/iconfont/MaterialIcons-Regular.woff2) format('woff2'), url(../lib/iconfont/MaterialIcons-Regular.woff) format('woff'), url(../lib/iconfont/MaterialIcons-Regular.ttf) format('truetype'); +} +.material-icons { + font-family: 'Material Icons'; + font-weight: normal; + font-style: normal; + font-size: 18px; + /* Preferred icon size */ + display: inline-block; + line-height: 1; + text-transform: none; + letter-spacing: normal; + word-wrap: normal; + white-space: nowrap; + direction: ltr; + vertical-align: middle; + /* Support for all WebKit browsers. */ + -webkit-font-smoothing: antialiased; + /* Support for Safari and Chrome. */ + text-rendering: optimizeLegibility; + /* Support for Firefox. */ + -moz-osx-font-smoothing: grayscale; + /* Support for IE. */ + font-feature-settings: 'liga'; +} +body.ttrss_utility.sanity_failed { + background: #900; +} +body.ttrss_utility { + background: #222; + color: #ccc; + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 14px; + margin: 4em; +} +body.ttrss_utility .content { + background: #333; + border: 1px solid #222; + padding: 20px; + box-shadow: 0px 1px 1px -1px rgba(0, 0, 0, 0.1); +} +body.ttrss_utility .content h2:first-of-type { + margin-top: 0; +} +body.ttrss_utility .content h2, +body.ttrss_utility .content h3, +body.ttrss_utility .content h4 { + color: #b87d2c; + font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; +} +body.ttrss_utility .content h2 { + font-size: 18px; +} +body.ttrss_utility .content h3 { + font-size: 16px; +} +body.ttrss_utility a { + color: #b87d2c; + text-decoration: none; +} +body.ttrss_utility a:hover, +body.ttrss_utility a:focus { + color: #664518; + text-decoration: underline; +} +body.ttrss_utility h1 { + color: gray; + font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 18px; + margin: 10px 0 0 0; +} +body.ttrss_utility .footer { + text-align: center; + padding-top: 10px; +} +body.ttrss_utility .footer a { + color: gray; +} +body.ttrss_utility .footer a:hover { + color: #b87d2c; +} +body.ttrss_utility form { + margin: 0; +} +body.ttrss_utility.otp .content fieldset > label { + display: inline; +} +body.ttrss_utility.ttrss_login { + margin: 0; + padding: 0; + width: 100%; + height: 100%; + position: absolute; + display: flex; + align-items: center; + justify-content: center; +} +body.ttrss_utility.ttrss_login .container { + max-width: 600px; + margin-left: auto; + margin-right: auto; +} +body.ttrss_utility.ttrss_login .container .content { + padding: 40px; +} +body.ttrss_utility.installer, +body.ttrss_utility.feed_debugger { + margin: 2em; +} +body.ttrss_utility.share_popup { + margin: 0; + padding: 0; + background: white; +} +body.ttrss_utility.share_popup .content { + padding: 15px; + border-width: 0; + box-shadow: none; +} +body.ttrss_zoom { + max-width: 900px; + margin: 2em auto; +} +body.ttrss_zoom div.post { + border: 1px solid #222; + background: #333; + box-shadow: 0px 1px 1px -1px rgba(0, 0, 0, 0.1); +} +body.ttrss_zoom div.post .attachments { + display: none; +} +body.ttrss_zoom div.post div.header { + padding-bottom: 10px; + border: 0px solid #222; + border-bottom-width: 1px; + background: #333; + font-size: 12px; + color: #ccc; +} +body.ttrss_zoom div.post div.header .row { + display: flex; + margin-bottom: 4px; + flex-wrap: nowrap; + align-items: center; + justify-content: space-between; +} +body.ttrss_zoom div.post div.content { + font-size: 15px; + line-height: 1.5; + border-width: 0; + padding: 0; +} +body.ttrss_zoom div.post div.content img, +body.ttrss_zoom div.post div.content video { + max-width: 760px; + height: auto; +} +body.ttrss_zoom div.post div.content blockquote { + margin: 5px 0px 5px 0px; + color: #ccc; + padding-left: 10px; + border: 0px solid #222; + border-left-width: 4px; +} +body.ttrss_zoom div.post div.content code { + color: #009900; + font-family: monospace; + font-size: 12px; +} +body.ttrss_zoom div.post div.content pre { + margin: 5px 0px 5px 0px; + padding: 10px; + color: #ccc; + font-family: monospace; + font-size: 12px; + border: 0px solid #ccc; + background: #222; + display: block; + max-width: 98%; + overflow: auto; +} +body.flat.ttrss_main.ttrss_prefs #main, +body.flat.ttrss_main.ttrss_prefs #footer { + background: #222; +} +body.flat.ttrss_main.ttrss_prefs #footer a { + color: #fff; +} +body.flat.ttrss_main.ttrss_prefs td.filename, +body.flat.ttrss_main.ttrss_prefs div.prefHelp { + color: #999999; +} +body.flat.ttrss_main.ttrss_prefs hr { + border-color: #666; +} +body.flat.ttrss_main { + /* + .post .content img, + .cdm .content-inner img, + .post .content video, + .cdm .content-inner video { + transition : opacity 0.2s linear, filter 0.2s linear; + } + + .post .content img:not(:hover), + .cdm .content-inner img:not(:hover), + .post .content video:not(:hover), + .cdm .content-inner video:not(:hover) { + opacity : 0.5; + filter: grayscale(80%); + } */ +} +body.flat.ttrss_main img[src*='indicator_white.gif'] { + filter: invert(1); +} +body.flat.ttrss_main a:hover { + color: #dcae6e; +} +body.flat.ttrss_main #main, +body.flat.ttrss_main #overlay { + color: #ccc; + background: #333; +} +body.flat.ttrss_main #toolbar-frame #toolbar { + background: #222; + color: #e6e6e6; +} +body.flat.ttrss_main #feeds-holder { + background: #222; + box-shadow: inset -1px 0px 2px -1px #666; +} +body.flat.ttrss_main #feeds-holder #feedTree .counterNode.aux, +body.flat.ttrss_main #feeds-holder #feedTree .counterNode.marked { + background: #222; + color: #ccc; + border-color: #333; +} +body.flat.ttrss_main #feeds-holder #feedTree .counterNode.marked { + border-color: #b87d2c; +} +body.flat.ttrss_main #feeds-holder #feedTree .dijitTreeRowSelected { + background: #333; + border-color: #333 transparent; + color: #e6e6e6; +} +body.flat.ttrss_main #feeds-holder #feedTree .dijitTreeRowSelected .dijitTreeLabel { + text-shadow: none; +} +body.flat.ttrss_main #feeds-holder #feedTree i.icon.icon-inbox { + color: #999999; +} +body.flat.ttrss_main #headlines-frame .hl:not(.active):not(.Selected):not(.Unread), +body.flat.ttrss_main #headlines-frame .cdm.expandable:not(.active):not(.Selected):not(.Unread) { + background: #333; +} +body.flat.ttrss_main #headlines-frame .hl.Unread:not(.active):not(.Selected), +body.flat.ttrss_main #headlines-frame .cdm.expandable.Unread:not(.active):not(.Selected) { + background: #222; +} +body.flat.ttrss_main #headlines-frame .cdm.expanded { + background: #333; +} +body.flat.ttrss_main #headlines-frame .hl.Unread .title, +body.flat.ttrss_main #headlines-frame .cdm.Unread .title { + color: #e6e6e6; +} +body.flat.ttrss_main #headlines-frame .hl.active > *, +body.flat.ttrss_main #headlines-frame .hl.Selected > *, +body.flat.ttrss_main #headlines-frame .cdm.expandable.Selected > * { + filter: invert(1); +} +body.flat.ttrss_main #headlines-frame .hl.active > * img, +body.flat.ttrss_main #headlines-frame .hl.Selected > * img, +body.flat.ttrss_main #headlines-frame .cdm.expandable.Selected > * img { + filter: invert(1); +} +body.flat.ttrss_main #headlines-frame .hl.active .dijitCheckBox, +body.flat.ttrss_main #headlines-frame .hl.Selected .dijitCheckBox, +body.flat.ttrss_main #headlines-frame .cdm.expandable.Selected .dijitCheckBox { + filter: invert(1); +} +body.flat.ttrss_main #headlines-frame .hl.Selected.marked i.marked-pic, +body.flat.ttrss_main #headlines-frame .cdm.expandable.Selected.marked i.marked-pic, +body.flat.ttrss_main #headlines-frame .hl.active.marked i.marked-pic { + filter: invert(1); +} +body.flat.ttrss_main #headlines-frame .hl.Selected.published i.pub-pic, +body.flat.ttrss_main #headlines-frame .cdm.expandable.Selected.published i.pub-pic, +body.flat.ttrss_main #headlines-frame .hl.active.published i.pub-pic { + filter: invert(1); +} +body.flat.ttrss_main #headlines-frame .cdm.expanded.active .title, +body.flat.ttrss_main #headlines-frame .cdm.expandable.active .title { + color: #b87d2c; +} +body.flat.ttrss_main #headlines-frame .cdm.expandable.active { + background: #222 ! important; +} +body.flat.ttrss_main #headlines-frame .hl, +body.flat.ttrss_main #headlines-frame .cdm { + color: #ccc; +} +body.flat.ttrss_main #headlines-frame .hl .title, +body.flat.ttrss_main #headlines-frame .cdm .title { + color: #ccc; +} +body.flat.ttrss_main #headlines-frame .hl .author, +body.flat.ttrss_main #headlines-frame .cdm .author { + color: #999999; +} +body.flat.ttrss_main #headlines-frame .hl .updated, +body.flat.ttrss_main #headlines-frame .cdm .updated, +body.flat.ttrss_main #headlines-frame .hl .content, +body.flat.ttrss_main #headlines-frame .cdm .content { + color: #ccc; +} +body.flat.ttrss_main #headlines-frame .hl .feed a, +body.flat.ttrss_main #headlines-frame .cdm .feed a { + color: #e6e6e6; +} +body.flat.ttrss_main #headlines-frame .cdm .footer { + border-color: #222; + color: #ccc; +} +body.flat.ttrss_main #headlines-frame .left i.material-icons, +body.flat.ttrss_main #headlines-frame .left .dijitCheckBox { + opacity: 0.7; +} +body.flat.ttrss_main .dijitToolbar .dijitSelect .dijitButtonContents, +body.flat.ttrss_main .dijitToolbar .dijitSelect .dijitButtonNode { + transition: background-color 0.3s linear; +} +body.flat.ttrss_main .dijitToolbar .dijitSelect:not(.dijitHover) .dijitButtonContents, +body.flat.ttrss_main .dijitToolbar .dijitSelect:not(.dijitHover) .dijitButtonNode { + background-color: #222; +} +body.flat.ttrss_main .dijitCheckBox:not(.dijitChecked)::before { + color: #999999; + background: #222; +} +body.flat.ttrss_main .text-muted { + color: #999999; +} +body.flat.ttrss_main .dijitAccordionInnerContainerSelected .dijitAccordionTitle { + color: white; +} +body.flat.ttrss_main .dijitDialog .dijitDialogPaneContent { + background: #222; +} +body.flat.ttrss_main .dijitTab:not(.dijitTabChecked) { + background: #222; +} +body.flat.ttrss_main .dijitTab.dijitTabChecked.dijitTabHover { + color: #e6e6e6; +} +body.flat.ttrss_main label.dijitButton { + border: 1px solid #666; +} +body.flat.ttrss_main label.dijitButton:hover { + border-color: #2f2f2f; + background-color: #333; +} +body.flat.ttrss_main textarea { + color: #e6e6e6; +} +body.flat.ttrss_main code { + color: #c90 ! important; +} +body.flat.ttrss_main .panel { + background-color: #222; + border-color: #666; +} +body.flat.ttrss_main .dijitDialog .panel { + background-color: #333; +} +body.flat.ttrss_main #headlines-frame blockquote, +body.flat.ttrss_main #content-insert blockquote { + color: #ccc; + border-color: #b87d2c; +} +body.flat.ttrss_main pre { + color: #ccc; + background: #222 ! important; +} +body.flat.ttrss_main ul#filterDlg_Matches, +body.flat.ttrss_main ul#filterDlg_Actions { + background: #222; + border-color: #666; +} +body.flat.ttrss_main .article-note { + background: #b87d2c; + border-color: #b87d2c; + color: #333; +} +body.flat.ttrss_main .article-note i.material-icons { + color: #333; +} +body.flat.ttrss_main ::-webkit-scrollbar { + width: 4px; +} +body.flat.ttrss_main ::-webkit-scrollbar-thumb { + background-color: #666; +} +body.flat.ttrss_main ::-webkit-scrollbar-track { + background-color: #222; +} +body.flat.ttrss_main .alert { + background: #222; + border-color: #664518; + color: #b87d2c; +} +body.flat.ttrss_main .alert.alert-info { + color: #3a87ad; + border-color: #204b61; +} +body.flat.ttrss_main .alert.alert-danger { + color: #b94a48; + border-color: #702c2b; +} +body.flat.ttrss_main #filterNewRuleDlg .dijitValidationTextAreaError { + background: #503030; +} +body.flat.ttrss_main #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError) { + background: #305030; +} +/* rules specific to compact.css */ +body.ttrss_main.ttrss_index.flat #feedTree.dijitTree .dijitTreeLabel { + font-size: 13px ! important; +} +body.ttrss_main.ttrss_index.flat .dijitMenu .dijitMenuItemLabel, +body.ttrss_main.ttrss_index.flat .content-inner, +body.ttrss_main.ttrss_index.flat #content-insert, +body.ttrss_main.ttrss_index.flat .cdm .content, +body.ttrss_main.ttrss_index.flat .post .content { + font-size: 12px ! important; +} +body.ttrss_main.ttrss_index.flat div[id*=RROW] i.material-icons { + font-size: 18px; +} +body.ttrss_main.ttrss_index.flat .hl, +body.ttrss_main.ttrss_index.flat .post .header .title, +body.ttrss_main.ttrss_index.flat .cdm .title { + font-size: 13px ! important; +} diff --git a/themes/compact_night.less b/themes/compact_night.less new file mode 100644 index 000000000..5cefa726d --- /dev/null +++ b/themes/compact_night.less @@ -0,0 +1,2 @@ +@import "night_base.less"; +@import "compact_base.less"; diff --git a/themes/light.css b/themes/light.css index f8f8b65ce..d713e071d 100644 --- a/themes/light.css +++ b/themes/light.css @@ -70,12 +70,19 @@ body.ttrss_main div.post div.content video { max-width: 98%; height: auto; } -body.ttrss_main div.post div.content p { - hyphens: auto; +body.ttrss_main div.post div.content div.embed-responsive { + overflow: hidden; + padding-bottom: 56.25%; + position: relative; } -body.ttrss_main div.post div.content iframe { - min-width: 50%; - max-width: 98%; +body.ttrss_main div.post div.content div.embed-responsive iframe { + border: 0; + bottom: 0; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; } body.ttrss_main .inline-player { display: flex; @@ -661,13 +668,6 @@ body.ttrss_main #headlines-frame div.feed-title a { body.ttrss_main #headlines-frame div.feed-title a:hover { color: #257aa7; } -body.ttrss_main #headlines-frame.smooth-scroll { - scroll-behavior: smooth; -} -body.ttrss_main #headlines-frame.forbid-smooth-scroll, -body.ttrss_main #content-insert.forbid-smooth-scroll { - scroll-behavior: auto; -} body.ttrss_main #toolbar-frame_splitter { display: none; } @@ -754,7 +754,6 @@ body.ttrss_main #content-insert { line-height: 1.5; overflow: auto; -webkit-overflow-scrolling: touch; - scroll-behavior: smooth; } body.ttrss_main img.feed-icon, body.ttrss_main img.icon { @@ -865,6 +864,22 @@ body.ttrss_main #feedEditDlg img.feedIcon { height: auto; width: auto; } +body.ttrss_main .dijitTooltipContents { + background: #1c5c7d; + color: #f5f5f5; +} +body.ttrss_main .dijitTooltipRight .dijitTooltipConnector { + border-right-color: #1c5c7d; +} +body.ttrss_main .dijitTooltipLeft .dijitTooltipConnector { + border-left-color: #1c5c7d; +} +body.ttrss_main .dijitTooltipBelow .dijitTooltipConnector { + border-bottom-color: #1c5c7d; +} +body.ttrss_main .dijitTooltipAbove .dijitTooltipConnector { + border-top-color: #1c5c7d; +} body.ttrss_main .dijitDialog h1:first-of-type, body.ttrss_main .dijitDialog h2:first-of-type, body.ttrss_main .dijitDialog h3:first-of-type, @@ -877,10 +892,10 @@ body.ttrss_main[view-mode="marked"] #feeds-holder #feedTree .dijitTreeRow.Has_Ma body.ttrss_main[view-mode="marked"] #feeds-holder #feedTree .dijitTreeRow.Has_Marked .counterNode.marked { display: inline-block; } -body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.AlwaysVisible):not(.Special):not(.Has_Marked) { +body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.AlwaysVisible):not(.Special):not(.Has_Marked) { display: none; } -body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.AlwaysVisible):not(.Has_Marked) { +body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.AlwaysVisible):not(.Has_Marked) { display: none; } body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow.Unread .counterNode.unread { @@ -889,10 +904,10 @@ body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow. body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow.Has_Aux:not(.Unread) .counterNode.aux { display: inline-block; } -body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.Unread):not(.AlwaysVisible):not(.Special) { +body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.Unread):not(.AlwaysVisible):not(.Special) { display: none; } -body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.Unread):not(.AlwaysVisible) { +body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.Unread):not(.AlwaysVisible) { display: none; } body.ttrss_main #toolbar-headlines i.icon-syndicate { @@ -917,12 +932,10 @@ body.ttrss_main i.icon-no-feed { body.ttrss_main .dijitTreeRow.UpdatesDisabled .dijitTreeLabel { opacity: 0.5; } -body.ttrss_main #floatingTitle.marked i.marked-pic, body.ttrss_main .cdm.marked .left i.marked-pic, body.ttrss_main .hl.marked .left i.marked-pic { color: #ffc069; } -body.ttrss_main #floatingTitle.published i.pub-pic, body.ttrss_main .cdm.published .left i.pub-pic, body.ttrss_main .hl.published .left i.pub-pic { color: #ff7c4b; @@ -1116,6 +1129,11 @@ video::-webkit-media-controls-overlay-play-button { .cdm i.material-icons { color: #777; } +.cdm .header { + position: sticky; + top: 0; + z-index: 3; +} .cdm .header, .cdm .footer { display: flex; @@ -1128,6 +1146,9 @@ video::-webkit-media-controls-overlay-play-button { margin: 0px 4px; vertical-align: middle; } +.cdm .header-sticky-guard { + height: 0; +} .cdm .header { align-items: center; } @@ -1207,9 +1228,6 @@ video::-webkit-media-controls-overlay-play-button { margin-top: 0px; margin-bottom: 0px; } -div.cdm.expanded div.header { - background: transparent ! important; -} div.cdm.expanded div.header a.title { font-size: 16px; color: #999; @@ -1267,15 +1285,19 @@ div.cdm.vgrlf .feed { font-style: italic; font-size: 11px; } -.cdm div.content-inner p { - /*max-width : 650px;*/ - -webkit-hyphens: auto; - -moz-hyphens: auto; - hyphens: auto; +.cdm div.content-inner div.embed-responsive { + overflow: hidden; + padding-bottom: 56.25%; + position: relative; } -.cdm div.content-inner iframe { - min-width: 50%; - max-width: 98%; +.cdm div.content-inner div.embed-responsive iframe { + border: 0; + bottom: 0; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; } .cdm div.header span.author { white-space: nowrap; @@ -1288,115 +1310,6 @@ div.cdm.vgrlf .feed { display: inline-block; padding: 1px 4px 1px 4px; } -#main:not(.expandable) div#floatingTitle .collapse { - display: none; -} -div#floatingTitle { - position: absolute; - z-index: 5; - top: 0px; - right: 0px; - left: 0px; - border: 0px solid #ddd; - border-bottom-width: 1px; - background: white; - color: #555; - display: flex; - flex-direction: row; - flex-wrap: nowrap; - box-shadow: 0px 1px 1px -1px rgba(0, 0, 0, 0.1); - align-items: center; -} -div#floatingTitle > * { - white-space: nowrap; - padding: 4px; -} -div#floatingTitle .left, -div#floatingTitle .right { - display: flex; - align-items: center; -} -div#floatingTitle .left i.material-icons, -div#floatingTitle .right i.material-icons { - margin-left: 2px; - font-size: 21px; - padding: 2px; - user-select: none; -} -div#floatingTitle .left i.icon-anchor, -div#floatingTitle .right i.icon-anchor { - margin-left: 0px; - margin-right: 1px; - padding: 0px; - color: #ccc; - cursor: pointer; -} -div#floatingTitle .excerpt { - display: none; -} -div#floatingTitle .collapse i.material-icons { - color: #257aa7; - cursor: pointer; -} -div#floatingTitle span.author { - color: #555; - font-size: 11px; - font-weight: normal; -} -div#floatingTitle a.title { - font-size: 16px; - color: #999; - transition: color 0.2s, background 0.2s; - font-weight: 600; - text-rendering: optimizelegibility; - font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; -} -div#floatingTitle div.feed { - padding-right: 10px; - color: #555; - font-weight: normal; - font-style: italic; - font-size: 11px; - white-space: nowrap; -} -div#floatingTitle div.feed a { - border-radius: 4px; - display: inline-block; - padding: 1px 4px 1px 4px; -} -div#floatingTitle span.updated { - padding-right: 10px; - white-space: nowrap; - color: #555; - font-size: 11px; -} -div#floatingTitle div.feed a { - color: #555; -} -div#floatingTitle span.titleWrap { - width: 100%; - white-space: normal; -} -div#floatingTitle .feed-title > * { - display: table-cell; - vertical-align: middle; -} -div#floatingTitle .feed-title a.title { - width: 100%; -} -div#floatingTitle .feed-title a.catchup { - text-align: right; - color: #555; - padding-right: 10px; - font-size: 11px; - white-space: nowrap; -} -div#floatingTitle .feed-title a.catchup:hover { - color: #257aa7; -} -div#floatingTitle.Unread a.title { - color: black; -} .cdm.expandable { background-color: #f5f5f5; border: 0px solid #ddd; @@ -1469,6 +1382,15 @@ div.cdm.expandable:not(.active) .content, div.cdm.expandable:not(.active) .collapse { display: none; } +div.cdm.expandable.active .header[stuck], +div.cdm.expanded .header[stuck] { + box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.1); + border: 0 solid #ddd; + border-bottom-width: 1px; + background: white ! important; + opacity: 0.9; + backdrop-filter: blur(6px); +} body.ttrss_prefs { background-color: #f5f5f5; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; @@ -1594,12 +1516,12 @@ body.ttrss_prefs .phpinfo td.v { font-family: monospace; word-break: break-all; } -body.ttrss_prefs #filterNewRuleDlg .invalid, -body.ttrss_main #filterNewRuleDlg .invalid { +body.ttrss_prefs #filterNewRuleDlg .dijitValidationTextAreaError, +body.ttrss_main #filterNewRuleDlg .dijitValidationTextAreaError { background: #ffc0c0; } -body.ttrss_prefs #filterNewRuleDlg .valid, -body.ttrss_main #filterNewRuleDlg .valid { +body.ttrss_prefs #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError), +body.ttrss_main #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError) { background: #c0ffc0; } body.ttrss_prefs fieldset, @@ -1906,11 +1828,6 @@ body.ttrss_zoom div.post div.header .row { align-items: center; justify-content: space-between; } -body.ttrss_zoom div.post p { - -webkit-hyphens: auto; - -moz-hyphens: auto; - hyphens: auto; -} body.ttrss_zoom div.post div.content { font-size: 15px; line-height: 1.5; @@ -1946,4 +1863,3 @@ body.ttrss_zoom div.post div.content pre { max-width: 98%; overflow: auto; } -/*# sourceMappingURL=light.css.map */
\ No newline at end of file diff --git a/themes/light.css.map b/themes/light.css.map deleted file mode 100644 index 00664b779..000000000 --- a/themes/light.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["C:/Users/fox/Projects/tt-rss/css/default.less","C:/Users/fox/Projects/tt-rss/css/defines.less","C:/Users/fox/Projects/tt-rss/css/tt-rss.less","C:/Users/fox/Projects/tt-rss/css/cdm.less","C:/Users/fox/Projects/tt-rss/css/prefs.less","C:/Users/fox/Projects/tt-rss/css/utility.less","C:/Users/fox/Projects/tt-rss/css/dijit_basic.less","C:/Users/fox/Projects/tt-rss/css/dijit_light.less","C:/Users/fox/Projects/tt-rss/css/zoom.less"],"names":[],"mappings":"QAGQ;ACcR,IAAI;AACJ,IAAI;AACJ;EACE,kBAAA;EACA,WAAA;EACA,YAAA;EACA,SAAA;EACA,UAAA;EACA,SAAA;;ACzBF,IAAI;EACH,iBAAA;EACA,YAAA;EACA,aAAa,8CAAb;EACA,eAAA;EACA,gBAAA;;AALD,IAAI,WAOH;EACC,aAAA;;AARF,IAAI,WAWH,IAAG;EACF,YAAA;EACA,eAAA;;AAbF,IAAI,WAWH,IAAG,KAIF,IAAG;EACF,YAAA;EACA,cAAA;EACA,sBAAA;EACA,wBAAA;EACA,mBAAA;;AApBH,IAAI,WAWH,IAAG,KAIF,IAAG,OAOF;AAtBH,IAAI,WAWH,IAAG,KAIF,IAAG,OAOK;EACN,aAAA;;AAvBJ,IAAI,WAWH,IAAG,KAIF,IAAG,OAWF;EACC,aAAA;EACA,kBAAA;EACA,iBAAA;EACA,mBAAA;EACA,8BAAA;;AA/BJ,IAAI,WAWH,IAAG,KAIF,IAAG,OAmBF;EACC,YAAA;;AAnCJ,IAAI,WAWH,IAAG,KAIF,IAAG,OAuBF;EACC,mBAAA;;AAvCJ,IAAI,WAWH,IAAG,KAIF,IAAG,OA2BF;AA1CH,IAAI,WAWH,IAAG,KAIF,IAAG,OA2BG,EAAC;EACL,eAAA;EACA,sBAAA;EACA,WAAA;;AA7CJ,IAAI,WAWH,IAAG,KAIF,IAAG,OAiCF;EACC,YAAA;EACA,eAAA;EACA,gBAAA;EACA,kCAAA;EACA,aDrDY,qBAAqB,qBAAqB,yBAAyB,oBAAoB,8CCqDnG;;AArDJ,IAAI,WAWH,IAAG,KA8CF,IAAG;EACF,aAAA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gBAAA;;ACXF,IAAI;EACH,gBAAA;EACA,gBAAA;;AAFD,IAAI,WAIH,IAAG;EACF,sBAAA;EACA,iBAAA;EACA,+CAAA;;AAPF,IAAI,WAIH,IAAG,KAKF;EACC,aAAA;;AAVH,IAAI,WAIH,IAAG,KASF,IAAG;EACF,oBAAA;EACA,sBAAA;EACA,wBAAA;EACA,iBAAA;EACA,eAAA;EACA,WAAA;;AAnBH,IAAI,WAIH,IAAG,KASF,IAAG,OAQF;EACC,aAAA;EACA,kBAAA;EACA,iBAAA;EACA,mBAAA;EACA,8BAAA;;AA1BJ,IAAI,WAIH,IAAG,KA0BF;EACC,qBAAA;EACA,kBAAA;EACA,aAAA;;AAjCH,IAAI,WAIH,IAAG,KAgCF,IAAG;EACF,eAAA;EACA,gBAAA;EACA,eAAA;EACA,UAAA;;AAxCH,IAAI,WAIH,IAAG,KAgCF,IAAG,QAMF;AA1CH,IAAI,WAIH,IAAG,KAgCF,IAAG,QAMG;EACJ,gBAAA;EACA,YAAA;;AA5CJ,IAAI,WAIH,IAAG,KAgCF,IAAG,QAWF;EACC,uBAAA;EACA,WAAA;EACA,kBAAA;EACA,sBAAA;EACA,sBAAA;;AApDJ,IAAI,WAIH,IAAG,KAgCF,IAAG,QAmBF;EACC,cAAA;EACA,sBAAA;EACA,eAAA;;AA1DJ,IAAI,WAIH,IAAG,KAgCF,IAAG,QAyBF;EACC,uBAAA;EACA,aAAA;EACA,WAAA;EACA,sBAAA;EACA,eAAA;EACA,sBAAA;EACA,mBAAA;EACA,cAAA;EACA,cAAA;EACA,cAAA","file":"light.css"}
\ No newline at end of file diff --git a/themes/light.less b/themes/light.less index e0f21f110..2e9b4da6a 100644 --- a/themes/light.less +++ b/themes/light.less @@ -1 +1 @@ -@import "../css/default.less"; +@import "light/light_base.less"; diff --git a/css/cdm.less b/themes/light/cdm.less index 7ac28913e..3a5b602f2 100755..100644 --- a/css/cdm.less +++ b/themes/light/cdm.less @@ -3,6 +3,12 @@ color : @color-icon; } + .header { + position: sticky; + top : 0; + z-index: 3; + } + .header, .footer { display : flex; flex-direction : row; @@ -15,6 +21,10 @@ vertical-align: middle; } + .header-sticky-guard { + height : 0; + } + .header { align-items : center; @@ -110,10 +120,6 @@ } -div.cdm.expanded div.header { - background : transparent ! important; -} - div.cdm.expanded div.header a.title { font-size : 16px; color : #999; @@ -185,16 +191,20 @@ div.cdm.vgrlf .feed { font-size: 11px; } - div.content-inner p { - /*max-width : 650px;*/ - -webkit-hyphens: auto; - -moz-hyphens: auto; - hyphens: auto; - } - - div.content-inner iframe { - min-width : 50%; - max-width : 98%; + div.content-inner div.embed-responsive { + overflow : hidden; + padding-bottom : @embed-responsive-padding; + position : relative; + + iframe { + border : 0; + bottom : 0; + height : 100%; + left : 0; + position : absolute; + top : 0; + width : 100%; + } } div.header span.author { @@ -211,137 +221,6 @@ div.cdm.vgrlf .feed { } } -#main:not(.expandable) div#floatingTitle { - .collapse { - display : none; - } -} - -div#floatingTitle { - position : absolute; - z-index : 5; - top : 0px; - right : 0px; - left : 0px; - border: 0px solid @border-default; - border-bottom-width: 1px; - background : white; - color : @default-text; - display : flex; - flex-direction : row; - flex-wrap : nowrap; - box-shadow : 0px 1px 1px -1px rgba(0,0,0,0.1); - align-items: center; - - > * { - white-space : nowrap; - padding : 4px; - } - - .left, .right { - display : flex; - align-items : center; - - i.material-icons { - margin-left : 2px; - font-size : 21px; - padding : 2px; - user-select: none; - } - - i.icon-anchor { - margin-left : 0px; - margin-right : 1px; // replaces checkbox which is a bit wider - padding : 0px; - color : #ccc; - cursor : pointer; - } - } - - .excerpt { - display : none; - } - - .collapse i.material-icons { - color : @color-accent; - cursor : pointer; - } - - span.author { - color : @default-text; - font-size : 11px; - font-weight : normal; - } - - a.title { - font-size : 16px; - color : #999; - transition : color 0.2s, background 0.2s; - font-weight : 600; - text-rendering: optimizelegibility; - font-family : @fonts-ui-bold; - } - - div.feed { - padding-right : 10px; - color : @default-text; - font-weight : normal; - font-style : italic; - font-size : 11px; - white-space : nowrap; - } - - div.feed a { - border-radius : 4px; - display : inline-block; - padding : 1px 4px 1px 4px; - } - - span.updated { - padding-right : 10px; - white-space : nowrap; - color : @default-text; - font-size : 11px; - } - - div.feed a { - color : @default-text; - } - - span.titleWrap { - width : 100%; - white-space : normal; - } - - .feed-title { - > * { - display : table-cell; - vertical-align : middle; - } - - a.title { - width : 100%; - } - - a.catchup { - text-align : right; - color : @default-text; - padding-right : 10px; - font-size : 11px; - white-space : nowrap; - } - - a.catchup:hover { - color : @color-link; - } - - } -} - -div#floatingTitle.Unread a.title { - color : black; -} - .cdm.expandable { background-color : @color-panel-bg; border: 0px solid @border-default; @@ -432,3 +311,17 @@ div.cdm.expandable:not(.active) { display : none; } } + +div.cdm { + &.expandable.active, + &.expanded { + .header[stuck] { + box-shadow : 0 1px 1px -1px rgba(0,0,0,0.1); + border: 0 solid @border-default; + border-bottom-width: 1px; + background : @default-bg ! important; + opacity: 0.9; + backdrop-filter: blur(6px); + } + } +} diff --git a/css/defines.less b/themes/light/defines.less index 1926a06a5..7de7a7686 100644 --- a/css/defines.less +++ b/themes/light/defines.less @@ -14,6 +14,10 @@ @border-default : #ddd; @default-text: #555; @color-icon: #777; +@color-tooltip-fg: @color-panel-bg; +@color-tooltip-bg: darken(@color-accent, 10%); + +@embed-responsive-padding: 56.25%; // Use 56.25% for 16:9 aspect ratio, 75% for 4:3. body.ttrss_main, body.ttrss_prefs, diff --git a/css/dijit_basic.less b/themes/light/dijit_basic.less index a00cc5e59..a00cc5e59 100644 --- a/css/dijit_basic.less +++ b/themes/light/dijit_basic.less diff --git a/css/dijit_light.less b/themes/light/dijit_light.less index 53b098bba..53b098bba 100644 --- a/css/dijit_light.less +++ b/themes/light/dijit_light.less diff --git a/css/default.less b/themes/light/light_base.less index 3e94b6a09..769f23efe 100644 --- a/css/default.less +++ b/themes/light/light_base.less @@ -1,4 +1,4 @@ @import "defines.less"; @import "dijit_light.less"; @import "zoom.less"; -@import "../lib/flat-ttrss/flat_combined.css";
\ No newline at end of file +@import "../lib/flat-ttrss/flat_combined.css"; diff --git a/css/prefs.less b/themes/light/prefs.less index 7b187e584..92084a9c8 100644 --- a/css/prefs.less +++ b/themes/light/prefs.less @@ -155,10 +155,10 @@ body.ttrss_prefs { body.ttrss_prefs, body.ttrss_main { #filterNewRuleDlg { - .invalid { + .dijitValidationTextAreaError { background : #ffc0c0; } - .valid { + .dijitValidationTextArea:not(.dijitValidationTextAreaError) { background : #c0ffc0; } } diff --git a/css/tt-rss.less b/themes/light/tt-rss.less index 82be48d75..b3fba8cf9 100755..100644 --- a/css/tt-rss.less +++ b/themes/light/tt-rss.less @@ -66,13 +66,20 @@ body.ttrss_main { height: auto; } - p { - hyphens: auto; - } + div.embed-responsive { + overflow : hidden; + padding-bottom : @embed-responsive-padding; + position : relative; - iframe { - min-width : 50%; - max-width : 98%; + iframe { + border : 0; + bottom : 0; + height : 100%; + left : 0; + position : absolute; + top : 0; + width : 100%; + } } } } @@ -777,15 +784,6 @@ body.ttrss_main { } } - #headlines-frame.smooth-scroll { - scroll-behavior: smooth; - } - - #headlines-frame.forbid-smooth-scroll, - #content-insert.forbid-smooth-scroll { - scroll-behavior : auto; - } - #toolbar-frame_splitter { display : none; } @@ -885,7 +883,6 @@ body.ttrss_main { line-height: 1.5; overflow : auto; -webkit-overflow-scrolling : touch; - scroll-behavior: smooth; } img.feed-icon, img.icon { @@ -1018,6 +1015,27 @@ body.ttrss_main { height : auto; width : auto; } + + .dijitTooltipContents { + background : @color-tooltip-bg; + color : @color-tooltip-fg; + } + + .dijitTooltipRight .dijitTooltipConnector { + border-right-color : @color-tooltip-bg; + } + + .dijitTooltipLeft .dijitTooltipConnector { + border-left-color : @color-tooltip-bg; + } + + .dijitTooltipBelow .dijitTooltipConnector { + border-bottom-color : @color-tooltip-bg; + } + + .dijitTooltipAbove .dijitTooltipConnector { + border-top-color : @color-tooltip-bg; + } } body.ttrss_main .dijitDialog { @@ -1039,12 +1057,12 @@ body.ttrss_main[view-mode="marked"] #feeds-holder #feedTree { } body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree - .dijitTreeRow:not(.dijitTreeRowSelected):not(.AlwaysVisible):not(.Special):not(.Has_Marked) { + .dijitTreeRow:not(.AlwaysVisible):not(.Special):not(.Has_Marked) { display : none; } body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree - .dijitTreeRow:not(.dijitTreeRowSelected):not(.AlwaysVisible):not(.Has_Marked) { + .dijitTreeRow:not(.AlwaysVisible):not(.Has_Marked) { display : none; } @@ -1059,12 +1077,12 @@ body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree { } body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree - .dijitTreeRow:not(.dijitTreeRowSelected):not(.Unread):not(.AlwaysVisible):not(.Special) { + .dijitTreeRow:not(.Unread):not(.AlwaysVisible):not(.Special) { display : none; } body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree - .dijitTreeRow:not(.dijitTreeRowSelected):not(.Unread):not(.AlwaysVisible) { + .dijitTreeRow:not(.Unread):not(.AlwaysVisible) { display : none; } @@ -1096,13 +1114,11 @@ body.ttrss_main { opacity : 0.5; } - #floatingTitle.marked i.marked-pic, .cdm.marked .left i.marked-pic, .hl.marked .left i.marked-pic { color : @color-marked; } - #floatingTitle.published i.pub-pic, .cdm.published .left i.pub-pic, .hl.published .left i.pub-pic { color : @color-published; diff --git a/css/utility.less b/themes/light/utility.less index 087c4ced3..087c4ced3 100644 --- a/css/utility.less +++ b/themes/light/utility.less diff --git a/css/zoom.less b/themes/light/zoom.less index ae8de7dba..e06939ac2 100644 --- a/css/zoom.less +++ b/themes/light/zoom.less @@ -28,12 +28,6 @@ body.ttrss_zoom { } } - p { - -webkit-hyphens: auto; - -moz-hyphens: auto; - hyphens: auto; - } - div.content { font-size : 15px; line-height : 1.5; diff --git a/themes/night.css b/themes/night.css index 35cced3cf..7edc043a0 100644 --- a/themes/night.css +++ b/themes/night.css @@ -71,12 +71,19 @@ body.ttrss_main div.post div.content video { max-width: 98%; height: auto; } -body.ttrss_main div.post div.content p { - hyphens: auto; +body.ttrss_main div.post div.content div.embed-responsive { + overflow: hidden; + padding-bottom: 56.25%; + position: relative; } -body.ttrss_main div.post div.content iframe { - min-width: 50%; - max-width: 98%; +body.ttrss_main div.post div.content div.embed-responsive iframe { + border: 0; + bottom: 0; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; } body.ttrss_main .inline-player { display: flex; @@ -662,13 +669,6 @@ body.ttrss_main #headlines-frame div.feed-title a { body.ttrss_main #headlines-frame div.feed-title a:hover { color: #b87d2c; } -body.ttrss_main #headlines-frame.smooth-scroll { - scroll-behavior: smooth; -} -body.ttrss_main #headlines-frame.forbid-smooth-scroll, -body.ttrss_main #content-insert.forbid-smooth-scroll { - scroll-behavior: auto; -} body.ttrss_main #toolbar-frame_splitter { display: none; } @@ -755,7 +755,6 @@ body.ttrss_main #content-insert { line-height: 1.5; overflow: auto; -webkit-overflow-scrolling: touch; - scroll-behavior: smooth; } body.ttrss_main img.feed-icon, body.ttrss_main img.icon { @@ -866,6 +865,22 @@ body.ttrss_main #feedEditDlg img.feedIcon { height: auto; width: auto; } +body.ttrss_main .dijitTooltipContents { + background: #d29745; + color: #222; +} +body.ttrss_main .dijitTooltipRight .dijitTooltipConnector { + border-right-color: #d29745; +} +body.ttrss_main .dijitTooltipLeft .dijitTooltipConnector { + border-left-color: #d29745; +} +body.ttrss_main .dijitTooltipBelow .dijitTooltipConnector { + border-bottom-color: #d29745; +} +body.ttrss_main .dijitTooltipAbove .dijitTooltipConnector { + border-top-color: #d29745; +} body.ttrss_main .dijitDialog h1:first-of-type, body.ttrss_main .dijitDialog h2:first-of-type, body.ttrss_main .dijitDialog h3:first-of-type, @@ -878,10 +893,10 @@ body.ttrss_main[view-mode="marked"] #feeds-holder #feedTree .dijitTreeRow.Has_Ma body.ttrss_main[view-mode="marked"] #feeds-holder #feedTree .dijitTreeRow.Has_Marked .counterNode.marked { display: inline-block; } -body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.AlwaysVisible):not(.Special):not(.Has_Marked) { +body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.AlwaysVisible):not(.Special):not(.Has_Marked) { display: none; } -body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.AlwaysVisible):not(.Has_Marked) { +body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.AlwaysVisible):not(.Has_Marked) { display: none; } body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow.Unread .counterNode.unread { @@ -890,10 +905,10 @@ body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow. body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow.Has_Aux:not(.Unread) .counterNode.aux { display: inline-block; } -body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.Unread):not(.AlwaysVisible):not(.Special) { +body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.Unread):not(.AlwaysVisible):not(.Special) { display: none; } -body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.Unread):not(.AlwaysVisible) { +body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.Unread):not(.AlwaysVisible) { display: none; } body.ttrss_main #toolbar-headlines i.icon-syndicate { @@ -918,12 +933,10 @@ body.ttrss_main i.icon-no-feed { body.ttrss_main .dijitTreeRow.UpdatesDisabled .dijitTreeLabel { opacity: 0.5; } -body.ttrss_main #floatingTitle.marked i.marked-pic, body.ttrss_main .cdm.marked .left i.marked-pic, body.ttrss_main .hl.marked .left i.marked-pic { color: #ffc069; } -body.ttrss_main #floatingTitle.published i.pub-pic, body.ttrss_main .cdm.published .left i.pub-pic, body.ttrss_main .hl.published .left i.pub-pic { color: #ff7c4b; @@ -1117,6 +1130,11 @@ video::-webkit-media-controls-overlay-play-button { .cdm i.material-icons { color: #777; } +.cdm .header { + position: sticky; + top: 0; + z-index: 3; +} .cdm .header, .cdm .footer { display: flex; @@ -1129,6 +1147,9 @@ video::-webkit-media-controls-overlay-play-button { margin: 0px 4px; vertical-align: middle; } +.cdm .header-sticky-guard { + height: 0; +} .cdm .header { align-items: center; } @@ -1208,9 +1229,6 @@ video::-webkit-media-controls-overlay-play-button { margin-top: 0px; margin-bottom: 0px; } -div.cdm.expanded div.header { - background: transparent ! important; -} div.cdm.expanded div.header a.title { font-size: 16px; color: #999; @@ -1268,15 +1286,19 @@ div.cdm.vgrlf .feed { font-style: italic; font-size: 11px; } -.cdm div.content-inner p { - /*max-width : 650px;*/ - -webkit-hyphens: auto; - -moz-hyphens: auto; - hyphens: auto; +.cdm div.content-inner div.embed-responsive { + overflow: hidden; + padding-bottom: 56.25%; + position: relative; } -.cdm div.content-inner iframe { - min-width: 50%; - max-width: 98%; +.cdm div.content-inner div.embed-responsive iframe { + border: 0; + bottom: 0; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; } .cdm div.header span.author { white-space: nowrap; @@ -1289,115 +1311,6 @@ div.cdm.vgrlf .feed { display: inline-block; padding: 1px 4px 1px 4px; } -#main:not(.expandable) div#floatingTitle .collapse { - display: none; -} -div#floatingTitle { - position: absolute; - z-index: 5; - top: 0px; - right: 0px; - left: 0px; - border: 0px solid #222; - border-bottom-width: 1px; - background: white; - color: #ccc; - display: flex; - flex-direction: row; - flex-wrap: nowrap; - box-shadow: 0px 1px 1px -1px rgba(0, 0, 0, 0.1); - align-items: center; -} -div#floatingTitle > * { - white-space: nowrap; - padding: 4px; -} -div#floatingTitle .left, -div#floatingTitle .right { - display: flex; - align-items: center; -} -div#floatingTitle .left i.material-icons, -div#floatingTitle .right i.material-icons { - margin-left: 2px; - font-size: 21px; - padding: 2px; - user-select: none; -} -div#floatingTitle .left i.icon-anchor, -div#floatingTitle .right i.icon-anchor { - margin-left: 0px; - margin-right: 1px; - padding: 0px; - color: #ccc; - cursor: pointer; -} -div#floatingTitle .excerpt { - display: none; -} -div#floatingTitle .collapse i.material-icons { - color: #b87d2c; - cursor: pointer; -} -div#floatingTitle span.author { - color: #ccc; - font-size: 11px; - font-weight: normal; -} -div#floatingTitle a.title { - font-size: 16px; - color: #999; - transition: color 0.2s, background 0.2s; - font-weight: 600; - text-rendering: optimizelegibility; - font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; -} -div#floatingTitle div.feed { - padding-right: 10px; - color: #ccc; - font-weight: normal; - font-style: italic; - font-size: 11px; - white-space: nowrap; -} -div#floatingTitle div.feed a { - border-radius: 4px; - display: inline-block; - padding: 1px 4px 1px 4px; -} -div#floatingTitle span.updated { - padding-right: 10px; - white-space: nowrap; - color: #ccc; - font-size: 11px; -} -div#floatingTitle div.feed a { - color: #ccc; -} -div#floatingTitle span.titleWrap { - width: 100%; - white-space: normal; -} -div#floatingTitle .feed-title > * { - display: table-cell; - vertical-align: middle; -} -div#floatingTitle .feed-title a.title { - width: 100%; -} -div#floatingTitle .feed-title a.catchup { - text-align: right; - color: #ccc; - padding-right: 10px; - font-size: 11px; - white-space: nowrap; -} -div#floatingTitle .feed-title a.catchup:hover { - color: #b87d2c; -} -div#floatingTitle.Unread a.title { - color: black; -} .cdm.expandable { background-color: #222; border: 0px solid #222; @@ -1470,6 +1383,15 @@ div.cdm.expandable:not(.active) .content, div.cdm.expandable:not(.active) .collapse { display: none; } +div.cdm.expandable.active .header[stuck], +div.cdm.expanded .header[stuck] { + box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.1); + border: 0 solid #222; + border-bottom-width: 1px; + background: #333 ! important; + opacity: 0.9; + backdrop-filter: blur(6px); +} body.ttrss_prefs { background-color: #222; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; @@ -1595,12 +1517,12 @@ body.ttrss_prefs .phpinfo td.v { font-family: monospace; word-break: break-all; } -body.ttrss_prefs #filterNewRuleDlg .invalid, -body.ttrss_main #filterNewRuleDlg .invalid { +body.ttrss_prefs #filterNewRuleDlg .dijitValidationTextAreaError, +body.ttrss_main #filterNewRuleDlg .dijitValidationTextAreaError { background: #ffc0c0; } -body.ttrss_prefs #filterNewRuleDlg .valid, -body.ttrss_main #filterNewRuleDlg .valid { +body.ttrss_prefs #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError), +body.ttrss_main #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError) { background: #c0ffc0; } body.ttrss_prefs fieldset, @@ -1898,11 +1820,6 @@ body.ttrss_zoom div.post div.header .row { align-items: center; justify-content: space-between; } -body.ttrss_zoom div.post p { - -webkit-hyphens: auto; - -moz-hyphens: auto; - hyphens: auto; -} body.ttrss_zoom div.post div.content { font-size: 15px; line-height: 1.5; @@ -1949,11 +1866,8 @@ body.flat.ttrss_main.ttrss_prefs td.filename, body.flat.ttrss_main.ttrss_prefs div.prefHelp { color: #999999; } -body.flat.ttrss_main.ttrss_prefs #filterNewRuleDlg .invalid { - background: #503030; -} -body.flat.ttrss_main.ttrss_prefs #filterNewRuleDlg .valid { - background: #305030; +body.flat.ttrss_main.ttrss_prefs hr { + border-color: #666; } body.flat.ttrss_main { /* @@ -2011,18 +1925,6 @@ body.flat.ttrss_main #feeds-holder #feedTree .dijitTreeRowSelected .dijitTreeLab body.flat.ttrss_main #feeds-holder #feedTree i.icon.icon-inbox { color: #999999; } -body.flat.ttrss_main #floatingTitle { - background-color: #333; -} -body.flat.ttrss_main #floatingTitle .feed a { - color: #e6e6e6; -} -body.flat.ttrss_main #floatingTitle i.material-icons { - opacity: 0.7; -} -body.flat.ttrss_main div#floatingTitle.Unread a.title { - color: #e6e6e6; -} body.flat.ttrss_main #headlines-frame .hl:not(.active):not(.Selected):not(.Unread), body.flat.ttrss_main #headlines-frame .cdm.expandable:not(.active):not(.Selected):not(.Unread) { background: #333; @@ -2191,7 +2093,9 @@ body.flat.ttrss_main .alert.alert-danger { color: #b94a48; border-color: #702c2b; } -body.ttrss_prefs hr { - border-color: #666; +body.flat.ttrss_main #filterNewRuleDlg .dijitValidationTextAreaError { + background: #503030; +} +body.flat.ttrss_main #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError) { + background: #305030; } -/*# sourceMappingURL=night.css.map */
\ No newline at end of file diff --git a/themes/night.css.map b/themes/night.css.map deleted file mode 100644 index 6f8de00c0..000000000 --- a/themes/night.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["night_base.less","night.less","C:/Users/fox/Projects/tt-rss/css/defines.less","C:/Users/fox/Projects/tt-rss/css/tt-rss.less","C:/Users/fox/Projects/tt-rss/css/cdm.less","C:/Users/fox/Projects/tt-rss/css/prefs.less","C:/Users/fox/Projects/tt-rss/css/dijit_basic.less","C:/Users/fox/Projects/tt-rss/css/utility.less","C:/Users/fox/Projects/tt-rss/css/zoom.less"],"names":[],"mappings":"QAGQ;QCFA;ACgBR,IAAI;AACJ,IAAI;AACJ;EACE,kBAAA;EACA,WAAA;EACA,YAAA;EACA,SAAA;EACA,UAAA;EACA,SAAA;;ACzBF,IAAI;EACH,gBAAA;EACA,WAAA;EACA,aAAa,8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A7OH,IAAI,KAAK,WA6Oc,GAAE;EACvB,gBAAA;EACA,kBAAA;;AA/OF,IAAI,KAAK,WAkQR;EACC,mBAAA;EACA,qBAAA;EACA,WAAA;;AArQF,IAAI,KAAK,WAkQR,cAKC,EAAC;EACA,WAAA;;AAxQH,IAAI,KAAK,WA4QR;EACC,UAAA;;AA7QF,IAAI,KAAK,WAgRR;EACC,sBAAA;;AAjRF,IAAI,KAAK,WAoRR;EACC,sBAAA;;AArRF,IAAI,KAAK,WAwRR;EACC,gBAAA;EACA,qBAAA;EACA,cAAA;;AA3RF,IAAI,KAAK,WA8RR,OAAM;EACL,cAAA;EACA,qBAAA;;AAhSF,IAAI,KAAK,WAmSR,OAAM;EACL,cAAA;EACA,qBAAA;;AAKF,IAAI,YACH;EACC,kBAAA","file":"night.css"}
\ No newline at end of file diff --git a/themes/night_base.less b/themes/night_base.less index 7ab1f85b1..0dff7d191 100644 --- a/themes/night_base.less +++ b/themes/night_base.less @@ -1,6 +1,6 @@ -@import "../css/defines.less"; -@import "../css/utility.less"; -@import "../css/zoom.less"; +@import "light/defines.less"; +@import "light/utility.less"; +@import "light/zoom.less"; @import "../lib/flat-ttrss/flat_combined_dark.css"; @color-accent: #b87d2c; @@ -20,6 +20,8 @@ @color-alert-info : #3a87ad; @color-alert-danger : #b94a48; +@color-tooltip-bg : lighten(@color-accent, 10%); + body.flat.ttrss_main.ttrss_prefs { #main, #footer { background: @color-panel-bg; @@ -34,13 +36,8 @@ body.flat.ttrss_main.ttrss_prefs { color : @fg-text-muted; } - #filterNewRuleDlg { - .invalid { - background : #503030; - } - .valid { - background : #305030; - } + hr { + border-color : @border-light; } } @@ -94,22 +91,6 @@ body.flat.ttrss_main { } } - #floatingTitle { - background-color : @default-bg; - - .feed a { - color : @fg-light; - } - - i.material-icons { - opacity : 0.7; - } - } - - div#floatingTitle.Unread a.title { - color : @fg-light; - } - #headlines-frame { .hl:not(.active):not(.Selected):not(.Unread), .cdm.expandable:not(.active):not(.Selected):not(.Unread) { @@ -340,10 +321,12 @@ body.flat.ttrss_main { border-color : darken(@color-alert-danger, 20%); } -} - -body.ttrss_prefs { - hr { - border-color : @border-light; + #filterNewRuleDlg { + .dijitValidationTextAreaError { + background : #503030; + } + .dijitValidationTextArea:not(.dijitValidationTextAreaError) { + background : #305030; + } } } diff --git a/themes/night_blue.css b/themes/night_blue.css index a2fcf2c54..09a996262 100644 --- a/themes/night_blue.css +++ b/themes/night_blue.css @@ -71,12 +71,19 @@ body.ttrss_main div.post div.content video { max-width: 98%; height: auto; } -body.ttrss_main div.post div.content p { - hyphens: auto; +body.ttrss_main div.post div.content div.embed-responsive { + overflow: hidden; + padding-bottom: 56.25%; + position: relative; } -body.ttrss_main div.post div.content iframe { - min-width: 50%; - max-width: 98%; +body.ttrss_main div.post div.content div.embed-responsive iframe { + border: 0; + bottom: 0; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; } body.ttrss_main .inline-player { display: flex; @@ -662,13 +669,6 @@ body.ttrss_main #headlines-frame div.feed-title a { body.ttrss_main #headlines-frame div.feed-title a:hover { color: #257aa7; } -body.ttrss_main #headlines-frame.smooth-scroll { - scroll-behavior: smooth; -} -body.ttrss_main #headlines-frame.forbid-smooth-scroll, -body.ttrss_main #content-insert.forbid-smooth-scroll { - scroll-behavior: auto; -} body.ttrss_main #toolbar-frame_splitter { display: none; } @@ -755,7 +755,6 @@ body.ttrss_main #content-insert { line-height: 1.5; overflow: auto; -webkit-overflow-scrolling: touch; - scroll-behavior: smooth; } body.ttrss_main img.feed-icon, body.ttrss_main img.icon { @@ -866,6 +865,22 @@ body.ttrss_main #feedEditDlg img.feedIcon { height: auto; width: auto; } +body.ttrss_main .dijitTooltipContents { + background: #2e99d1; + color: #222; +} +body.ttrss_main .dijitTooltipRight .dijitTooltipConnector { + border-right-color: #2e99d1; +} +body.ttrss_main .dijitTooltipLeft .dijitTooltipConnector { + border-left-color: #2e99d1; +} +body.ttrss_main .dijitTooltipBelow .dijitTooltipConnector { + border-bottom-color: #2e99d1; +} +body.ttrss_main .dijitTooltipAbove .dijitTooltipConnector { + border-top-color: #2e99d1; +} body.ttrss_main .dijitDialog h1:first-of-type, body.ttrss_main .dijitDialog h2:first-of-type, body.ttrss_main .dijitDialog h3:first-of-type, @@ -878,10 +893,10 @@ body.ttrss_main[view-mode="marked"] #feeds-holder #feedTree .dijitTreeRow.Has_Ma body.ttrss_main[view-mode="marked"] #feeds-holder #feedTree .dijitTreeRow.Has_Marked .counterNode.marked { display: inline-block; } -body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.AlwaysVisible):not(.Special):not(.Has_Marked) { +body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.AlwaysVisible):not(.Special):not(.Has_Marked) { display: none; } -body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.AlwaysVisible):not(.Has_Marked) { +body.ttrss_main[view-mode="marked"][hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.AlwaysVisible):not(.Has_Marked) { display: none; } body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow.Unread .counterNode.unread { @@ -890,10 +905,10 @@ body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow. body.ttrss_main:not([view-mode="marked"]) #feeds-holder #feedTree .dijitTreeRow.Has_Aux:not(.Unread) .counterNode.aux { display: inline-block; } -body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.Unread):not(.AlwaysVisible):not(.Special) { +body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="true"] #feeds-holder #feedTree .dijitTreeRow:not(.Unread):not(.AlwaysVisible):not(.Special) { display: none; } -body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.dijitTreeRowSelected):not(.Unread):not(.AlwaysVisible) { +body.ttrss_main:not([view-mode="marked"])[hide-read-feeds="true"][hide-read-shows-special="false"] #feeds-holder #feedTree .dijitTreeRow:not(.Unread):not(.AlwaysVisible) { display: none; } body.ttrss_main #toolbar-headlines i.icon-syndicate { @@ -918,12 +933,10 @@ body.ttrss_main i.icon-no-feed { body.ttrss_main .dijitTreeRow.UpdatesDisabled .dijitTreeLabel { opacity: 0.5; } -body.ttrss_main #floatingTitle.marked i.marked-pic, body.ttrss_main .cdm.marked .left i.marked-pic, body.ttrss_main .hl.marked .left i.marked-pic { color: #ffc069; } -body.ttrss_main #floatingTitle.published i.pub-pic, body.ttrss_main .cdm.published .left i.pub-pic, body.ttrss_main .hl.published .left i.pub-pic { color: #ff7c4b; @@ -1117,6 +1130,11 @@ video::-webkit-media-controls-overlay-play-button { .cdm i.material-icons { color: #777; } +.cdm .header { + position: sticky; + top: 0; + z-index: 3; +} .cdm .header, .cdm .footer { display: flex; @@ -1129,6 +1147,9 @@ video::-webkit-media-controls-overlay-play-button { margin: 0px 4px; vertical-align: middle; } +.cdm .header-sticky-guard { + height: 0; +} .cdm .header { align-items: center; } @@ -1208,9 +1229,6 @@ video::-webkit-media-controls-overlay-play-button { margin-top: 0px; margin-bottom: 0px; } -div.cdm.expanded div.header { - background: transparent ! important; -} div.cdm.expanded div.header a.title { font-size: 16px; color: #999; @@ -1268,15 +1286,19 @@ div.cdm.vgrlf .feed { font-style: italic; font-size: 11px; } -.cdm div.content-inner p { - /*max-width : 650px;*/ - -webkit-hyphens: auto; - -moz-hyphens: auto; - hyphens: auto; +.cdm div.content-inner div.embed-responsive { + overflow: hidden; + padding-bottom: 56.25%; + position: relative; } -.cdm div.content-inner iframe { - min-width: 50%; - max-width: 98%; +.cdm div.content-inner div.embed-responsive iframe { + border: 0; + bottom: 0; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; } .cdm div.header span.author { white-space: nowrap; @@ -1289,115 +1311,6 @@ div.cdm.vgrlf .feed { display: inline-block; padding: 1px 4px 1px 4px; } -#main:not(.expandable) div#floatingTitle .collapse { - display: none; -} -div#floatingTitle { - position: absolute; - z-index: 5; - top: 0px; - right: 0px; - left: 0px; - border: 0px solid #222; - border-bottom-width: 1px; - background: white; - color: #ccc; - display: flex; - flex-direction: row; - flex-wrap: nowrap; - box-shadow: 0px 1px 1px -1px rgba(0, 0, 0, 0.1); - align-items: center; -} -div#floatingTitle > * { - white-space: nowrap; - padding: 4px; -} -div#floatingTitle .left, -div#floatingTitle .right { - display: flex; - align-items: center; -} -div#floatingTitle .left i.material-icons, -div#floatingTitle .right i.material-icons { - margin-left: 2px; - font-size: 21px; - padding: 2px; - user-select: none; -} -div#floatingTitle .left i.icon-anchor, -div#floatingTitle .right i.icon-anchor { - margin-left: 0px; - margin-right: 1px; - padding: 0px; - color: #ccc; - cursor: pointer; -} -div#floatingTitle .excerpt { - display: none; -} -div#floatingTitle .collapse i.material-icons { - color: #257aa7; - cursor: pointer; -} -div#floatingTitle span.author { - color: #ccc; - font-size: 11px; - font-weight: normal; -} -div#floatingTitle a.title { - font-size: 16px; - color: #999; - transition: color 0.2s, background 0.2s; - font-weight: 600; - text-rendering: optimizelegibility; - font-family: "Segoe WP Semibold", "Segoe UI Semibold", "Segoe UI Web Semibold", "Segoe UI", Ubuntu, "Helvetica Neue", Helvetica, Arial, sans-serif; -} -div#floatingTitle div.feed { - padding-right: 10px; - color: #ccc; - font-weight: normal; - font-style: italic; - font-size: 11px; - white-space: nowrap; -} -div#floatingTitle div.feed a { - border-radius: 4px; - display: inline-block; - padding: 1px 4px 1px 4px; -} -div#floatingTitle span.updated { - padding-right: 10px; - white-space: nowrap; - color: #ccc; - font-size: 11px; -} -div#floatingTitle div.feed a { - color: #ccc; -} -div#floatingTitle span.titleWrap { - width: 100%; - white-space: normal; -} -div#floatingTitle .feed-title > * { - display: table-cell; - vertical-align: middle; -} -div#floatingTitle .feed-title a.title { - width: 100%; -} -div#floatingTitle .feed-title a.catchup { - text-align: right; - color: #ccc; - padding-right: 10px; - font-size: 11px; - white-space: nowrap; -} -div#floatingTitle .feed-title a.catchup:hover { - color: #257aa7; -} -div#floatingTitle.Unread a.title { - color: black; -} .cdm.expandable { background-color: #222; border: 0px solid #222; @@ -1470,6 +1383,15 @@ div.cdm.expandable:not(.active) .content, div.cdm.expandable:not(.active) .collapse { display: none; } +div.cdm.expandable.active .header[stuck], +div.cdm.expanded .header[stuck] { + box-shadow: 0 1px 1px -1px rgba(0, 0, 0, 0.1); + border: 0 solid #222; + border-bottom-width: 1px; + background: #333 ! important; + opacity: 0.9; + backdrop-filter: blur(6px); +} body.ttrss_prefs { background-color: #222; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; @@ -1595,12 +1517,12 @@ body.ttrss_prefs .phpinfo td.v { font-family: monospace; word-break: break-all; } -body.ttrss_prefs #filterNewRuleDlg .invalid, -body.ttrss_main #filterNewRuleDlg .invalid { +body.ttrss_prefs #filterNewRuleDlg .dijitValidationTextAreaError, +body.ttrss_main #filterNewRuleDlg .dijitValidationTextAreaError { background: #ffc0c0; } -body.ttrss_prefs #filterNewRuleDlg .valid, -body.ttrss_main #filterNewRuleDlg .valid { +body.ttrss_prefs #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError), +body.ttrss_main #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError) { background: #c0ffc0; } body.ttrss_prefs fieldset, @@ -1898,11 +1820,6 @@ body.ttrss_zoom div.post div.header .row { align-items: center; justify-content: space-between; } -body.ttrss_zoom div.post p { - -webkit-hyphens: auto; - -moz-hyphens: auto; - hyphens: auto; -} body.ttrss_zoom div.post div.content { font-size: 15px; line-height: 1.5; @@ -1949,11 +1866,8 @@ body.flat.ttrss_main.ttrss_prefs td.filename, body.flat.ttrss_main.ttrss_prefs div.prefHelp { color: #999999; } -body.flat.ttrss_main.ttrss_prefs #filterNewRuleDlg .invalid { - background: #503030; -} -body.flat.ttrss_main.ttrss_prefs #filterNewRuleDlg .valid { - background: #305030; +body.flat.ttrss_main.ttrss_prefs hr { + border-color: #666; } body.flat.ttrss_main { /* @@ -2011,18 +1925,6 @@ body.flat.ttrss_main #feeds-holder #feedTree .dijitTreeRowSelected .dijitTreeLab body.flat.ttrss_main #feeds-holder #feedTree i.icon.icon-inbox { color: #999999; } -body.flat.ttrss_main #floatingTitle { - background-color: #333; -} -body.flat.ttrss_main #floatingTitle .feed a { - color: #e6e6e6; -} -body.flat.ttrss_main #floatingTitle i.material-icons { - opacity: 0.7; -} -body.flat.ttrss_main div#floatingTitle.Unread a.title { - color: #e6e6e6; -} body.flat.ttrss_main #headlines-frame .hl:not(.active):not(.Selected):not(.Unread), body.flat.ttrss_main #headlines-frame .cdm.expandable:not(.active):not(.Selected):not(.Unread) { background: #333; @@ -2191,7 +2093,9 @@ body.flat.ttrss_main .alert.alert-danger { color: #b94a48; border-color: #702c2b; } -body.ttrss_prefs hr { - border-color: #666; +body.flat.ttrss_main #filterNewRuleDlg .dijitValidationTextAreaError { + background: #503030; +} +body.flat.ttrss_main #filterNewRuleDlg .dijitValidationTextArea:not(.dijitValidationTextAreaError) { + background: #305030; } -/*# sourceMappingURL=night_blue.css.map */
\ No newline at end of file diff --git a/themes/night_blue.css.map b/themes/night_blue.css.map deleted file mode 100644 index 93af60643..000000000 --- a/themes/night_blue.css.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["night_base.less","night_blue.less","C:/Users/fox/Projects/tt-rss/css/defines.less","C:/Users/fox/Projects/tt-rss/css/tt-rss.less","C:/Users/fox/Projects/tt-rss/css/cdm.less","C:/Users/fox/Projects/tt-rss/css/prefs.less","C:/Users/fox/Projects/tt-rss/css/dijit_basic.less","C:/Users/fox/Projects/tt-rss/css/utility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AAK,WA8NR,aAAa;EACZ,sBAAA;;AA/NF,IAAI,KAAK,WAkOR,iBAAiB;AAlOlB,IAAI,KAAK,WAmOR,gBAAgB;EACf,WAAA;EACA,qBAAA;;AArOF,IAAI,KAAK,WAwOR;EACC,WAAA;EACA,gBAAA;;AA1OF,IAAI,KAAK,WA6OR,GAAE;AA7OH,IAAI,KAAK,WA6Oc,GAAE;EACvB,gBAAA;EACA,kBAAA;;AA/OF,IAAI,KAAK,WAkQR;EACC,mBAAA;EACA,qBAAA;EACA,WAAA;;AArQF,IAAI,KAAK,WAkQR,cAKC,EAAC;EACA,WAAA;;AAxQH,IAAI,KAAK,WA4QR;EACC,UAAA;;AA7QF,IAAI,KAAK,WAgRR;EACC,sBAAA;;AAjRF,IAAI,KAAK,WAoRR;EACC,sBAAA;;AArRF,IAAI,KAAK,WAwRR;EACC,gBAAA;EACA,qBAAA;EACA,cAAA;;AA3RF,IAAI,KAAK,WA8RR,OAAM;EACL,cAAA;EACA,qBAAA;;AAhSF,IAAI,KAAK,WAmSR,OAAM;EACL,cAAA;EACA,qBAAA;;AAKF,IAAI,YACH;EACC,kBAAA","file":"night_blue.css"}
\ No newline at end of file diff --git a/update.php b/update.php index 5b723277f..95f19d022 100755 --- a/update.php +++ b/update.php @@ -14,6 +14,19 @@ require_once "db.php"; require_once "db-prefs.php"; + function make_stampfile($filename) { + $fp = fopen(LOCK_DIRECTORY . "/$filename", "w"); + + if (flock($fp, LOCK_EX | LOCK_NB)) { + fwrite($fp, time() . "\n"); + flock($fp, LOCK_UN); + fclose($fp); + return true; + } else { + return false; + } + } + function cleanup_tags($days = 14, $limit = 1000) { $days = (int) $days; @@ -69,6 +82,7 @@ $longopts = array("feeds", "daemon", "daemon-loop", + "update-feed:", "send-digests", "task:", "cleanup-tags", @@ -77,7 +91,7 @@ "log-level:", "indexes", "pidlock:", - "update-schema", + "update-schema::", "convert-filters", "force-update", "gen-search-idx", @@ -85,6 +99,7 @@ "debug-feed:", "force-refetch", "force-rehash", + "opml-export:", "help"); foreach (PluginHost::getInstance()->get_commands() as $command => $data) { @@ -122,29 +137,30 @@ if (count($options) == 0 || isset($options["help"]) ) { print "Tiny Tiny RSS data update script.\n\n"; print "Options:\n"; - print " --feeds - update feeds\n"; - print " --daemon - start single-process update daemon\n"; - print " --task N - create lockfile using this task id\n"; - print " --cleanup-tags - perform tags table maintenance\n"; - print " --quiet - don't output messages to stdout\n"; - print " --log FILE - log messages to FILE\n"; - print " --log-level N - log verbosity level\n"; - print " --indexes - recreate missing schema indexes\n"; - print " --update-schema - update database schema\n"; - print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n"; - print " --convert-filters - convert type1 filters to type2\n"; - print " --send-digests - send pending email digests\n"; - print " --force-update - force update of all feeds\n"; - print " --list-plugins - list all available plugins\n"; - print " --debug-feed N - perform debug update of feed N\n"; - print " --force-refetch - debug update: force refetch feed data\n"; - print " --force-rehash - debug update: force rehash articles\n"; - print " --help - show this help\n"; + print " --feeds - update feeds\n"; + print " --daemon - start single-process update daemon\n"; + print " --task N - create lockfile using this task id\n"; + print " --cleanup-tags - perform tags table maintenance\n"; + print " --quiet - don't output messages to stdout\n"; + print " --log FILE - log messages to FILE\n"; + print " --log-level N - log verbosity level\n"; + print " --indexes - recreate missing schema indexes\n"; + print " --update-schema[=force-yes] - update database schema (without prompting)\n"; + print " --gen-search-idx - generate basic PostgreSQL fulltext search index\n"; + print " --convert-filters - convert type1 filters to type2\n"; + print " --send-digests - send pending email digests\n"; + print " --force-update - force update of all feeds\n"; + print " --list-plugins - list all available plugins\n"; + print " --debug-feed N - perform debug update of feed N\n"; + print " --force-refetch - debug update: force refetch feed data\n"; + print " --force-rehash - debug update: force rehash articles\n"; + print " --opml-export \"USER FILE\" - export feeds of selected user to OPML\n"; + print " --help - show this help\n"; print "Plugin options:\n"; foreach (PluginHost::getInstance()->get_commands() as $command => $data) { $args = $data['arghelp']; - printf(" --%-19s - %s\n", "$command $args", $data["description"]); + printf(" --%-26s - %s\n", "$command $args", $data["description"]); } return; @@ -220,8 +236,8 @@ } if (isset($options["feeds"])) { - RSSUtils::update_daemon_common(); - RSSUtils::housekeeping_common(true); + RSSUtils::update_daemon_common(DAEMON_FEED_LIMIT, $options); + RSSUtils::housekeeping_common(); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); } @@ -229,8 +245,8 @@ if (isset($options["daemon"])) { while (true) { $quiet = (isset($options["quiet"])) ? "--quiet" : ""; - $log = isset($options['log']) ? '--log '.$options['log'] : ''; - $log_level = isset($options['log-level']) ? '--log-level '.$options['log-level'] : ''; + $log = isset($options['log']) ? '--log '.$options['log'] : ''; + $log_level = isset($options['log-level']) ? '--log-level '.$options['log-level'] : ''; passthru(PHP_EXECUTABLE . " " . $argv[0] ." --daemon-loop $quiet $log $log_level"); @@ -242,15 +258,31 @@ } } + if (isset($options["update-feed"])) { + try { + + if (!RSSUtils::update_rss_feed($options["update-feed"], true)) + exit(100); + + } catch (PDOException $e) { + Debug::log(sprintf("Exception while updating feed %d: %s (%s:%d)", + $options["update-feed"], $e->getMessage(), $e->getFile(), $e->getLine())); + + Logger::get()->log_error(E_USER_WARNING, $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString()); + + exit(110); + } + } + if (isset($options["daemon-loop"])) { if (!make_stampfile('update_daemon.stamp')) { Debug::log("warning: unable to create stampfile\n"); } - RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT); + RSSUtils::update_daemon_common(isset($options["pidlock"]) ? 50 : DAEMON_FEED_LIMIT, $options); if (!isset($options["pidlock"]) || $options["task"] == 0) - RSSUtils::housekeeping_common(true); + RSSUtils::housekeeping_common(); PluginHost::getInstance()->run_hooks(PluginHost::HOOK_UPDATE_TASK, "hook_update_task", $op); } @@ -380,12 +412,16 @@ else Debug::log("WARNING: please backup your database before continuing."); - Debug::log("Type 'yes' to continue."); + if ($options["update-schema"] != "force-yes") { + Debug::log("Type 'yes' to continue."); - if (read_stdin() != 'yes') - exit; + if (read_stdin() != 'yes') + exit; + } else { + Debug::log("Proceeding to update without confirmation..."); + } - Debug::log("Performing updates to version " . SCHEMA_VERSION); + Debug::log("Performing updates to version " . SCHEMA_VERSION . "..."); for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) { Debug::log("* Updating to version $i..."); @@ -398,10 +434,11 @@ Debug::log("One of the updates failed. Either retry the process or perform updates manually."); return; } - } + + Debug::log("All done."); } else { - Debug::log("Update not required."); + Debug::log("Database schema is already at latest version."); } } @@ -483,6 +520,26 @@ Digest::send_headlines_digests(); } + if (isset($options["opml-export"])) { + list ($user, $filename) = explode(" ", $options["opml-export"], 2); + + Debug::log("Exporting feeds of user $user to $filename as OPML..."); + + $sth = $pdo->prepare("SELECT id FROM ttrss_users WHERE login = ?"); + $sth->execute([$user]); + + if ($res = $sth->fetch()) { + $opml = new OPML(""); + + $rc = $opml->opml_export($filename, $res["id"], false, true, true); + + Debug::log($rc ? "Success." : "Failed."); + } else { + Debug::log("User not found: $user"); + } + + } + PluginHost::getInstance()->run_commands($options); if (file_exists(LOCK_DIRECTORY . "/$lock_filename")) |