Sfoglia il codice sorgente

Initial commit

master
The Dod 4 anni fa
commit
8aaace3a1e
7 ha cambiato i file con 63 aggiunte e 0 eliminazioni
  1. 1
    0
      .gitignore
  2. 7
    0
      README.md
  3. 23
    0
      fortune.rss
  4. 24
    0
      fortune.rss.py
  5. 3
    0
      install.sh
  6. 4
    0
      makefortune.sh
  7. 1
    0
      requirements.txt

+ 1
- 0
.gitignore Vedi File

@@ -0,0 +1 @@
1
+venv

+ 7
- 0
README.md Vedi File

@@ -0,0 +1,7 @@
1
+### To install
2
+`./install.sh`
3
+
4
+### To run
5
+`/PATH/TO/makefortune.sh` would create fortune.rss in the `/PATH/TO/` folder.
6
+
7
+For best results, do this as a cronjob, and make `/PATH/TO/` accessible by web.

+ 23
- 0
fortune.rss Vedi File

@@ -0,0 +1,23 @@
1
+<rss version="2.0"><channel><title>Fortune</title><link>https://linux.die.net/man/6/fortune</link><description>Random, hopefully interesting, adages</description><item><title>You will stop at nothing to reach your objective, but only because your
2
+brakes are defective.
3
+</title></item><item><title>Let us endeavor so to live that when we come to die even the undertaker will be
4
+sorry.
5
+		-- Mark Twain, "Pudd'nhead Wilson's Calendar"
6
+</title></item><item><title>The lunatic, the lover, and the poet,
7
+Are of imagination all compact...
8
+		-- Wm. Shakespeare, "A Midsummer Night's Dream"
9
+</title></item><item><title>Hain't we got all the fools in town on our side?  And hain't that a big
10
+enough majority in any town?
11
+		-- Mark Twain, "Huckleberry Finn"
12
+</title></item><item><title>You'll be sorry...
13
+</title></item><item><title>Having nothing, nothing can he lose.
14
+		-- William Shakespeare, "Henry VI"
15
+</title></item><item><title>Beware of Bigfoot!
16
+</title></item><item><title>Writing is turning one's worst moments into money.
17
+		-- J.P. Donleavy
18
+</title></item><item><title>Q:	Why is Christmas just like a day at the office?
19
+A:	You do all of the work and the fat guy in the suit
20
+	gets all the credit.
21
+</title></item><item><title>Q:	How many WASPs does it take to change a light bulb?
22
+A:	One.
23
+</title></item></channel></rss>

+ 24
- 0
fortune.rss.py Vedi File

@@ -0,0 +1,24 @@
1
+import sys
2
+from subprocess import Popen, PIPE
3
+from min_rss_gen.generator import start_rss, gen_item
4
+import xml.etree.ElementTree
5
+
6
+FEED_LINK = 'https://linux.die.net/man/6/fortune'
7
+FEED_TITLE = 'Fortune'
8
+FEED_DESCRIPTION = 'Random, hopefully interesting, adages'
9
+NUM_ITEMS = 10
10
+
11
+rss_items = []
12
+
13
+for i in range(NUM_ITEMS):
14
+    with Popen(['fortune', '-s'], encoding='utf-8', stdout=PIPE) as fortune:
15
+        rss_items.append(gen_item(title=fortune.stdout.read()))
16
+
17
+rss_xml_element = start_rss(
18
+    title=FEED_TITLE, link=FEED_LINK,
19
+    description=FEED_DESCRIPTION, items=rss_items)
20
+
21
+sys.stdout.write(str(
22
+    xml.etree.ElementTree.tostring(
23
+        rss_xml_element, encoding='utf-8', method='xml'),
24
+    'utf-8'))

+ 3
- 0
install.sh Vedi File

@@ -0,0 +1,3 @@
1
+virtualenv -p python3 venv
2
+. venv/bin/activate
3
+pip install -r requirements.txt

+ 4
- 0
makefortune.sh Vedi File

@@ -0,0 +1,4 @@
1
+#!/bin/sh
2
+cd "$(dirname "$0")"
3
+. venv/bin/activate
4
+python fortune.rss.py > fortune.rss

+ 1
- 0
requirements.txt Vedi File

@@ -0,0 +1 @@
1
+min-rss==0.0.3

Loading…
Annulla
Salva