RSS + .htaccess

This commit is contained in:
Hermes 2022-08-30 12:21:37 +02:00
pare 33dc470836
commit b98539d3e1
S'han modificat 5 arxius amb 108 adicions i 16 eliminacions

31
.htaccess Normal file
Veure arxiu

@ -0,0 +1,31 @@
# Custom 400 errors
ErrorDocument 400 /errorFiles/index.php?ec=400
# Custom 401 errors
ErrorDocument 401 /errorFiles/index.php?ec=401
# Custom 403 errors
ErrorDocument 403 /errorFiles/index.php?ec=403
# Custom 404 errors
ErrorDocument 404 /errorFiles/index.php?ec=404
# Custom 500 errors
ErrorDocument 500 /errorFiles/index.php?ec=500
# Prevent viewing of .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Prevent directory listings
Options All -Indexes
# ModRewrite
RewriteEngine On
RewriteRule ^article/([^/]*) /article.php?id=$1
RewriteRule ^tag/([^/]*) /tag.php?tag=$1
RewriteRule ^article/([^/]*)/search/([^/]*)$ /article.php?id=$1&s=$2 [L]

Veure arxiu

@ -11,7 +11,7 @@
$row = $query->fetchArray();
?>
<body>
<h1><a href="index.php"><img src='apple-touch-icon.png' title='Xenoteca logo' alt='Xenoteca logo' /><?=$site['site_name']?></a></h1>
<h1><a href="/"><img src='/apple-touch-icon.png' title='Xenoteca logo' alt='Xenoteca logo' /><?=$site['site_name']?></a></h1>
<div class="container">
<?php
echo "
@ -40,11 +40,11 @@ echo "<small><acronym title='Idioma: ".$lang['name']."'><span class='langTag'><s
$tagsQuery = "SELECT articles.article_id as art_id, tags.tag_id, tags.tag_name as tagname, article_tags.tag from articles, article_tags, tags WHERE art_id = ".$_GET['id']." AND art_id = article_tags.article and tags.tag_id = article_tags.tag";
$queryTags = $db->query($tagsQuery);
while($rowTags = $queryTags->fetchArray()){
echo "<span class='tag'><a class='inherit' href='tag.php?tag=".$rowTags['tag_id']."'>" . $rowTags['tagname'] . "</a></span>";
echo "<span class='tag'><a class='inherit' href='/tag/".$rowTags['tag_id']."'>" . $rowTags['tagname'] . "</a></span>";
}
?></small><br />
<a href="index.php">&larr; Back</a>
<a href="/">&larr; Back</a>
</div>
<script>
$("a[href^='http']").each(function() {

Veure arxiu

@ -10,7 +10,7 @@
$query = $db->query($sql);
?>
<body>
<h1><img src='apple-touch-icon.png' title='Xenoteca logo' alt='Xenoteca logo' /><?=$site['site_name']?></h1>
<h1><img src='/apple-touch-icon.png' title='Xenoteca logo' alt='Xenoteca logo' /><?=$site['site_name']?></h1>
<p><?=$site['site_short']?></p>
<div class="container indexContainer">
<dl>
@ -30,12 +30,12 @@
$queryType = $db->query($typeQuery);
$type = $queryType->fetchArray();
echo "<dt><h3 style='display:inline'><a href='article.php?id=".$row['article_id']."'>".$row['article_title']."</a></h3> · <small>publicat el ".strftime('%A, %e %B %Y (%R)', $row['article_timestamp'])."</small></dt><dd><div class='contents'>". $Parsedown->text($row['article_content'])."<div class='gradient'><div class='buttonReadMore'><a class='inherit' href='article.php?id=".$row['article_id']."'>🔍 Expandir post</a></div></div></div><hr> <small><acronym title='Idioma: ".$lang['name']."'><span class='langTag'><span class='noCursive'>🌐 ".$lang['name']."</span></span></acronym></small>
echo "<dt><h3 style='display:inline'><a href='/article/".$row['article_id']."'>".$row['article_title']."</a></h3> · <small>publicat el ".strftime('%A, %e %B %Y (%R)', $row['article_timestamp'])."</small></dt><dd><div class='contents'>". $Parsedown->text($row['article_content'])."<div class='gradient'><div class='buttonReadMore'><a class='inherit' href='/article.php/".$row['article_id']."'>🔍 Expandir post</a></div></div></div><hr> <small><acronym title='Idioma: ".$lang['name']."'><span class='langTag'><span class='noCursive'>🌐 ".$lang['name']."</span></span></acronym></small>
<small><acronym title='Tipus de document: ".$type['type']."\n".$type['explanation']."'><span class='langTag'><span class='noCursive'>📄 ".$type['type']."</span></span></acronym></small>
<small>";
while($rowTags = $queryTags->fetchArray()){
echo "<span class='tag'><a class='inherit' href='tag.php?tag=".$rowTags['tag_id']."'>" . $rowTags['tagname'] . "</a></span>";
echo "<span class='tag'><a class='inherit' href='/tag/".$rowTags['tag_id']."'>" . $rowTags['tagname'] . "</a></span>";
}
echo "</small><br /></dd>";
@ -44,7 +44,14 @@ echo "</small><br /></dd>";
</dl>
</div>
<div id='footer'>
<p>IndieWeb SignIn:</p>
<h3>RSS</h3>
<img src='https://xenoteca.digital/icones/rss.png' class='rssIcon'>
<ul style='list-style-type:none;'><li><a class='skipIcon' rel='alternate' type='application/rss+xml' title='RSS General' href='https://xenoteca.digital/rss.php'>Sindicació als posts de la Xenoteca</a></li>
<?php if(isset($tagNameRow['tag_name'])) {
echo "\t\t<li><a class='skipIcon' rel='alternate' type='application/rss+xml' title='RSS per tag ".$tagNameRow['tag_name']."' href='https://xenoteca.digital/rss.php?tag=".$tagNameRow['tag_name']."'>Sindicació al tag #".$tagNameRow['tag_name']."</a></li>\n";
} ?></ul><br />
<h3 style='clear:both'>IndieWeb SignIn:</h3>
<ul>
<?php
@ -59,7 +66,7 @@ echo "</small><br /></dd>";
</ul>
</div>
<script>
$("a[href^='http']").each(function() {
$("a[href^='http']").not('.skipIcon').each(function() {
$(this).css({
background: "url(https://v1.indieweb-avatar.11ty.dev/" + this.href.replace(":","%3A").replace(/\//g,"%2F") + ") left center no-repeat",
"padding-left": "22px",

47
rss.php Normal file
Veure arxiu

@ -0,0 +1,47 @@
<?php
include "conn.php"; // Connection
include "Parsedown.php";
$Parsedown = new Parsedown();
setlocale(LC_ALL, 'ca_ES.utf8'); // locale
if(!isset($_GET['tag']) or $_GET['tag']=='') {
$sql = "SELECT * FROM articles ORDER BY article_timestamp DESC LIMIT 10";
$title='La Xenoteca | General';
} else {
$sql = "SELECT tags.tag_name, articles.article_id, articles.article_title, articles.article_timestamp, articles.article_content FROM articles, article_tags, tags WHERE lower(tags.tag_name)='".strtolower($_GET['tag'])."' and article_tags.tag=tags.tag_id and article_tags.article=articles.article_id ORDER BY article_timestamp DESC LIMIT 10";
$title='La Xenoteca | tag #'.$_GET['tag'];
}
$query = $db->query($sql);
header( "Content-type: text/xml");
$lines = '';
$lastUpdate='';
while($row = $query->fetchArray()) {
$linies .= "\t\t<item>\n";
$linies .= "\t\t\t<title>".$row['article_title']."</title>\n";
$linies .= "\t\t\t<link>https://xenoteca.digital/article/" . $row['article_id'] . "</link>\n";
$linies .= "\t\t\t<description>".$Parsedown->text(substr($row['article_content'],0,strpos($row['article_content'],"\n")))." [<a href='https://xenoteca.digital/article.php?id=" . $row['article_id'] . "'>Read more</a>]</description>\n";
$linies .= "\t\t\t<pubDate>".date(DATE_RSS,$row['article_timestamp'])."</pubDate>\n";
$linies .= "\t\t\t<guid>https://xenoteca.digital/article/" . $row['article_id'] . "</guid>\n";
$linies .= "\t\t</item>\n";
if ($lastUpdate===''){
$lastUpdate=date(DATE_RSS,$row['article_timestamp']);
}
}
?><?xml version="1.0" encoding='UTF-8'?>
<rss version="2.0">
<channel>
<title><?=$title ?> Feed RSS</title>
<link>https://xenoteca.digital</link>
<description>Anades d'olla de l'Hermes</description>
<pubDate><?=$lastUpdate?></pubDate>
<lastBuildDate><?=$lastUpdate?></lastBuildDate>
<docs>https://www.rssboard.org/rss-specification#element-channel-language</docs>
<generator>Xenoteca Software</generator>
<managingEditor>hermes@xenoteca.digital</managingEditor>
<webMaster>hermes@xenoteca.digital</webMaster>
<?=$linies?>
</channel>
</rss>

23
tag.php
Veure arxiu

@ -7,12 +7,10 @@
$query = $db->query($sql);
?>
<body>
<h1><a href="index.php"><img src='apple-touch-icon.png' title='Xenoteca logo' alt='Xenoteca logo' /><?=$site['site_name']?></a></h1>
<h1><a href="/"><img src='/apple-touch-icon.png' title='Xenoteca logo' alt='Xenoteca logo' /><?=$site['site_name']?></a></h1>
<h2><?php
$tagNameSql = "SELECT tags.tag_name FROM tags WHERE tags.tag_id=".$_GET['tag'];
$tagNameR = $db->query($tagNameSql);
$tagNameRow = $tagNameR->fetchArray();
echo "Tag: #" . $tagNameRow['tag_name'];
@ -25,13 +23,13 @@
$tagsQuery = "SELECT articles.article_id as art_id, tags.tag_id, tags.tag_name as tagname, article_tags.tag from articles, article_tags, tags WHERE art_id = ".$row['article_id']." AND art_id = article_tags.article and tags.tag_id = article_tags.tag";
$queryTags = $db->query($tagsQuery);
echo "<li><h3 style='display:inline'><a href='article.php?id=".$row['article_id']."'>".$row['article_title']."</a></h3> · <small>publicat el ".strftime('%A, %e %B %Y (%R)', $row['article_timestamp'])."</small><br /><small>Arxivat a:";
echo "<li><h3 style='display:inline'><a href='/article/".$row['article_id']."'>".$row['article_title']."</a></h3> · <small>publicat el ".strftime('%A, %e %B %Y (%R)', $row['article_timestamp'])."</small><br /><small>Arxivat a:";
while($rowTags = $queryTags->fetchArray()){
if($rowTags['tag_id']==$_GET['tag']) {
echo "<span class='tag current'>" . $rowTags['tagname'] . "</span>";
}
else {
echo "<span class='tag'><a class='inherit' href='tag.php?tag=".$rowTags['tag_id']."'>" . $rowTags['tagname'] . "</a></span>";
echo "<span class='tag'><a class='inherit' href='/tag/".$rowTags['tag_id']."'>" . $rowTags['tagname'] . "</a></span>";
}
}
echo "</small> </li>";
@ -39,10 +37,19 @@
?>
</ul>
<br />
<a href="index.php">&larr; Back</a>
<a href="/">&larr; Back</a>
</div>
<div id='footer'>
<h3>RSS</h3>
<img src='https://xenoteca.digital/icones/rss.png' class='rssIcon'>
<ul style='list-style-type:none;'><li><a class='skipIcon' rel='alternate' type='application/rss+xml' title='RSS General' href='https://xenoteca.digital/rss.php'>Sindicació als posts de la Xenoteca</a></li>
<?php if(isset($tagNameRow['tag_name'])) {
echo "\t\t<li><a class='skipIcon' rel='alternate' type='application/rss+xml' title='RSS per tag ".$tagNameRow['tag_name']."' href='https://xenoteca.digital/rss.php?tag=".$tagNameRow['tag_name']."'>Sindicació al tag #".$tagNameRow['tag_name']."</a></li>\n";
} ?></ul>
</div>
<script>
$("a[href^='http']").each(function() {
$("a[href^='http']").not('.skipIcon').each(function() {
$(this).css({
background: "url(https://v1.indieweb-avatar.11ty.dev/" + this.href.replace(":","%3A").replace(/\//g,"%2F") + ") left center no-repeat",
"padding-left": "22px",