an RSS and Atom creator in pure nim
2024-01-06 13:59:43 -06:00
src initial commit 2024-01-06 12:59:45 -06:00
tests adding tests 2024-01-06 13:00:38 -06:00
compile_switches_rpi.nims initial commit 2024-01-06 12:59:45 -06:00
config.nims initial commit 2024-01-06 12:59:45 -06:00
LICENSE.md adding license 2024-01-06 13:59:43 -06:00
README.md correcting typo in readme 2024-01-06 13:44:26 -06:00

RSS creator

This library uses rssatom, anonimongo, and NimYAML. Please refer to these libraries for their usage and documentation.

This only requires compilation with nim 2.0 and a YAML file with the following structure:

%YAML 1.2
---
id: comalmx
title: RSS de COMAL
link: https://comalmx.org
description: RSS de COMAL y aliadxs. Este es un ejemplo del feed
language: spa
copyright: Copyright material depends on where the contents where published
generator: samsamros
author: 
  name: samsamros
  email: samsamros@comalmx.org
  uri: none
file: /fullpath/tests/prueba.csv
dates:
  fromDate: 05/05/1990
  toDate: 02/10/2024
outputpath: /fulloutputpath/Downloads/
outputfilename: test
outputtype: rss
themes: []

Other requirements: rssatom == 2.7, anonimongo == 0.7.0, NimYAML == 2.1.0

compiling:

$nim c --out=buildrss main.nim

usage (try it out with the tests):

$./buildrss ../tests/test1.yml
$./buildrss ../tests/test1_1_dates.yml
$./buildrss ../tests/test-mongodb.yml

YAML config

Each of the fields will build the RSS object and parse through a CSV or a MongoDB collection.

%YAML 1.2
---
id: #The RSS' id, this can be done by the user
title: #The RSS' title
link: #main link, anything the end-user wants
description: #Briefly describe the RSS feed
language: #language: en, spa or other acronyms
copyright: #if there's a license, add it
generator: #Who or what generated the feed
author: 
  name: #the name of the generator or main author
  email: #email of the generator or main author
  uri: #url to the generator o main author's website
file: # SEE BELOW
dates:
  fromDate: # SEE BELOW
  toDate: # SEE BELOW
outputpath: #full path to the directory where the rss feed will be stored
outputfilename: #name of the RSS feed file
outputtype: #it can either be rss or atom
themes: # SEE BELOW

  • file: this can either be the full path to a csv or a MongoDB colleciton with the following schema (please see the file prueba.csv or the MongoDB dump:
    This is still restricted to the following schema:
        title,
        link,
        description,
        author_name,
        author_email,
        author_uri,
        category,
        comments,
        guid,
        pubDate,
        updated
    

If a file is chosen, a full path must be provided to the csv:

...
file: /fullpath/prueba.csv # or whatever your file is named
...

If a MongoDB collection is chosen the URI must comply with the following

  • Passwordless: mongodb://127.0.0.1:27017/?database=rssfeed&collection=rsstoday
  • In addition to the regular URI, include the query with the following:
    • ?
    • database=NameOfDatabase
    • collection=NameOfCollection
  • Password connection:
    • Authentication has been hardcoded to SHA-256, please upgrade your authentication algorithm. mongodb://user:password@127.0.0.1:27017/rssfeed?database=rssfeed&collection=rsstoday
  • This includes the database and collection queries. In addition it also includes user and passsword. For this database, the user is stored within the database and not as an admin user, so in order for authentication to work, the path to the database must be included */rssfeed/
  • The program automatically separates the URI from the query, but the query is necessary to complete authentication.

  • fromDate and toDate: Either a string date with the following format can be added dd/MM/yyyy. This will parse a CSV file or a MongoDB collection with the following criteria fromDate <= newsDate => toDate

However, users can opt for adding the following to toDate:

...
	toDate: today
...

this will call the now() proc in nim and use date arithmetic with the following options available in fromDate: month, week, day

	fromDate: month
	toDate: today
...

this will query all news in the CSV or a MongoDB collection that was produced a month ago.


  • themes: a YAML array that helps create more xml files based on categories stored in the database. In the CSV file, categories are separated by - with no whitespaces. In MongoDB, this is a sample array. See examples for more information.
    • If themes is equal to [] no categories will be produced and a single xml file will be dumped.
    • If themes is an array with categories, additional xml files will be produced. Run the tests yourself for more info!
    ...
    themes:
    	- crime
    	- cyberpunk
    	- cats
    

This is under development

I'm providing additional compile switches for Raspberry pi 4 devices