bibsonomy 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bibsonomy/api.rb +25 -31
- data/lib/bibsonomy/csl.rb +47 -51
- data/lib/bibsonomy/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8d9d23c1914cd4715fa7c9642e3b116c98d7b4b
|
4
|
+
data.tar.gz: 880c61defc6356d790ac26c65538d9bb084c57a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a86ad6a98c4f48621c6baca09b8159707540c474fa55c21f2b10e047e1d50e623ef4825623b022aba748058e16dd6998f413a6d4baa9d27d50ce88c7c62a1898
|
7
|
+
data.tar.gz: f74e7b55616b18ed0db1602b58e0ae85cb31094780fa52ca170c144ded2af7bd079599cbe6df8873d8a3d6406cad2795138edec54a4a5b83be3ea3fb0b2feff6
|
data/lib/bibsonomy/api.rb
CHANGED
@@ -2,11 +2,6 @@
|
|
2
2
|
require 'faraday'
|
3
3
|
require 'json'
|
4
4
|
|
5
|
-
#
|
6
|
-
# TODO:
|
7
|
-
# - error handling
|
8
|
-
# - getting more than 1000 posts
|
9
|
-
#
|
10
5
|
|
11
6
|
# configuration options
|
12
7
|
$API_URL = "https://www.bibsonomy.org/"
|
@@ -21,17 +16,18 @@ $resource_types_bibtex = ['bibtex', 'pub', 'publication', 'publications', 'publ'
|
|
21
16
|
#
|
22
17
|
# The BibSonomy REST client for Ruby.
|
23
18
|
#
|
19
|
+
# @todo error handling
|
20
|
+
# @todo getting more than 1000 posts
|
21
|
+
#
|
22
|
+
# @author Robert Jäschke
|
23
|
+
#
|
24
24
|
module BibSonomy
|
25
25
|
class API
|
26
26
|
|
27
27
|
# Initializes the client with the given credentials.
|
28
28
|
#
|
29
|
-
# @param user_name [String]
|
30
|
-
#
|
31
|
-
#
|
32
|
-
# @param api_key [String] The API key corresponding to the user
|
33
|
-
# account - can be obtained from
|
34
|
-
# http://www.bibsonomy.org/settings?selTab=1
|
29
|
+
# @param user_name [String] the name of the user account used for accessing the API
|
30
|
+
# @param api_key [String] the API key corresponding to the user account - can be obtained from http://www.bibsonomy.org/settings?selTab=1
|
35
31
|
#
|
36
32
|
# @param format [String] The requested return format. One of:
|
37
33
|
# 'xml', 'json', 'ruby', 'csl', 'bibtex'. The default is 'ruby'
|
@@ -64,11 +60,9 @@ module BibSonomy
|
|
64
60
|
#
|
65
61
|
# Get a single post
|
66
62
|
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
# +return+:: [BibSonomy::Post] the requested post
|
71
|
-
#
|
63
|
+
# @param user_name [String] the name of the post's owner
|
64
|
+
# @param intra_hash [String] the intrag hash of the post
|
65
|
+
# @return [BibSonomy::Post, String] the requested post
|
72
66
|
def get_post(user_name, intra_hash)
|
73
67
|
response = @conn.get "/api/users/" + CGI.escape(user_name) + "/posts/" + CGI.escape(intra_hash), { :format => @format }
|
74
68
|
|
@@ -82,12 +76,12 @@ module BibSonomy
|
|
82
76
|
#
|
83
77
|
# Get posts owned by a user, optionally filtered by tags.
|
84
78
|
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
79
|
+
# @param user_name [String] the name of the posts' owner
|
80
|
+
# @param resource_type [String] the type of the post. Currently supported are 'bookmark' and 'publication'.
|
81
|
+
# @param tags [Array<String>] the tags that all posts must contain (can be empty)
|
82
|
+
# @param start [Integer] number of first post to download
|
83
|
+
# @param endc [Integer] number of last post to download
|
84
|
+
# @return [Array<BibSonomy::Post>, String] the requested posts
|
91
85
|
def get_posts_for_user(user_name, resource_type, tags = nil, start = 0, endc = $MAX_POSTS_PER_REQUEST)
|
92
86
|
params = {
|
93
87
|
:format => @format,
|
@@ -115,10 +109,10 @@ module BibSonomy
|
|
115
109
|
#
|
116
110
|
# Get a document belonging to a post.
|
117
111
|
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
#
|
112
|
+
# @param user_name
|
113
|
+
# @param intra_hash
|
114
|
+
# @param file_name
|
115
|
+
# @return the document and the content type
|
122
116
|
def get_document(user_name, intra_hash, file_name)
|
123
117
|
response = @conn.get get_document_href(user_name, intra_hash, file_name)
|
124
118
|
if response.status == 200
|
@@ -130,11 +124,11 @@ module BibSonomy
|
|
130
124
|
#
|
131
125
|
# Get the preview for a document belonging to a post.
|
132
126
|
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
127
|
+
# @param user_name
|
128
|
+
# @param intra_hash
|
129
|
+
# @param file_name
|
130
|
+
# @param size
|
131
|
+
# @return the preview image and the content type `image/jpeg`
|
138
132
|
def get_document_preview(user_name, intra_hash, file_name, size)
|
139
133
|
response = get_document_href(user_name, intra_hash, file_name), { :preview => size }
|
140
134
|
if response.status = 200
|
data/lib/bibsonomy/csl.rb
CHANGED
@@ -23,64 +23,56 @@ require 'bibsonomy'
|
|
23
23
|
# 2015-02-24
|
24
24
|
# - initial version
|
25
25
|
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
26
|
+
# @todo escape data
|
27
|
+
# @todo make sorting, etc. configurable
|
28
|
+
# @todo automatically rename files (TODO: CSL lacks BibTeX key)
|
29
|
+
# @todo add intra_hash, user_name, etc. to CSL (cf. https://bitbucket.org/bibsonomy/bibsonomy/issue/2411/)
|
30
|
+
# @todo integrate AJAX abstract
|
31
|
+
# @todo make all options available via command line
|
32
|
+
#
|
33
|
+
# @author Robert Jäschke
|
33
34
|
|
34
35
|
module BibSonomy
|
35
36
|
class CSL
|
36
|
-
|
37
|
-
# :
|
38
|
-
|
39
|
-
|
40
|
-
##
|
41
|
-
# :attr_accessor: style
|
42
|
-
# The CSL[http://citationstyles.org/] style used for rendering. (default: +apa.csl+)
|
43
|
-
|
44
|
-
##
|
45
|
-
# :attr_accessor: year_headings
|
46
|
-
# A boolean indicating whether year headings shall be rendered. (default: enabled)
|
37
|
+
|
38
|
+
# @return [String] the output directory for downloaded PDF files. If set to `nil`, no documents are downloaded. (default: `nil`)
|
39
|
+
attr_accessor :pdf_dir
|
47
40
|
|
48
|
-
|
49
|
-
|
50
|
-
# The CSS class used to render the surrounding +<ul>+ list (default: 'publications')
|
41
|
+
# @return [String] the {http://citationstyles.org/ CSL} style used for rendering. (default: `apa.csl`)
|
42
|
+
attr_accessor :style
|
51
43
|
|
52
|
-
|
53
|
-
|
54
|
-
# A boolean indicating whether links for DOIs shall be rendered. (default: true)
|
44
|
+
# @return [Boolean] whether year headings shall be rendered. (default: `true`)
|
45
|
+
attr_accessor :year_headings
|
55
46
|
|
56
|
-
|
57
|
-
|
58
|
-
# A boolean indicating whether URLs of posts shall be rendered. (default: true)
|
47
|
+
# @return [String] the CSS class used to render the surrounding `<ul>` list (default: 'publications')
|
48
|
+
attr_accessor :css_class
|
59
49
|
|
60
|
-
|
61
|
-
|
62
|
-
# A boolean indicating whether links to the BibTeX data of a post (in BibSonomy) shall be rendered. (default: true)
|
50
|
+
# @return [Boolean] whether links for DOIs shall be rendered. (default: `true`)
|
51
|
+
attr_accessor :doi_link
|
63
52
|
|
64
|
-
|
65
|
-
|
66
|
-
# A boolean indicating whether links BibSonomy shall be rendered. (default: true)
|
53
|
+
# @return [Boolean] whether URLs of posts shall be rendered. (default: `true`)
|
54
|
+
attr_accessor :url_link
|
67
55
|
|
68
|
-
|
69
|
-
|
70
|
-
# The separator between options. (default: ' | ')
|
56
|
+
# @return [Boolean] whether links to the BibTeX data of a post (in BibSonomy) shall be rendered. (default: `true`)
|
57
|
+
attr_accessor :bibtex_link
|
71
58
|
|
72
|
-
|
73
|
-
|
74
|
-
# When a post has several documents and the filename of one of them ends with +public_doc_postfix+, only this document is downloaded and linked, all other are ignored. (default: '_oa.pdf')
|
59
|
+
# @return [Boolean] whether links to BibSonomy shall be rendered. (default: `true`)
|
60
|
+
attr_accessor :bibsonomy_link
|
75
61
|
|
76
|
-
#
|
77
|
-
attr_accessor :
|
62
|
+
# @return [String] the separator between options. (default: ' | ')
|
63
|
+
attr_accessor :opt_sep
|
78
64
|
|
65
|
+
# @return [String] When a post has several documents and the
|
66
|
+
# filename of one of them ends with `public_doc_postfix`, only
|
67
|
+
# this document is downloaded and linked, all other are
|
68
|
+
# ignored. (default: '_oa.pdf')
|
69
|
+
attr_accessor :public_doc_postfix
|
70
|
+
|
71
|
+
#
|
72
|
+
# Create a new BibSonomy instance.
|
79
73
|
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
# +user_name+:: BibSonomy user name
|
83
|
-
# +api_key+:: API key of the given user (get at http://www.bibsonomy.org/settings?selTab=1)
|
74
|
+
# @param user_name [String] the BibSonomy user name
|
75
|
+
# @param api_key [String] the API key of the user (get at http://www.bibsonomy.org/settings?selTab=1)
|
84
76
|
def initialize(user_name, api_key)
|
85
77
|
super()
|
86
78
|
@bibsonomy = BibSonomy::API.new(user_name, api_key, 'csl')
|
@@ -100,11 +92,12 @@ module BibSonomy
|
|
100
92
|
end
|
101
93
|
|
102
94
|
#
|
103
|
-
# Download
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
95
|
+
# Download `count` posts for the given `user` and `tag(s)` and render them with {http://citationstyles.org/ CSL}.
|
96
|
+
#
|
97
|
+
# @param user [String] the name of the posts' owner
|
98
|
+
# @param tags [Array<String>] the tags that all posts must contain (can be empty)
|
99
|
+
# @param count [Integer] number of posts to download
|
100
|
+
# @return [String] the rendered posts as HTML
|
108
101
|
def render(user, tags, count)
|
109
102
|
# get posts from BibSonomy
|
110
103
|
posts = JSON.parse(@bibsonomy.get_posts_for_user(user, 'publication', tags, 0, count))
|
@@ -270,7 +263,10 @@ module BibSonomy
|
|
270
263
|
end
|
271
264
|
|
272
265
|
|
273
|
-
#
|
266
|
+
# Parse command line options
|
267
|
+
#
|
268
|
+
# @param args [Array<String>] command line options
|
269
|
+
# @return [String] the rendered posts as HTML
|
274
270
|
def self.main(args)
|
275
271
|
|
276
272
|
# setting default options
|
data/lib/bibsonomy/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bibsonomy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Jäschke
|
@@ -197,3 +197,4 @@ summary: Wraps the BibSonomy REST API.
|
|
197
197
|
test_files:
|
198
198
|
- test/post_test.rb
|
199
199
|
- test/test_helper.rb
|
200
|
+
has_rdoc:
|