Skip to content
Snippets Groups Projects
Commit b46a15b7 authored by Bob Mottram's avatar Bob Mottram
Browse files

smolrss webui settings

parent c4b60a84
No related branches found
No related tags found
No related merge requests found
......@@ -43,6 +43,19 @@ smolrss_variables=(ONION_ONLY
DDNS_PROVIDER
MY_USERNAME)
function smolrss_update_settings_template {
# Creates rss feeds list within the web UI
read_config_param SMOLRSS_DOMAIN_NAME
# shellcheck disable=SC2154
app_settings_screen_template="$webadmin_install_dir/settings_smolrss_template.html"
app_settings_screen="$webadmin_install_dir/settings_smolrss.html"
cp "$app_settings_screen_template" "$app_settings_screen"
feedslist=$(sed 's@[/\&]@\\&@g;s/$/\\/' "/var/www/$SMOLRSS_DOMAIN_NAME/htdocs/feeds.txt"; echo .)
feedslist=${feedslist%.}
sed -i "s|RSSFEEDS|$feedslist|g" "$app_settings_screen"
chown www-data:www-data "$app_settings_screen"
}
function logging_on_smolrss {
echo -n ''
}
......
......@@ -52,6 +52,7 @@ FIREWALL_DOMAINS=/root/${PROJECT_NAME}-firewall-domains.cfg
local_hostname=$(grep 'host-name' /etc/avahi/avahi-daemon.conf | awk -F '=' '{print $2}').local
webadmin_install_dir="/var/www/${local_hostname}/htdocs/admin"
smolrss_file="$webadmin_install_dir/.rssfeeds.txt"
syncthing_file="$webadmin_install_dir/.syncthing.txt"
appsettings_file="$webadmin_install_dir/.appsettings.txt"
factoryreset_file="$webadmin_install_dir/.factoryreset.txt"
......@@ -1416,6 +1417,18 @@ function syncthing_update_settings_template {
chown www-data:www-data "$app_settings_screen"
}
function smolrss_update_settings_template {
# Creates rss feeds list within the web UI
# shellcheck disable=SC2154
app_settings_screen_template="$webadmin_install_dir/settings_smolrss_template.html"
app_settings_screen="$webadmin_install_dir/settings_smolrss.html"
cp "$app_settings_screen_template" "$app_settings_screen"
feedslist=$(sed 's@[/\&]@\\&@g;s/$/\\/' "/var/www/$SMOLRSS_DOMAIN_NAME/htdocs/feeds.txt"; echo .)
feedslist=${feedslist%.}
sed -i "s|RSSFEEDS|$feedslist|g" "$app_settings_screen"
chown www-data:www-data "$app_settings_screen"
}
function update_syncthing {
if [ -f "$syncthing_file" ]; then
......@@ -1454,6 +1467,43 @@ function update_syncthing {
fi
}
function update_smolrss {
if [ -f "$smolrss_file" ]; then
SMOLRSS_DOMAIN_NAME=$(grep 'SMOLRSS_DOMAIN_NAME=' "/root/${PROJECT_NAME}.cfg" | awk -F '=' '{print $2}')
cd "/var/www/$SMOLRSS_DOMAIN_NAME/htdocs" || return
if [ -f "feeds.new" ]; then
rm "feeds.new"
fi
touch "feeds.new"
feeds_lines_ctr=0
while read -r line; do
if [ $feeds_lines_ctr -gt 1024 ]; then
# This prevents someone copy-pasting a giant amount of text
# into the rss feeds
break
fi
feeds_lines_ctr=$((feeds_lines_ctr + 1))
if [ "$line" ]; then
# remove leading and trailing spaces
newline="$(echo -e "${line}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
echo "$newline" >> "feeds.new"
fi
done < "$smolrss_file"
mv "feeds.new" feeds.txt
./create_feeds feeds.txt > feeds.xml
chown www-data:www-data feeds.txt
rm "$smolrss_file"
smolrss_update_settings_template
fi
}
function update_blocklist {
if [ -f "$blocklist_file" ]; then
......@@ -1779,6 +1829,7 @@ do
add_remove_users
update_app_settings
update_syncthing
update_smolrss
webadmin_upgrade
install_apps_from_webadmin
sleep 1
......
<!DOCTYPE html>
<html>
<head>
<style>
#headerpic {
width: 60%;
height: auto;
margin-right : auto;
margin-left : auto;
min-width : 220px;
}
.header {
text-align: center;
padding: 32px;
}
.card {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
max-width: 600px;
margin: auto;
text-align: center;
font-family: arial;
clear: both;
}
.card input[type=text] {
width: 90%;
clear: both;
text-align: center;
color: black;
background-color: lightblue;
}
.appurl {
color: grey;
font-size: 100%;
}
.welcomeheader {
color: black;
font-size: 200%;
font-weight: bold;
}
.descriptiontext {
color: black;
font-size: 90%;
}
.logintext {
color: black;
font-size: 120%;
font-weight: bold;
color: #981737;
}
button {
border: none;
outline: 0;
display: inline-block;
padding: 8px;
color: white;
background-color: #000;
text-align: center;
cursor: pointer;
width: 100%;
font-size: 18px;
}
a {
text-decoration: none;
color: black;
}
button:hover, a:hover {
opacity: 0.7;
}
.chip {
display: inline-block;
padding: 0 25px;
height: 50px;
font-size: 70%;
line-height: 50px;
border-radius: 25px;
background-color: #f1f1f1;
}
.chip img {
float: left;
margin: 0 10px 0 -25px;
height: 50px;
width: 50px;
border-radius: 50%;
}
textarea {
width: 90%;
color: black;
font-weight: bold;
background: lightblue;
font-size: 120%;
}
</style>
</head>
<body>
<div class="card">
<div class="header">
<a href="app_smolrss.html"><img id="headerpic" class="img-responsive" src="images/logo.png"></a><br>
<p class="descriptiontext">RSS Feeds</p>
<form action="settings_smolrss.php" method="post">
<textarea rows="10" cols="50" name="feeds">RSSFEEDS</textarea>
<br><br>
<input type="submit" name="submitcancel" value="Cancel">
<input type="submit" name="submitfeeds" value="Update">
</form>
<br>
</div>
</div>
</body>
</html>
<?php
// SmolRSS feeds
$output_filename = "app_smolrss.html";
if (isset($_POST['submitfeeds'])) {
$feeds = htmlspecialchars($_POST['feeds']);
$feeds_file = fopen(".rssfeeds.txt", "w") or die("Unable to create feeds file");
fwrite($feeds_file, $feeds);
fclose($feeds_file);
}
$htmlfile = fopen("$output_filename", "r") or die("Unable to open $output_filename");
echo fread($htmlfile,filesize("$output_filename"));
fclose($htmlfile);
?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment