init
This commit is contained in:
commit
12b3accd30
|
@ -0,0 +1,11 @@
|
||||||
|
src/**
|
||||||
|
src
|
||||||
|
static/**
|
||||||
|
*.md
|
||||||
|
hoedown
|
||||||
|
config.txt
|
||||||
|
discord_api.txt
|
||||||
|
!test.md
|
||||||
|
!README.md
|
||||||
|
.clangd
|
||||||
|
post/**
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 iceyrazor
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -0,0 +1,42 @@
|
||||||
|
# hi
|
||||||
|
this is just a personal project i made to generate and push to my static pages and rss feed at http://iceyfox.xyz and post to discord webhook
|
||||||
|
|
||||||
|
this isnt perfect and does require manual intervention. for instance. if you need to edit a post. you have to delete it from the rss feed aka the xml file. else you will have duplicates.
|
||||||
|
|
||||||
|
### this was built in mind with linux, not intended for windows
|
||||||
|
|
||||||
|
# how to download and use.
|
||||||
|
well its all shell. except for converting from md to html. witch you need hoedown. https://github.com/hoedown/hoedown
|
||||||
|
|
||||||
|
- download hoedown
|
||||||
|
- extract and compile it. should just be make.
|
||||||
|
- download this repo
|
||||||
|
- put hoedown in this repo ./
|
||||||
|
- make a directoy in this repo. static
|
||||||
|
- make a folder inside static for your 'posting' page.
|
||||||
|
- copy config.def.txt as config.txt and config it.
|
||||||
|
- prime folder is if on your webserver you want everything in a sub-directory. leave as is if you dont want it. must have trailing /!
|
||||||
|
- make post the same name as your 'posting' page
|
||||||
|
- copy index.xml and index.html to static/'posting' or static/primefolder/posting.
|
||||||
|
- in gen\_index\_list.sh edit the head -n 6 to get the top half of your index.html page. and make the one below your number +1
|
||||||
|
- optional
|
||||||
|
- make a file discord\_api.txt and put a webhook api in there if you want to
|
||||||
|
|
||||||
|
and that shoooould be everything
|
||||||
|
|
||||||
|
# running
|
||||||
|
for this ill use test.md as a example
|
||||||
|
|
||||||
|
- only run this while in the same directory as this repo. i havent edited this to run outside it, for now.
|
||||||
|
- to run you can run rss\_pull.sh if you have files from a website that allready has a simmular setup //will use the config for url to pull from
|
||||||
|
- run ``gen_index_list.sh ./test.md`` and check static/post/index.html
|
||||||
|
- run ``gen_xml.sh ./test.md`` and check static/post/index.xml
|
||||||
|
- run ``gen_html.sh ./test.md`` and check static/post/list/filename/index.html
|
||||||
|
- if you have a discord webhook and thats config'd run ``push_discord_webhook.sh ./test.md`` and check your webhook channel
|
||||||
|
- run rss\_push.sh ./test.md or upload files to your webserver
|
||||||
|
- in rss\_push.sh if ./test.md or file isnt defined it wont add the posting file, instead it will just update the existing files.
|
||||||
|
|
||||||
|
# todo
|
||||||
|
- instead of defining posting page in config. make directory for each posting page then use directory name for post
|
||||||
|
- somthing i dont remember
|
||||||
|
- error checking. mainly input file checking.
|
|
@ -0,0 +1,7 @@
|
||||||
|
url:
|
||||||
|
prime_folder:
|
||||||
|
css_file:static/static-style.css
|
||||||
|
css_upload:assets
|
||||||
|
post:updates
|
||||||
|
ftp:
|
||||||
|
user:
|
|
@ -0,0 +1,21 @@
|
||||||
|
content="$(./hoedown --hard-wrap "$1" | sed -e 's/&/\\\\&/g')"
|
||||||
|
#content=$(printf "%q" $content)
|
||||||
|
title=$(cat "$1" | head -n 1 | sed 's/# //' | sed -e 's/\r//g')
|
||||||
|
file=$(printf "$1" | sed 's/\.md$//' | sed 's/^\.\///')
|
||||||
|
|
||||||
|
config=$(cat ./config.txt)
|
||||||
|
url=$(printf "$config" | awk 'gsub(/^url:/,"")');
|
||||||
|
prime_folder=$(printf "$config" | awk 'gsub(/^prime_folder:/,"")');
|
||||||
|
post=$(printf "$config" | awk 'gsub(/^post:/,"")');
|
||||||
|
ftp=$(printf "$config" | awk 'gsub(/^ftp:/,"")');
|
||||||
|
user=$(printf "$config" | awk 'gsub(/^user:/,"")');
|
||||||
|
|
||||||
|
#f_out=$(printf "<html>\n<head>\n<link rel=\"stylesheet\" href=\"/static/static-style.css?v=76\" />\n</body>\n<div align=\"center\" class=\"static-main\">\n$content\n<br><br><a href=\"$url/$prime_folder/$post\">$url/$prime_folder/$post</a> <a href=\"../index.xml\" target=\"_blank\"><img src=\"/assets/img/RSS.png\" class=\"rss_img\"></a>\n</div></body>\n</html>")
|
||||||
|
|
||||||
|
#f_out=$(cat ./template/page.html | awk -v chunk="$content" '{gsub("<PAGE_CONTENT>",chunk)}1' | awk -v chunk="$url/$prime_folder/$post" '{gsub("<PAGE_URL>",chunk)}1' | awk -v chunk="$(date '+%B %m/%d/%Y %I:%M%p')" '{gsub("<DATE_POST>",chunk)}1')
|
||||||
|
|
||||||
|
f_out=$(awk -v content="$content" -v post="$url/$prime_folder$post" -v date="$(date '+%B %m/%d/%Y %I:%M%p')" '{gsub("<PAGE_CONTENT>",content); gsub("<PAGE_URL>",post); gsub("<DATE_POST>",date); print}' ./template/page.html)
|
||||||
|
|
||||||
|
printf "$f_out"
|
||||||
|
mkdir "static/$prime_folder$post/$file"
|
||||||
|
printf "$f_out" > "static/$prime_folder$post/$file/index.html"
|
|
@ -0,0 +1,20 @@
|
||||||
|
file=$(printf "$1" | sed 's/\.md$//' | sed 's/^\.\///')
|
||||||
|
title=$(cat "$1" | head -n 1 | sed 's/# //' | sed -e 's/\r//g')
|
||||||
|
|
||||||
|
config=$(cat ./config.txt)
|
||||||
|
url=$(printf "$config" | awk 'gsub(/^url:/,"")');
|
||||||
|
prime_folder=$(printf "$config" | awk 'gsub(/^prime_folder:/,"")');
|
||||||
|
post=$(printf "$config" | awk 'gsub(/^post:/,"")');
|
||||||
|
ftp=$(printf "$config" | awk 'gsub(/^ftp:/,"")');
|
||||||
|
user=$(printf "$config" | awk 'gsub(/^user:/,"")');
|
||||||
|
|
||||||
|
|
||||||
|
#f_end="$(cat ./$prime_folder/$post/index.html | tail -n 5)"
|
||||||
|
#f_start=$(cat ./$prime_folder/$post/index.html | awk -v RS="$f_end" 'NR==1{printf $0} NR!=1{printf "%s", $0}')
|
||||||
|
f_start=$(head -n 6 "./static/$prime_folder$post/index.html")
|
||||||
|
f_end=$(tail -n +7 "./static/$prime_folder$post/index.html")
|
||||||
|
|
||||||
|
f_out=$(printf "$f_start\n<div><a href=\"$url/$prime_folder$post/$file/index.html\">$title</a></div>\n$f_end")
|
||||||
|
|
||||||
|
printf "$f_out"
|
||||||
|
printf "$f_out" > "static/$prime_folder$post/index.html"
|
|
@ -0,0 +1,29 @@
|
||||||
|
# " --> "
|
||||||
|
# & --> &
|
||||||
|
# ' --> '
|
||||||
|
# < --> <
|
||||||
|
# > --> >
|
||||||
|
content="$(./hoedown "$1" | tail -n +2 | sed 's/</\<\;/g' | sed 's/>/\>\;/g')"
|
||||||
|
title=$(cat "$1" | head -n 1 | sed 's/# //' | sed -e 's/\r//g')
|
||||||
|
file=$(printf "$1" | sed 's/\.md$//' | sed 's/^\.\///')
|
||||||
|
|
||||||
|
config=$(cat ./config.txt)
|
||||||
|
url=$(printf "$config" | awk 'gsub(/^url:/,"")');
|
||||||
|
prime_folder=$(printf "$config" | awk 'gsub(/^prime_folder:/,"")');
|
||||||
|
post=$(printf "$config" | awk 'gsub(/^post:/,"")');
|
||||||
|
ftp=$(printf "$config" | awk 'gsub(/^ftp:/,"")');
|
||||||
|
user=$(printf "$config" | awk 'gsub(/^user:/,"")');
|
||||||
|
|
||||||
|
#f_end="$(cat ./$prime_folder/$post/index.xml | tail -n 2)"
|
||||||
|
#f_start=$(cat ./$prime_folder/$post/index.xml | awk -v RS="$f_end" 'NR==1{printf $0} NR!=1{printf "%s", $0}')
|
||||||
|
f_start=$(head -n 6 "./static/$prime_folder$post/index.xml")
|
||||||
|
f_end=$(tail -n +7 "./static/$prime_folder$post/index.xml")
|
||||||
|
|
||||||
|
|
||||||
|
pub_date=$(date '+%a, %d %b %Y %H:%M:%S %z')
|
||||||
|
|
||||||
|
f_out=$(printf "$f_start\n<item>\n\t<title>$title</title>\n\t<pubDate>$pub_date</pubDate>\n\t<link>$url/$prime_folder$post/$file/</link>\n\t<guid>$url/$prime_folder$post/$file/</guid>\n\t<description>$content</description>\n</item>\n$f_end" | awk -v chunk="$(date '+%B %d/%d/%Y %I:%M%p')" '{gsub("<DATE_POST>",chunk)}1')
|
||||||
|
|
||||||
|
|
||||||
|
printf "$f_out"
|
||||||
|
printf "$f_out" > "static/$prime_folder$post/index.xml"
|
|
@ -0,0 +1,18 @@
|
||||||
|
content="$(cat "$1" | head -n 20 | sed -z 's/\n/\\\\n/g' | sed 's/\"/\\\\"/g' | sed -e 's/\r//g')"
|
||||||
|
#content=$(printf "%q" $content)
|
||||||
|
title=$(cat "$1" | head -n 1 | sed 's/# //' | sed -e 's/\r//g')
|
||||||
|
file=$(printf "$1" | sed 's/\.md$//' | sed 's/^\.\///')
|
||||||
|
|
||||||
|
config=$(cat ./config.txt)
|
||||||
|
url=$(printf "$config" | awk 'gsub(/^url:/,"")');
|
||||||
|
local_folder=$(printf "$config" | awk 'gsub(/^local_folder:/,"")');
|
||||||
|
prime_folder=$(printf "$config" | awk 'gsub(/^prime_folder:/,"")');
|
||||||
|
post=$(printf "$config" | awk 'gsub(/^post:/,"")');
|
||||||
|
ftp=$(printf "$config" | awk 'gsub(/^ftp:/,"")');
|
||||||
|
user=$(printf "$config" | awk 'gsub(/^user:/,"")');
|
||||||
|
discord_webhook=$(cat discord_api.txt);
|
||||||
|
|
||||||
|
f_out=$(cat ./template/webhook.json | awk -v chunk="$content" '{gsub("<PAGE_CONTENT>",chunk)}1' | awk -v chunk="$url/$prime_folder$post/$file" '{gsub("<PAGE_URL>",chunk)}1' | awk -v chunk="$post" '{gsub("<POST_NAME>",chunk)}1' | awk -v chunk="$url/$prime_folder$post" '{gsub("<PAGE_PAGE>",chunk)}1' | awk -v chunk="$(date '+%B %m/%d/%Y %I:%M%p')" '{gsub("<DATE_POST>",chunk)}1')
|
||||||
|
|
||||||
|
printf "$f_out\n\n"
|
||||||
|
curl -X POST -H "Content-Type: application/json" -d "$f_out" "$discord_webhook"
|
|
@ -0,0 +1 @@
|
||||||
|
find . -type f -exec sed -i 's/old_string/new_string/g' {} \;
|
|
@ -0,0 +1,18 @@
|
||||||
|
config=$(cat ./config.txt)
|
||||||
|
url=$(printf "$config" | awk 'gsub(/^url:/,"")');
|
||||||
|
prime_folder=$(printf "$config" | awk 'gsub(/^prime_folder:/,"")');
|
||||||
|
post=$(printf "$config" | awk 'gsub(/^post:/,"")');
|
||||||
|
ftp=$(printf "$config" | awk 'gsub(/^ftp:/,"")');
|
||||||
|
user=$(printf "$config" | awk 'gsub(/^user:/,"")');
|
||||||
|
|
||||||
|
cd static/
|
||||||
|
cd $prime_folder
|
||||||
|
rm static-style.css
|
||||||
|
wget $url/static/{$prime_folder}static-style.css
|
||||||
|
|
||||||
|
cd $post
|
||||||
|
rm index.html
|
||||||
|
wget $url/static/$prime_folder$post/index.html
|
||||||
|
|
||||||
|
rm index.xml
|
||||||
|
wget $url/static/$prime_folder$post/index.xml
|
|
@ -0,0 +1,79 @@
|
||||||
|
config=$(cat ./config.txt)
|
||||||
|
file=$(printf "$1" | sed 's/\.md$//' | sed 's/^\.\///')
|
||||||
|
url=$(printf "$config" | awk 'gsub(/^url:/,"")');
|
||||||
|
prime_folder=$(printf "$config" | awk 'gsub(/^prime_folder:/,"")');
|
||||||
|
css_file=$(printf "$config" | awk 'gsub(/^css_file:/,"")');
|
||||||
|
css_upload_folder=$(printf "$config" | awk 'gsub(/^css_upload_folder:/,"")');
|
||||||
|
post=$(printf "$config" | awk 'gsub(/^post:/,"")');
|
||||||
|
ftp=$(printf "$config" | awk 'gsub(/^ftp:/,"")');
|
||||||
|
user=$(printf "$config" | awk 'gsub(/^user:/,"")');
|
||||||
|
|
||||||
|
prime_folder_cmd=""
|
||||||
|
prime_cd_cmd=""
|
||||||
|
prime_mkdir=""
|
||||||
|
if [ "$prime_folder" != "" ]; then
|
||||||
|
prime_folder_cmd="lcd $prime_folder"
|
||||||
|
prime_cd_cmd="cd $prime_folder"
|
||||||
|
prime_mkdir="mkdir $prime_folder"
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -s -p "ftp_password: " pass
|
||||||
|
printf "\n\n"
|
||||||
|
|
||||||
|
if [ "$1" == "" ]; then
|
||||||
|
|
||||||
|
#upload only index.xml/html listing and other assets
|
||||||
|
ftp -n <<EOF
|
||||||
|
open $ftp
|
||||||
|
user $user $pass
|
||||||
|
|
||||||
|
cd public_html
|
||||||
|
cd $css_upload_folder
|
||||||
|
lcd static
|
||||||
|
put $css_file
|
||||||
|
cd /public_html
|
||||||
|
|
||||||
|
$prime_mkdir
|
||||||
|
$prim_cd_cmd
|
||||||
|
|
||||||
|
$prime_folder_cmd
|
||||||
|
|
||||||
|
mkdir "$post"
|
||||||
|
cd "$post"
|
||||||
|
lcd "$post"
|
||||||
|
put index.xml
|
||||||
|
put index.html
|
||||||
|
EOF
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
ftp -n -vvv <<EOF
|
||||||
|
open $ftp
|
||||||
|
user $user $pass
|
||||||
|
|
||||||
|
cd public_html
|
||||||
|
cd $css_upload_folder
|
||||||
|
lcd static
|
||||||
|
put $css_file
|
||||||
|
|
||||||
|
cd /public_html
|
||||||
|
|
||||||
|
$prime_mkdir
|
||||||
|
$prim_cd_cmd
|
||||||
|
|
||||||
|
$prime_folder_cmd
|
||||||
|
|
||||||
|
|
||||||
|
mkdir "$post"
|
||||||
|
cd "$post"
|
||||||
|
lcd "$post"
|
||||||
|
put index.xml
|
||||||
|
put index.html
|
||||||
|
|
||||||
|
mkdir "$file"
|
||||||
|
cd "$file"
|
||||||
|
lcd "$file"
|
||||||
|
put index.html
|
||||||
|
EOF
|
||||||
|
|
||||||
|
fi
|
|
@ -0,0 +1,11 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="/assets/static-style.css?v=1" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="static-main" >
|
||||||
|
<br><br>
|
||||||
|
rss: <a href="./index.xml" target="_blank"><img src="/assets/img/RSS.png" class="rss_img"></img></a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<rss version="2.0">
|
||||||
|
<channel>
|
||||||
|
<title>iceys updates</title>
|
||||||
|
<link>http://iceyfox.xyz/static/test</link>
|
||||||
|
<description>this is a rss test</description>
|
||||||
|
</channel>
|
||||||
|
</rss>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="/assets/static-style.css?v=80" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="static-main">
|
||||||
|
<PAGE_CONTENT>
|
||||||
|
<br><br>
|
||||||
|
<a href="<PAGE_URL>"><PAGE_URL></a>
|
||||||
|
<a href="../index.xml" target="_blank">
|
||||||
|
<img src="/assets/img/RSS.png" class="rss_img">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"username":"iceyfox:<POST_NAME>",
|
||||||
|
"content":"<DATE_POST> <PAGE_PAGE>\nread more here: <PAGE_URL>\n<PAGE_CONTENT>\n---"
|
||||||
|
}
|
Loading…
Reference in New Issue