rework article notes; re-add built-in XSL template for generated feeds; remove schema_version caching in session

This commit is contained in:
Andrew Dolgov 2011-04-19 13:20:59 +04:00
parent dd04ea81ba
commit fcfa9ef15b
7 changed files with 49 additions and 83 deletions

View File

@ -211,10 +211,12 @@
} else if ($mode == "zoom") { } else if ($mode == "zoom") {
array_push($articles, format_article($link, $id, false, true, true)); array_push($articles, format_article($link, $id, false, true, true));
} else if ($mode == "raw") { } else if ($mode == "raw") {
if ($_REQUEST['html']) header("Content-Type: text/html"); if ($_REQUEST['html']) {
header("Content-Type: text/html");
print '<link rel="stylesheet" type="text/css" href="tt-rss.css"/>';
}
$article = format_article($link, $id, false); $article = format_article($link, $id, false);
print $article['id'] . "\n\n";
print $article['content']; print $article['content'];
return; return;
} else { } else {

View File

@ -1,12 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <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:output method="html"/>
<xsl:template match="/"> <xsl:template match="/atom:feed">
<html> <html>
<head> <head>
<title><xsl:value-of select="rss/channel/title"/></title> <title><xsl:value-of select="atom:title"/></title>
<link rel="stylesheet" type="text/css" href="utility.css"/> <link rel="stylesheet" type="text/css" href="utility.css"/>
<script language="javascript" src="lib/xsl_mop-up.js"></script> <script language="javascript" src="lib/xsl_mop-up.js"></script>
</head> </head>
@ -21,24 +23,18 @@
<img class="feedicon" src="images/feed-icon-64x64.png" alt="feed icon"/> <img class="feedicon" src="images/feed-icon-64x64.png" alt="feed icon"/>
<h1><xsl:value-of select="rss/channel/title"/></h1> <h1><xsl:value-of select="atom:title"/></h1>
<p class="description">This is an RSS feed exported from <p class="description">This feed has been exported from
<a target="_new" class="extlink" href="http://tt-rss.org">Tiny Tiny RSS</a>. <a target="_new" class="extlink" href="http://tt-rss.org">Tiny Tiny RSS</a>.
You must install a news aggregator to subscribe to it. You need a news reader software to subscribe to it.
This feed contains the following items:</p> It contains the following items:</p>
<!-- <p class="description"><xsl:value-of <xsl:for-each select="atom:entry">
select="rss/channel/description"/></p> --> <h2><a target="_new" href="{atom:link/@href}"><xsl:value-of select="atom:title"/></a></h2>
<xsl:for-each select="rss/channel/item">
<h2><a target="_new" href="{link}"><xsl:value-of select="title"/></a></h2>
<!-- <div><a class="extlink" target="_new"
href="{link}"><xsl:value-of select="link"/></a></div> -->
<div name="decodeme" class="content"> <div name="decodeme" class="content">
<xsl:value-of select="description" disable-output-escaping="yes"/> <xsl:value-of select="atom:content" disable-output-escaping="yes"/>
</div> </div>
<xsl:if test="enclosure"> <xsl:if test="enclosure">

View File

@ -2360,15 +2360,18 @@
return "even"; return "even";
} }
// Session caching removed due to causing wrong redirects to upgrade
// script when get_schema_version() is called on an obsolete session
// created on a previous schema version.
function get_schema_version($link, $nocache = false) { function get_schema_version($link, $nocache = false) {
if (!$_SESSION["schema_version"] || $nocache) { // if (!$_SESSION["schema_version"] || $nocache) {
$result = db_query($link, "SELECT schema_version FROM ttrss_version"); $result = db_query($link, "SELECT schema_version FROM ttrss_version");
$version = db_fetch_result($result, 0, "schema_version"); $version = db_fetch_result($result, 0, "schema_version");
$_SESSION["schema_version"] = $version; $_SESSION["schema_version"] = $version;
return $version; return $version;
} else { // } else {
return $_SESSION["schema_version"]; // return $_SESSION["schema_version"];
} // }
} }
function sanity_check($link) { function sanity_check($link) {
@ -3677,7 +3680,8 @@
require_once "lib/MiniTemplator.class.php"; require_once "lib/MiniTemplator.class.php";
$note_style = "float : right; background-color : #fff7d5; border-width : 1px; ". $note_style = "background-color : #fff7d5;
border-width : 1px; ".
"padding : 5px; border-style : dashed; border-color : #e7d796;". "padding : 5px; border-style : dashed; border-color : #e7d796;".
"margin-bottom : 1em; color : #9a8c59;"; "margin-bottom : 1em; color : #9a8c59;";
@ -3729,7 +3733,7 @@
$content = sanitize_rss($link, $line["content_preview"], false, $owner_uid); $content = sanitize_rss($link, $line["content_preview"], false, $owner_uid);
if ($line['note']) { if ($line['note']) {
$content = "<div style=\"$note_style\">" . $line['note'] . "</div>" . $content = "<div style=\"$note_style\">Article note: " . $line['note'] . "</div>" .
$content; $content;
} }
@ -4847,17 +4851,17 @@
$rv['content'] .= "</div>"; $rv['content'] .= "</div>";
$rv['content'] .= "<div class=\"postIcon\">" .
"<a target=\"_blank\" title=\"".__("Visit the website")."\"$
href=\"".htmlspecialchars($feed_site_url)."\">".
$feed_icon . "</a></div>";
$rv['content'] .= "<div id=\"POSTNOTE-$id\">"; $rv['content'] .= "<div id=\"POSTNOTE-$id\">";
if ($line['note']) { if ($line['note']) {
$rv['content'] .= format_article_note($id, $line['note']); $rv['content'] .= format_article_note($id, $line['note']);
} }
$rv['content'] .= "</div>"; $rv['content'] .= "</div>";
$rv['content'] .= "<div class=\"postIcon\">" .
"<a target=\"_blank\" title=\"".__("Visit the website")."\"$
href=\"".htmlspecialchars($feed_site_url)."\">".
$feed_icon . "</a></div>";
$rv['content'] .= "<div class=\"postContent\">"; $rv['content'] .= "<div class=\"postContent\">";
$article_content = sanitize_rss($link, $line["content"], false, false, $article_content = sanitize_rss($link, $line["content"], false, false,
@ -6367,8 +6371,9 @@
function format_article_note($id, $note) { function format_article_note($id, $note) {
$str = "<div class='articleNote' title=\"".__('edit note')."\" $str = "<div class='articleNote' onclick=\"editArticleNote($id)\">
onclick=\"editArticleNote($id)\">$note</div>"; <div class='noteEdit' onclick=\"editArticleNote($id)\">".
__('(edit note)')."</div>$note</div>";
return $str; return $str;
} }

View File

@ -818,14 +818,15 @@
if ($subop == "setNote") { if ($subop == "setNote") {
$id = db_escape_string($_REQUEST["id"]); $id = db_escape_string($_REQUEST["id"]);
$note = strip_tags(db_escape_string($_REQUEST["note"])); $note = trim(strip_tags(db_escape_string($_REQUEST["note"])));
db_query($link, "UPDATE ttrss_user_entries SET note = '$note' db_query($link, "UPDATE ttrss_user_entries SET note = '$note'
WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]); WHERE ref_id = '$id' AND owner_uid = " . $_SESSION["uid"]);
$formatted_note = format_article_note($id, $note); $formatted_note = format_article_note($id, $note);
print json_encode(array("note" => $formatted_note)); print json_encode(array("note" => $formatted_note,
"raw_length" => mb_strlen($note)));
return; return;
} }

View File

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="feed.xsl"?>
<!-- $BeginBlock feed --> <!-- $BeginBlock feed -->
<feed xmlns="http://www.w3.org/2005/Atom"> <feed xmlns="http://www.w3.org/2005/Atom">
<title>${FEED_TITLE}</title> <title>${FEED_TITLE}</title>

View File

@ -76,17 +76,17 @@ div.postReply img.tagsPic {
div.articleNote { div.articleNote {
background-color : #fff7d5; background-color : #fff7d5;
border-width : 1px;
padding : 5px; padding : 5px;
border-style : dashed; border-style : none none dashed none;
border-color : #e7d796; border-color : #e7d796;
font-size : 11px; border-width : 1px;
margin-left : 5px; background-color : #fff7d5;
margin-top : 5px;
float : right;
color : #9a8c59; color : #9a8c59;
max-width : 150px; }
text-align : justify;
div.articleNote div.noteEdit {
float : right;
cursor : pointer;
} }
div.postReply span.author { div.postReply span.author {
@ -1172,10 +1172,6 @@ div.dlgButtons {
clear : both; clear : both;
} }
span.prefsLabelEntry {
padding : 2px;
}
span.labelColorIndicator { span.labelColorIndicator {
height : 14px; height : 14px;
width : 14px; width : 14px;
@ -1216,37 +1212,6 @@ div.labelColorIndicator {
margin-right : 10px; margin-right : 10px;
} }
div.colorPicker div.colorPickerEntry:hover {
border : 1px solid #88b0f0;
}
div.colorPicker div.ccPrompt:hover {
color : black;
}
div.colorPicker div.colorPickerEntry {
height : 15px;
width : 15px;
line-height : 13px;
font-height : 9px;
text-align : center;
border : 1px solid black;
margin : 5px 5px 0px 0px;
float : left;
}
div.colorPicker {
border : 1px solid #cccccc;
background : #f0f0f0;
width : 110px;
padding : 0px 0px 5px 5px;
position : absolute;
left : auto;
top : auto;
z-index : 3;
color : #909090;
}
optgroup { optgroup {
color : #4684ff; color : #4684ff;
font-style : normal; font-style : normal;
@ -1499,12 +1464,6 @@ div#pref-tabs .dijitContentPane h3 {
font-weight : bold; font-weight : bold;
} }
/* div#feedTree {
font-size : 11px;
font-family : "Lucida Grande", "Segoe UI", Tahoma, Arial, sans-serif;
} */
#pref-filter-wrap, #pref-filter-header, #pref-filter-content, #pref-filter-wrap, #pref-filter-header, #pref-filter-content,
#pref-label-wrap, #pref-label-header, #pref-label-content, #pref-label-wrap, #pref-label-header, #pref-label-content,
#pref-user-wrap, #pref-user-header, #pref-user-content { #pref-user-wrap, #pref-user-header, #pref-user-content {

View File

@ -2211,6 +2211,8 @@ function editArticleNote(id) {
if (elem) { if (elem) {
Element.hide(elem); Element.hide(elem);
elem.innerHTML = reply.note; elem.innerHTML = reply.note;
if (reply.raw_length != 0)
new Effect.Appear(elem); new Effect.Appear(elem);
} }