Skip to content

Commit

Permalink
Merge branch 'master' of git.fakecake.org:tt-rss into weblate-integra…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Andrew Dolgov committed Dec 20, 2019
2 parents 573784c + 63ee91c commit 4b44103
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 58 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
@@ -1,5 +1,7 @@
## Contributing code the right way

*(or: how I learned to post merge requests without crying myself to sleep)*

New user accounts on Gogs are not allowed to fork repositories because of spam. To get
initial fork access, do the following:

Expand Down
5 changes: 4 additions & 1 deletion backend.php
Expand Up @@ -98,10 +98,13 @@
if ($override) {
$handler = $override;
} else {
$handler = new $op($_REQUEST);
$reflection = new ReflectionClass($op);
$handler = $reflection->newInstanceWithoutConstructor();
}

if ($handler && implements_interface($handler, 'IHandler')) {
$handler->__construct($_REQUEST);

if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) {
if ($handler->before($method)) {
if ($method && method_exists($handler, $method)) {
Expand Down
3 changes: 1 addition & 2 deletions classes/handler/public.php
Expand Up @@ -85,7 +85,7 @@ private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
$tpl->readTemplateFromFile("templates/generated_feed.txt");

$tpl->setVariable('FEED_TITLE', $feed_title, true);
$tpl->setVariable('VERSION', VERSION, true);
$tpl->setVariable('VERSION', get_version(), true);
$tpl->setVariable('FEED_URL', htmlspecialchars($feed_self_url), true);

$tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
Expand Down Expand Up @@ -180,7 +180,6 @@ private function generate_syndicated_feed($owner_uid, $feed, $is_cat,
$feed = array();

$feed['title'] = $feed_title;
$feed['version'] = VERSION;
$feed['feed_url'] = $feed_self_url;

$feed['self_url'] = get_self_url_prefix();
Expand Down
54 changes: 52 additions & 2 deletions include/functions.php
Expand Up @@ -27,6 +27,9 @@
error_reporting(E_ALL & ~E_NOTICE);
}

ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);

require_once 'config.php';

/**
Expand Down Expand Up @@ -151,10 +154,9 @@ function startup_gettext() {
}

require_once 'db-prefs.php';
require_once 'version.php';
require_once 'controls.php';

define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . VERSION . ' (http://tt-rss.org/)');
define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . get_version() . ' (http://tt-rss.org/)');
ini_set('user_agent', SELF_USER_AGENT);

$schema_version = false;
Expand Down Expand Up @@ -1882,3 +1884,51 @@ function get_scripts_timestamp() {

return $ts;
}

/* for package maintainers who don't use git: if version_static.txt exists in tt-rss root
directory, its contents are displayed instead of git commit-based version, this could be generated
based on source git tree commit used when creating the package */

function get_version(&$git_commit = false, &$git_timestamp = false) {
global $ttrss_version;

if (isset($ttrss_version))
return $ttrss_version;

$ttrss_version = "UNKNOWN (Unsupported)";

date_default_timezone_set('UTC');
$root_dir = dirname(dirname(__FILE__));

if ('\\' === DIRECTORY_SEPARATOR) {
$ttrss_version = "UNKNOWN (Unsupported, Windows)";
} else if (PHP_OS === "Darwin") {
$ttrss_version = "UNKNOWN (Unsupported, Darwin)";
} else if (file_exists("$root_dir/version_static.txt")) {
$ttrss_version = trim(file_get_contents("$root_dir/version_static.txt")) . " (Unsupported)";
} else if (is_dir("$root_dir/.git")) {
$rc = 0;
$output = [];

$cwd = getcwd();

chdir($root_dir);
exec('git log --pretty='.escapeshellarg('%ct %h').' -n1 HEAD 2>&1', $output, $rc);
chdir($cwd);

if ($rc == 0) {
if (is_array($output) && count($output) > 0) {
list ($timestamp, $commit) = explode(" ", $output[0], 2);

$git_commit = $commit;
$git_timestamp = $timestamp;

$ttrss_version = strftime("%y.%m", $timestamp) . "-$commit";
}
} else {
user_error("Unable to determine version (using $root_dir): " . implode("\n", $output), E_USER_WARNING);
}
}

return $ttrss_version;
}
1 change: 0 additions & 1 deletion include/sessions.php
Expand Up @@ -7,7 +7,6 @@
require_once "errorhandler.php";
require_once "lib/accept-to-gettext.php";
require_once "lib/gettext/gettext.inc";
require_once "version.php";

$session_expire = min(2147483647 - time() - 1, max(SESSION_COOKIE_LIFETIME, 86400));
$session_name = (!defined('TTRSS_SESSION_NAME')) ? "ttrss_sid" : TTRSS_SESSION_NAME;
Expand Down
36 changes: 0 additions & 36 deletions include/version.php

This file was deleted.

5 changes: 0 additions & 5 deletions index.php
Expand Up @@ -23,7 +23,6 @@
require_once "sessions.php";
require_once "functions.php";
require_once "sanity_check.php";
require_once "version.php";
require_once "config.php";
require_once "db-prefs.php";

Expand All @@ -40,10 +39,6 @@
<title>Tiny Tiny RSS</title>
<meta name="viewport" content="initial-scale=1,width=device-width" />

<script type="text/javascript">
var __ttrss_version = "<?php echo VERSION ?>"
</script>

<?php if ($_SESSION["uid"]) {
$theme = get_pref("USER_CSS_THEME", false, false);
if ($theme && theme_exists("$theme")) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/af_comics/init.php
Expand Up @@ -110,7 +110,7 @@ function hook_fetch_feed($feed_data, $fetch_url, $owner_uid, $feed, $last_articl
$tpl->readTemplateFromFile('templates/generated_feed.txt');

$tpl->setVariable('FEED_TITLE', $feed_title, true);
$tpl->setVariable('VERSION', VERSION, true);
$tpl->setVariable('VERSION', get_version(), true);
$tpl->setVariable('FEED_URL', htmlspecialchars($fetch_url), true);
$tpl->setVariable('SELF_URL', $site_url, true);

Expand Down
10 changes: 1 addition & 9 deletions prefs.php
Expand Up @@ -16,7 +16,6 @@
require_once "sessions.php";
require_once "functions.php";
require_once "sanity_check.php";
require_once "version.php";
require_once "config.php";
require_once "db-prefs.php";

Expand All @@ -32,10 +31,6 @@
<title>Tiny Tiny RSS : <?php echo __("Preferences") ?></title>
<meta name="viewport" content="initial-scale=1,width=device-width" />

<script type="text/javascript">
var __ttrss_version = "<?php echo VERSION ?>"
</script>

<?php if ($_SESSION["uid"]) {
$theme = get_pref("USER_CSS_THEME", false, false);
if ($theme && theme_exists("$theme")) {
Expand Down Expand Up @@ -164,10 +159,7 @@
</div>
<div id="footer" dojoType="dijit.layout.ContentPane" region="bottom">
<a class="text-muted" target="_blank" href="http://tt-rss.org/">
Tiny Tiny RSS</a>
<?php if (!defined('HIDE_VERSION')) { ?>
v<?php echo VERSION ?>
<?php } ?>
Tiny Tiny RSS</a> v<?php echo get_version() ?>
&copy; 2005-<?php echo date('Y') ?>
<a class="text-muted" target="_blank"
href="http://fakecake.org/">Andrew Dolgov</a>
Expand Down
1 change: 0 additions & 1 deletion update_daemon2.php
Expand Up @@ -8,7 +8,6 @@

define('DISABLE_SESSIONS', true);

require_once "version.php";
require_once "autoload.php";
require_once "functions.php";
require_once "config.php";
Expand Down

0 comments on commit 4b44103

Please sign in to comment.