add "recent additions" to homepage; add rss feed
https://pile.sdbs.cz/feed.php
This commit is contained in:
parent
257be83d9b
commit
0d6a15f06c
7 changed files with 94 additions and 2 deletions
1
db_versions/1_add_uploaded.sql
Normal file
1
db_versions/1_add_uploaded.sql
Normal file
|
@ -0,0 +1 @@
|
|||
ALTER TABLE Documents ADD UploadedTime INTEGER;
|
|
@ -6,3 +6,23 @@
|
|||
dávat ty nejdůležitější nebo nejzajímavější věci, zatim se o tom ale nikde moc nešiřte.</p>
|
||||
<p class="intro sign">/-\</p>
|
||||
</div>
|
||||
|
||||
<div class="text recent-additions">
|
||||
<h2>Recent additions</h2>
|
||||
<ul>
|
||||
<?php foreach (array_slice($recent_docs, 0, 5) as $doc): ?>
|
||||
<li>
|
||||
<a href="/?item=<?= $doc['ID'] ?>">
|
||||
<?php if (!empty($doc['UploadedTime'])): ?>
|
||||
<em>(<?= date("Y/m/d H:i:s", $doc['UploadedTime']); ?>)</em>
|
||||
<?php endif; ?>
|
||||
<?= $doc['Title'] ?>
|
||||
|
||||
<div class="recent-additions-desc">
|
||||
<?= $doc['Description'] ?>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
|
@ -113,13 +113,27 @@ class PileDB
|
|||
return $docs;
|
||||
}
|
||||
|
||||
public function getRecentDocs($count = 15)
|
||||
{
|
||||
$query = $this->db->prepare("SELECT * FROM Documents ORDER BY ID DESC LIMIT :count");
|
||||
$query->bindValue("count", $count);
|
||||
|
||||
$query_ret = $query->execute();
|
||||
$result = [];
|
||||
while ($row = $query_ret->fetchArray(SQLITE3_ASSOC)) {
|
||||
array_push($result, $row);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function updateDoc($id, $title, $author, $description, $published, $url, $tag_ids)
|
||||
{
|
||||
if (empty($id)) {
|
||||
$stmt = $this->db->prepare("INSERT INTO Documents
|
||||
(ID, Title, Author, Description, Published, URL)
|
||||
(ID, Title, Author, Description, Published, URL, UploadedTime)
|
||||
VALUES
|
||||
(NULL, :title, :author, :description, :published, :url)");
|
||||
(NULL, :title, :author, :description, :published, :url, :uploadedtime)");
|
||||
$stmt->bindValue(":uploadedtime", time(), SQLITE3_INTEGER);
|
||||
} else {
|
||||
$stmt = $this->db->prepare("UPDATE Documents SET
|
||||
Title=:title,
|
||||
|
|
|
@ -23,6 +23,19 @@ a {
|
|||
text-decoration: none;
|
||||
}
|
||||
|
||||
ul {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
ul > li {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
ul > li:before {
|
||||
content: "—";
|
||||
padding-right: .5rem;
|
||||
}
|
||||
|
||||
#sidebar {
|
||||
font-family: Prociono, serif;
|
||||
}
|
||||
|
@ -64,6 +77,7 @@ a {
|
|||
|
||||
#sidebar-taglist > ul > li:before {
|
||||
content: "/ ";
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
#sidebar-taglist-top:before {
|
||||
|
@ -175,6 +189,22 @@ a {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
.recent-additions li {
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
|
||||
.recent-additions-desc {
|
||||
font-size: 12pt;
|
||||
color: #bfbfbf;
|
||||
padding-left: calc(20px + .5rem);
|
||||
|
||||
line-height: 13pt;
|
||||
max-height: 26pt;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 64em ) {
|
||||
#sidebar-head {
|
||||
display: flex;
|
||||
|
|
26
www/feed.php
Normal file
26
www/feed.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
require '_util/PileDB.php';
|
||||
$db = new PileDB();
|
||||
$recent_docs = $db->getRecentDocs();
|
||||
|
||||
header('Content-Type: application/rss+xml');
|
||||
?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
|
||||
<channel>
|
||||
<title>/-\ pile</title>
|
||||
<link>https://pile.sdbs.cz</link>
|
||||
<atom:link href="https://pile.sdbs.cz/feed.php" rel="self" type="application/rss+xml" />
|
||||
<description>A pile of interesting documents.</description>
|
||||
|
||||
<?php foreach ($recent_docs as $doc): ?>
|
||||
<item>
|
||||
<title><?= $doc['Title'] ?></title>
|
||||
<link><?= $doc['URL'] ?></link>
|
||||
<guid>https://pile.sdbs.cz/?item=<?= $doc['ID'] ?></guid>
|
||||
<description><?= $doc['Description'] ?></description>
|
||||
</item>
|
||||
<?php endforeach; ?>
|
||||
</channel>
|
||||
</rss>
|
|
@ -33,6 +33,7 @@ if (isset($_GET["item"])) {
|
|||
$content = $doc_list_template->render('front_doc_listing.php');
|
||||
} else {
|
||||
$intro_template = new Template();
|
||||
$intro_template->recent_docs = $db->getRecentDocs();
|
||||
$content = $intro_template->render('front_intro.php');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue