blob: 44df5fbafc2a4a241df48031f313c4185003e2f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
#!/bin/bash
# taken from https://github.com/maxhebditch/rss-roller/
# modified by Mohit Agarwal
# Configuration
title="Unorthodox Monologues"
link="https://mohit.uk/blogs/unmono"
description="Abby's Blog"
rsslink="$link/feed.xml"
feedname="./feed.xml"
postDir="./unmono/"
echo "./feed.sh------------------------------------------------"
echo " Feed builder RSS/ATOM"
echo " Written by Mohit Agarwal"
echo " INTERNAL USE ONLY"
echo "---------------------------------------------------------"
echo ""
echo "TITLE" $title
echo "LINK " $link
echo "RSS L" $rsslink
echo "RSS F" $feedname
echo "DESCR" $description
echo "POSTD" $postDir
header () {
echo """<?xml version='1.0' encoding='UTF-8' ?>
<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'>
<!-- Made using rss-roller https://github.com/maxhebditch/rss-roller -->
""" > ~/feedtop
echo """
<channel>
<title>$title</title>
<link>$link</link>
<description>$description</description>
<atom:link href='$rsslink' rel='self' type='application/rss+xml' />
""" >> ~/feedtop
}
footer () {
echo """
</channel>
</rss>
""" >> ~/feedbottom
}
item () {
echo """<item>
<title>$fullTitle</title>
<link>$linkadd</link>
<guid>$guid</guid>
<content>
$fullText
</content>
<description>
$fullText
</description>
</item>
""" >> ~/feed
echo """<item>
<title>$fullTitle</title>
<link>$linkadd</link>
<guid isPermaLink='false'>$guidadd</guid>
</item>
""" >> ~/feed
}
combine () {
header
footer
cat ~/feedtop ~/feed > ~/feedtb
cat ~/feedtb ~/feedbottom > $feedname
rm ~/feedtop ~/feed ~/feedtb ~/feedbottom
}
if [[ ! -f $feedname ]]; then
touch $feedname
fi
echo ""
echo "BUILDING FEED"
#Do the bad thing
if [[ -f $feedname ]]; then
rm $feedname
fi
touch $feedname
postArray=( $(ls -r "$postDir"/*.html | grep -v index.html) )
numPosts=$(ls -r "$postDir"/*.html | grep -v index.html | wc -l)
echo "numPosts is $numPosts"
postNum=0
guidadd=$linkadd
for posts in "${postArray[@]}"; do
let postNum+=1
post=$posts
echo " adding post $postNum/$numPosts : $post"
fullTitle=$(grep -o '>.*</h1>' $post | sed 's/\(>\|<\/h1>\)//g')
postname=${post##*/}
linkadd="$link"/"$postname"
fullText=$(pandoc ../${post/%html/md} -t html)
item $post
done
combine
exit
|