-
Notifications
You must be signed in to change notification settings - Fork 1
/
toHATENA.R
45 lines (38 loc) · 1.9 KB
/
toHATENA.R
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
toHATENA <- function(trg, localDBP="D:/My Dropbox/Public", pubDBP="http://dl.dropbox.com/u/956851"){
#make googlegadget and save to Dropbox
require(RCurl)
require(RHTMLForms)
require(RJSONIO)
XMLname <- paste(sep="", unlist(strsplit(split="\\.", trg))[1], ".xml")
url <- paste(sep="", "http://api.zoom.it/v1/content/?url=", paste(sep="/", pubDBP, trg))
resAPI <- fromJSON(getURL(url))
res <- sprintf('<Module><ModulePrefs title=""></ModulePrefs><Content type="html"><![CDATA[%s]]></Content></Module>', resAPI$embedHtml)
address <- paste(sep="/", localDBP, XMLname)
write(res, address)
#upload the XML as googlegadget
forms <- getHTMLFormDescription("http://www.google.com/ig/submit")
fun <- createFunction(forms[[2]])
webDBP <- paste(sep="/", pubDBP, XMLname)
fun(url = webDBP)
#hatena
reshatena <- paste(sep="", '<script src="http://www.gmodules.com/ig/ifr?url=', webDBP, '&synd=open&w=580&h=450&title=&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>')
out <- paste(sep="", unlist(strsplit(split="\\.", trg))[1], "code.txt")
hatenafilename <- paste(sep="/", localDBP, out)
write(reshatena, hatenafilename)
}
toHATENA2 <- function(gvisobj, XMLname, localDBP="D:/My Dropbox/Public", pubDBP="http://dl.dropbox.com/u/956851"){
# for "gvis" class object
require(RHTMLForms)
ggd <- createGoogleGadget(gvisobj)
write(ggd, paste(sep="/", localDBP, XMLname))
#send XML as GoogleGadget
forms <- getHTMLFormDescription("http://www.google.com/ig/submit")
fun <- createFunction(forms[[2]])
webDBP <- paste(sep="/", pubDBP, XMLname)
fun(url = webDBP)
#toHatena
reshatena <- paste(sep="", '<script src="http://www.gmodules.com/ig/ifr?url=', webDBP,'&synd=open&w=580&h=450&title=&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>')
out <- "hatenagggd.txt"
hatenafilename <- paste(sep="/", localDBP, out)
write(reshatena, hatenafilename)
}