scrapbox 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +9 -1
- data/lib/scrapbox/page.rb +10 -2
- data/lib/scrapbox/project.rb +21 -5
- data/lib/scrapbox/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef9ebaeea78e01125db55ac776124c790603f792fe1fb6d9f64aa4806dd4e8e5
|
4
|
+
data.tar.gz: 269cc1b58479fc718add4eee503c74be2e0cb41db73fd84c81465fd6138e5126
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b26723a1de1a00501b36710e2ef70950178f9b9a2048ef89e55d6af42a1dedd33c8621d8d51886c97404ae3c3a7e4ebb18862963c294d3eadee54f468276ae3
|
7
|
+
data.tar.gz: 25a753e0e935e5f501d09c75340b6beef0164eeaf6af54f22e1894f96c38b4edd000c52c4bab2ee09910cbba58f3789d784a291b5c87fa603d4640a38537640b
|
data/Rakefile
CHANGED
data/lib/scrapbox/page.rb
CHANGED
@@ -6,14 +6,22 @@ module Scrapbox
|
|
6
6
|
def initialize(project,title)
|
7
7
|
@project = project
|
8
8
|
@title = title
|
9
|
+
@text = nil
|
10
|
+
@code = nil
|
9
11
|
end
|
10
12
|
|
11
13
|
def text
|
12
|
-
|
14
|
+
unless @text
|
15
|
+
@text = Scrapbox.__getsbdata("#{project.host}/api/pages/#{project.name}/#{URI.encode(title).gsub(/\//,'%2f')}/text")
|
16
|
+
end
|
17
|
+
@text
|
13
18
|
end
|
14
19
|
|
15
20
|
def code(src)
|
16
|
-
|
21
|
+
unless @code
|
22
|
+
@code = Scrapbox.__getsbdata("#{project.host}/api/code/#{project.name}/#{URI.encode(title)}/#{src}")
|
23
|
+
end
|
24
|
+
@code
|
17
25
|
end
|
18
26
|
|
19
27
|
end
|
data/lib/scrapbox/project.rb
CHANGED
@@ -6,14 +6,30 @@ module Scrapbox
|
|
6
6
|
def initialize(name,host='https://scrapbox.io')
|
7
7
|
@name = name
|
8
8
|
@host = host
|
9
|
+
@titles = nil
|
10
|
+
@pages = nil
|
9
11
|
end
|
10
12
|
|
11
|
-
def
|
13
|
+
def titles
|
12
14
|
data = Scrapbox.__getsbdata("#{@host}/api/pages/#{@name}")
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
unless @titles
|
16
|
+
@titles = JSON.parse(data)['pages'].collect { |page|
|
17
|
+
page['title']
|
18
|
+
}
|
19
|
+
end
|
20
|
+
@titles
|
16
21
|
end
|
17
|
-
end
|
18
22
|
|
23
|
+
def pages
|
24
|
+
unless @pages
|
25
|
+
@pages = {}
|
26
|
+
titles.each { |title|
|
27
|
+
page = Scrapbox::Page.new(self,title)
|
28
|
+
@pages[title] = page
|
29
|
+
}
|
30
|
+
end
|
31
|
+
@pages
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
19
35
|
end
|
data/lib/scrapbox/version.rb
CHANGED