Skip to content

Commit

Permalink
Added 'noindex' meta tag and cleaning up the rss code
Browse files Browse the repository at this point in the history
  • Loading branch information
patperu committed Feb 25, 2016
1 parent cfd0397 commit 012d447
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Expand Up @@ -2,7 +2,7 @@ Package: albopop
Title: Read some 'Albo Pretorio' pages and build a RSS feeds
Description: Provides functions to read some 'Albo Pretorio' pages and export a
RSS feed
Version: 0.1.0
Version: 0.1.1
Authors@R: c(
person("Patrick", "Hausmann", role = c("aut", "cre"), email = "patrick.hausmann@covimo.de")
)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Expand Up @@ -7,6 +7,7 @@ export(ap_parse_page)
export(ap_send_telegram)
export(disk)
importFrom(XML,addNode)
importFrom(XML,newXMLNode)
importFrom(XML,saveXML)
importFrom(XML,xmlParse)
importFrom(XML,xmlRoot)
Expand Down
2 changes: 1 addition & 1 deletion R/albopop-package.R
Expand Up @@ -12,7 +12,7 @@
#' @importFrom purrr flatten_chr map_chr
#' @importFrom stringr str_replace
#' @importFrom XML xmlTree addNode saveXML xpathSApply
#' xmlRoot xmlParse xmlValue xmlTreeParse
#' xmlRoot xmlParse xmlValue xmlTreeParse newXMLNode
#' @importFrom xml2 read_html
NULL

Expand Down
8 changes: 5 additions & 3 deletions R/ap_build_rss.R
Expand Up @@ -22,11 +22,14 @@ ap_build_rss <- function(x, rss_title, rss_link, rss_file, store = disk()) {
x$Fino <- Set_Date(x$Fino)
x$timestamp <- x$Inizio

feed <- xmlTree("rss")
feed <- xmlTree("rss", attrs=list(version = "2.0"))
feed$addNode("channel", close=FALSE)
feed$addNode("title", rss_title)
feed$addNode("description", paste0(rss_title, " Albo POP RSS"))
feed$addNode("link", rss_link)
feed$addNode(newXMLNode("xhtml:meta",
namespaceDefinitions = list(xhtml= "http://www.w3.org/1999/xhtml"),
attrs = list(name = "robots", content = "noindex")))
feed$addNode("language", "it")

for (i in 1:nrow(x)) {
Expand All @@ -42,8 +45,7 @@ ap_build_rss <- function(x, rss_title, rss_link, rss_file, store = disk()) {

feed$closeTag()

rss <- str_replace(saveXML(feed, prefix = '<?xml version="1.0" encoding="UTF-8"?>\n',
encoding = "UTF-8"), "<rss>", '<rss version="2.0">')
rss <- saveXML(feed, prefix = '<?xml version="1.0" encoding="UTF-8"?>\n')

#writeLines(rss, con = file.path("feed", rss_file))

Expand Down
1 change: 1 addition & 0 deletions README.Rmd
Expand Up @@ -26,6 +26,7 @@ The following functions are implemented:

### News

- Version 0.1.1 : added `noindex` meta tag ([#90 in aborruso/albo-pop ](https://github.com/aborruso/albo-pop/issues/90))
- Version 0.1.0 released

### Installation
Expand Down
17 changes: 9 additions & 8 deletions README.md
Expand Up @@ -11,6 +11,7 @@ The following functions are implemented:

### News

- Version 0.1.1 : added `noindex` meta tag ([\#90 in aborruso/albo-pop](https://github.com/aborruso/albo-pop/issues/90))
- Version 0.1.0 released

### Installation
Expand All @@ -28,7 +29,7 @@ library("rvest")

# current version
packageVersion("albopop")
## [1] '0.1.0'
## [1] '0.1.1'
```

The function `ap_parse_page` parse the content for different sites. The parameter `site` specify the type of input. Currently four providers are supported:
Expand All @@ -43,14 +44,14 @@ To parse the announcements for the [Comune di Lu](http://albo.studiok.it/lu/albo
``` r
res <- ap_parse_page(url = "http://albo.studiok.it/lu/albo", site = "studiok")
str(res)
## Classes 'albopop_srs' and 'data.frame': 39 obs. of 7 variables:
## $ APNumero : chr "60 / 2016" "59 / 2016" "58 / 2016" "57 / 2016" ...
## Classes 'albopop_srs' and 'data.frame': 44 obs. of 7 variables:
## $ APNumero : chr "67 / 2016" "66 / 2016" "65 / 2016" "64 / 2016" ...
## $ Descrizione: chr "" "" "" "" ...
## $ Tipo : chr "DELIBERA DI GIUNTA" "VARIE COMUNE DI LU" "DELIBERA DI GIUNTA" "DELIBERA DI GIUNTA" ...
## $ Oggetto : chr "[60 / 2016] DELIBERA GIUNTA COMUNALE N. 10 DEL 26/01/2016" "[59 / 2016] CONTRIBUTI REGIONALI PER RACCOLTA, TRASPORTO E SMALTIMENTO DI PICCOLI QUANTITATIVI DI AMIANTO (ETERNIT)" "[58 / 2016] DELIBERA GIUNTA COMUNALE N. 109 DEL 12/11/2015" "[57 / 2016] DELIBERA GIUNTA COMUNALE N. 56 DEL 07/07/2015" ...
## $ Inizio : chr "19/02/2016" "18/02/2016" "18/02/2016" "18/02/2016" ...
## $ Fino : chr "05/03/2016" "24/02/2016" "04/03/2016" "04/03/2016" ...
## $ link : chr "http://albo.studiok.it/lu/albo/dettaglio.php?id=MES00000000602016" "http://albo.studiok.it/lu/albo/dettaglio.php?id=MES00000000592016" "http://albo.studiok.it/lu/albo/dettaglio.php?id=MES00000000582016" "http://albo.studiok.it/lu/albo/dettaglio.php?id=MES00000000572016" ...
## $ Tipo : chr "DETERMINA" "DETERMINA" "DELIBERA DI CONSIGLIO" "DELIBERA DI CONSIGLIO" ...
## $ Oggetto : chr "[67 / 2016] DETERMINA RESPONSABILE SERVIZIO FINANZIARIO N. 3 DEL 17/02/2016" "[66 / 2016] DETERMINA RESPONSABILE SERVIZIO FINANZIARIO N. 2 DEL 15/02/2016" "[65 / 2016] DELIBERA CONSIGLIO COMUNALE N. 08 DEL 10/02/2016" "[64 / 2016] DELIBERA CONSIGLIO COMUNALE N. 07 DEL 10/02/2016" ...
## $ Inizio : chr "24/02/2016" "24/02/2016" "24/02/2016" "24/02/2016" ...
## $ Fino : chr "10/03/2016" "10/03/2016" "10/03/2016" "10/03/2016" ...
## $ link : chr "http://albo.studiok.it/lu/albo/dettaglio.php?id=MES00000000672016" "http://albo.studiok.it/lu/albo/dettaglio.php?id=MES00000000662016" "http://albo.studiok.it/lu/albo/dettaglio.php?id=MES00000000652016" "http://albo.studiok.it/lu/albo/dettaglio.php?id=MES00000000642016" ...
```

The function `ap_build_rss` generates an RSS feed and writes a simple XML file in the local default directory `feed`. The input must contain at least three columns named `Oggetto`, `Inizio` and `link`. To write the file "Lu.xml":
Expand Down

0 comments on commit 012d447

Please sign in to comment.