added categories

This commit is contained in:
sose 2021-04-02 12:06:43 +00:00
parent 5cbbce51ee
commit 8fae65292a
1 changed files with 20 additions and 2 deletions

View File

@ -1,13 +1,22 @@
#!/usr/bin/php
<?php
$READER_LINK = "reader";
$abs_path = "gemini://" . getenv("SERVER_NAME") . getenv("SCRIPT_NAME");
$READER_LINK = dirname($abs_path) . "/reader";
# ^^^^^^^ uri path to an instance of reader.php
# the default is relative, and assumes you have one in the same directory as this script
$abs_path = "gemini://" . getenv("SERVER_NAME") . getenv("SCRIPT_NAME");
$topics = array("WORLD", "BUSINESS", "TECHNOLOGY", "ENTERTAINMENT", "SPORTS", "SCIENCE", "HEALTH");
$feed_title = "";
$feed = new XMLReader;
$feed->open("https://news.google.com/atom?" . getenv("QUERY_STRING"), "utf-8");
if ( getenv("PATH_INFO") !== null ) {
$feed->open("https://news.google.com/atom" . getenv("PATH_INFO") . "?" . getenv("QUERY_STRING"), "utf-8");
} else {
$feed->open("https://news.google.com/atom?" . getenv("QUERY_STRING"), "utf-8");
}
$feed->read();
echo "20 text/gemini\n";
@ -19,7 +28,16 @@ echo "/_/ |_/_____/ |__/|__//____(_)_/ /_/ /_/_/ \n";
echo "====================================================\n";
echo " \"Yeah it's news\" \n";
echo "====================================================\n";
foreach ($topics as $topic) {
echo "=> " . getenv("SCRIPT_NAME") . "/headlines/section/topic/" . $topic . " " . $topic . "\n";
}
while ($feed->read()) {
if ($feed->name === "title" && $feed_title === "") {
$feed_title = $feed->readInnerXml();
$feed_title = str_replace(" - Google News", "", $feed_title);
echo "\n#" . $feed_title . "\n";
}
if ( $feed->name === "entry") {
$entries= $feed->expand();
foreach ($entries->childNodes as $entry_node) {