Skip to content

Commit 5d5d292

Browse files
committed
initial test
1 parent 4d829de commit 5d5d292

25 files changed

+196
-266
lines changed

.travis.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: r
2+
sudo: false
3+
latex: false
4+
pandoc: false
5+
cache: packages
6+
7+
before_install:
8+
- git config --global user.email "[email protected]"
9+
- git config --global user.name "yufree"
10+
script:
11+
- Rscript R/fetch.R
12+
13+
after_success:
14+
- git add --all *
15+
- git commit -m "Daily update"
16+
- git push -q https://${GITHUB_PAT}@github.com/${TRAVIS_REPO_SLUG}.git HEAD:master

DESCRIPTION

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Package: placeholder
2+
Title: DailyR
3+
Version: 0.0.1
4+
Remotes: yufree/scifetch

R/fetch.R

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
dir.create('content/post', showWarnings = FALSE)
2+
d = Sys.Date()
3+
4+
p = list.files('content/post/', '^\\d{4,}-\\d{2}-\\d{2}-\\d{1,}[.]md$')
5+
p = max(as.Date(gsub('-\\d{1,}.md$', '', p)))
6+
if (length(p) && d <= p && !interactive()) q('no')
7+
8+
if (!file.exists(f <- 'R/list.txt')) writeLines('website, update', f)
9+
m = read.csv(f, colClasses = "character")
10+
d = as.character(d)
11+
x = NULL
12+
n = 0
13+
14+
for (i in 1:NROW(m)) {
15+
a <- scifetch::getrss(m[i,1])
16+
n <- sum(as.POSIXct(a$date[1:10])>as.POSIXct(m[i,2]))
17+
if(n>0){
18+
temp <- a[1:n,]
19+
x <- rbind(temp,x)
20+
## update date
21+
m[i,2] <- as.character(max(as.POSIXct(a$date[1:10])))
22+
}
23+
}
24+
if(NROW(x)>0){
25+
for (i in 1:NROW(x)){
26+
p = sprintf('content/post/%s.md', paste0(d,'-',i))
27+
sink(p)
28+
cat('---\n')
29+
cat(yaml::as.yaml(x[i,]))
30+
cat('---\n')
31+
sink()
32+
}
33+
}
34+
35+
36+
write.csv(m[order(m$update), , drop = FALSE], f, row.names = FALSE)

R/list.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"website","update"
2+
"feeds.feedburner.com/ProfessorRobJHyndman","2018-01-01"
3+
"simplystatistics.org/index.xml","2018-01-22"
4+
"yihui.name/index.xml","2018-01-26"

config.toml

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
baseurl = "/"
22
languageCode = "en-us"
3-
title = "Hugo XMag"
3+
title = "Daily R"
44
theme = "hugo-xmag"
55
googleAnalytics = ""
66
disqusShortname = ""
@@ -11,9 +11,6 @@ hasCJKLanguage = true
1111
enableEmoji = true
1212
paginate = 6
1313

14-
[permalinks]
15-
post = "/post/:year/:month/:day/:slug/"
16-
1714
[[menu.main]]
1815
name = "Home"
1916
url = "/"
@@ -22,14 +19,6 @@ paginate = 6
2219
name = "About"
2320
url = "/about/"
2421
weight = 2
25-
[[menu.main]]
26-
name = "Categories"
27-
url = "/categories/"
28-
weight = 3
29-
[[menu.main]]
30-
name = "Tags"
31-
url = "/tags/"
32-
weight = 4
3322
[[menu.main]]
3423
name = "Subscribe"
3524
url = "/index.xml"

content/post/2015-07-23-lorem-ipsum.md

-21
This file was deleted.

content/post/2015-07-23-lorem-ipsum2.md

-21
This file was deleted.

content/post/2015-07-23-lorem-ipsum3.md

-21
This file was deleted.

content/post/2015-07-23-lorem-ipsum4.md

-21
This file was deleted.

content/post/2015-07-23-lorem-ipsum5.md

-21
This file was deleted.

0 commit comments

Comments
 (0)