bibsonomy 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3670b5540353a413ad5fa4782a7cb52a629f2ddb
4
- data.tar.gz: 8b6e6dc6aad993117d7856ec3dd16158c70c6533
3
+ metadata.gz: 9e90577cd917b74e5f0db75296b9ea9e53bca4ca
4
+ data.tar.gz: 00d3ca6fe7d1cc3b628f1e4fe56a8230aa445021
5
5
  SHA512:
6
- metadata.gz: eab5129c8b67a500dc4fc8b891fe802cf4145c9fb5b9ecbb6005f185be97e5d41897f1fa4453aacab61f4f4e1be18a9c8fc1404644592ac99dcd5f81b103fae4
7
- data.tar.gz: 40cadee5af345d6057f7d36065a1c4997cf7272a4ae730280815de03f4d9b0fad3775c470d841666a74b55c4b20ba547e051c38cb570cda9118862f611ad186c
6
+ metadata.gz: 4156a1444092b27d3e1ba14046eefd585ee66b16b992324364c8b49c99ffb3e7f511273989a94c9e100ad10959f792af40ae397d275d68feefac279255515772
7
+ data.tar.gz: e7142bbfc9134a812419b844a4a5cff7edd7321ed6320f13c64724a36179f03d510f6bed4611f88b92cd93f3af26d01b4f0488c785952e73ff97f7564de333d2
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  BibSonomy client for Ruby
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/bibsonomy.svg)](http://badge.fury.io/rb/bibsonomy)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -64,7 +66,7 @@ module Jekyll
64
66
  @tag = parts[1]
65
67
  @count = Integer(parts[2])
66
68
  end
67
-
69
+
68
70
  def render(context)
69
71
  site = context.registers[:site]
70
72
 
@@ -76,7 +78,7 @@ module Jekyll
76
78
  # target directory for PDF documents
77
79
  pdf_dir = site.config['bibsonomy_document_directory']
78
80
  csl.pdf_dir = pdf_dir
79
-
81
+
80
82
  # CSL style for rendering
81
83
  style = site.config['bibsonomy_style']
82
84
  csl.style = style
@@ -85,7 +87,7 @@ module Jekyll
85
87
 
86
88
  # set date to now
87
89
  context.registers[:page]["date"] = Time.new
88
-
90
+
89
91
  return html
90
92
  end
91
93
  end
@@ -97,13 +99,13 @@ Liquid::Template.register_tag('bibsonomy', Jekyll::BibSonomyPostList)
97
99
 
98
100
  The plugin can be used inside Markdown files as follows:
99
101
 
100
- ```
102
+ ```Liquid
101
103
  {% bibsonomy jaeschke myown 100 %}
102
104
  ```
103
105
 
104
106
  Add the following options to your `_config.yml`:
105
107
 
106
- ```
108
+ ```YAML
107
109
  bibsonomy_user: yourusername
108
110
  bibsonomy_apikey: yourapikey
109
111
  bibsonomy_document_directory: pdf
@@ -111,6 +113,8 @@ bibsonomy_document_directory: pdf
111
113
  bibsonomy_style: springer-lecture-notes-in-computer-science
112
114
  ```
113
115
 
116
+ For an example, have a look at [my publication list](http://www.kbs.uni-hannover.de/~jaeschke/publications.html).
117
+
114
118
 
115
119
  ## Contributing
116
120
 
data/bibsonomy.gemspec CHANGED
@@ -28,6 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "json", "~> 1.8"
29
29
  spec.add_dependency "citeproc", "~> 1.0"
30
30
  spec.add_dependency "csl-styles", "~> 1.0"
31
- spec.add_dependency "bibtex-ruby", "~> 4.0"
32
31
 
33
32
  end
data/lib/bibsonomy/api.rb CHANGED
@@ -64,9 +64,10 @@ module BibSonomy
64
64
  #
65
65
  # Get a single post
66
66
  #
67
- # @param user_name [String] The name of the post's owner.
68
- # @param intra_hash [String] The intrag hash of the post.
69
- # @return [BibSonomy::Post] the requested post
67
+ # Params:
68
+ # +user_name+:: [String] The name of the post's owner.
69
+ # +intra_hash+:: [String] The intrag hash of the post.
70
+ # +return+:: [BibSonomy::Post] the requested post
70
71
  #
71
72
  def get_post(user_name, intra_hash)
72
73
  response = @conn.get "/api/users/" + CGI.escape(user_name) + "/posts/" + CGI.escape(intra_hash), { :format => @format }
@@ -81,10 +82,12 @@ module BibSonomy
81
82
  #
82
83
  # Get posts owned by a user, optionally filtered by tags.
83
84
  #
84
- # @param user_name [String] The name of the posts' owner.
85
- # @resource_type [String] The type of the post. Currently
86
- # supported are 'bookmark' and 'publication'.
87
- #
85
+ # Params:
86
+ # +user_name+:: [String] The name of the posts' owner.
87
+ # +resource_type+:: [String] The type of the post. Currently supported are 'bookmark' and 'publication'.
88
+ # +tags+::
89
+ # +start+::
90
+ # +endc+::
88
91
  def get_posts_for_user(user_name, resource_type, tags = nil, start = 0, endc = $MAX_POSTS_PER_REQUEST)
89
92
  params = {
90
93
  :format => @format,
@@ -110,8 +113,12 @@ module BibSonomy
110
113
  end
111
114
 
112
115
  #
113
- # get a document belonging to a post
116
+ # Get a document belonging to a post.
114
117
  #
118
+ # Params:
119
+ # +user_name+::
120
+ # +intra_hash+::
121
+ # +file_name+::
115
122
  def get_document(user_name, intra_hash, file_name)
116
123
  response = @conn.get get_document_href(user_name, intra_hash, file_name)
117
124
  if response.status == 200
@@ -120,6 +127,14 @@ module BibSonomy
120
127
  return nil, nil
121
128
  end
122
129
 
130
+ #
131
+ # Get the preview for a document belonging to a post.
132
+ #
133
+ # Params:
134
+ # +user_name+::
135
+ # +intra_hash+::
136
+ # +file_name+::
137
+ # +size+::
123
138
  def get_document_preview(user_name, intra_hash, file_name, size)
124
139
  response = get_document_href(user_name, intra_hash, file_name), { :preview => size }
125
140
  if response.status = 200
@@ -128,12 +143,14 @@ module BibSonomy
128
143
  return nil, nil
129
144
  end
130
145
 
146
+
147
+
148
+ private
149
+
131
150
  #
132
151
  # Convenience method to allow sloppy specification of the resource
133
152
  # type.
134
153
  #
135
- # @private
136
- #
137
154
  def get_resource_type(resource_type)
138
155
  if $resource_types_bookmark.include? resource_type.downcase()
139
156
  return "bookmark"
data/lib/bibsonomy/csl.rb CHANGED
@@ -3,7 +3,6 @@
3
3
  require 'optparse'
4
4
  require 'citeproc'
5
5
  require 'csl/styles'
6
- require 'bibtex'
7
6
  require 'json'
8
7
  require 'bibsonomy'
9
8
 
@@ -27,14 +26,55 @@ require 'bibsonomy'
27
26
  # TODO:
28
27
  # - escape data
29
28
  # - make sorting, etc. configurable
30
- # - add link to BibSonomy
31
29
  # - automatically rename files (TODO: CSL lacks BibTeX key)
32
- # - add intra_hash, user_name, DOI to CSL
30
+ # - add intra_hash, user_name, etc. to CSL (cf. https://bitbucket.org/bibsonomy/bibsonomy/issue/2411/)
33
31
  # - integrate AJAX abstract
34
32
  # - make all options available via command line
35
33
 
36
34
  module BibSonomy
37
35
  class CSL
36
+ ##
37
+ # :attr_accessor: pdf_dir
38
+ # The output directory for downloaded PDF files. If set to +nil+, no documents are downloaded. (default: +nil+)
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)
47
+
48
+ ##
49
+ # :attr_accessor: css_class
50
+ # The CSS class used to render the surrounding +<ul>+ list (default: 'publications')
51
+
52
+ ##
53
+ # :attr_accessor: doi_link
54
+ # A boolean indicating whether links for DOIs shall be rendered. (default: true)
55
+
56
+ ##
57
+ # :attr_accessor: url_link
58
+ # A boolean indicating whether URLs of posts shall be rendered. (default: true)
59
+
60
+ ##
61
+ # :attr_accessor: bibtex_link
62
+ # A boolean indicating whether links to the BibTeX data of a post (in BibSonomy) shall be rendered. (default: true)
63
+
64
+ ##
65
+ # :attr_accessor: bibsonomy_link
66
+ # A boolean indicating whether links BibSonomy shall be rendered. (default: true)
67
+
68
+ ##
69
+ # :attr_accessor: opt_sep
70
+ # The separator between options. (default: ' | ')
71
+
72
+ ##
73
+ # :attr_accessor: public_doc_postfix
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')
75
+
76
+ # publicly accessible attributes
77
+ attr_accessor :style, :pdf_dir, :css_class, :year_headings, :public_doc_postfix, :doi_link, :url_link, :bibtex_link, :bibsonomy_link, :opt_sep
38
78
 
39
79
  #
40
80
  # Create a new BibSonomy instance
@@ -89,7 +129,7 @@ module BibSonomy
89
129
  result += "<h3>" + last_year + "</h3>"
90
130
  end
91
131
 
92
- result += "<ul class='#{@publications}'>\n"
132
+ result += "<ul class='#{@css_class}'>\n"
93
133
  for post_id in sorted_keys
94
134
  post = posts[post_id]
95
135
 
@@ -98,7 +138,7 @@ module BibSonomy
98
138
  year = get_year(post)
99
139
  if year != last_year
100
140
  last_year = year
101
- result += "</ul>\n<h3>" + last_year + "</h3>\n<ul class='#{@publications}'>\n"
141
+ result += "</ul>\n<h3>" + last_year + "</h3>\n<ul class='#{@css_class}'>\n"
102
142
  end
103
143
  end
104
144
 
@@ -142,13 +182,19 @@ module BibSonomy
142
182
  if options.length > 0
143
183
  result += " <span class='opt'>[" + options.join(@opt_sep) + "]</span>"
144
184
  end
145
-
185
+
146
186
  result += "</li>\n"
147
187
  end
148
188
  result += "</ul>\n"
149
189
 
150
190
  return result
151
191
  end
192
+
193
+
194
+ #
195
+ # private methods follow
196
+ #
197
+ private
152
198
 
153
199
  def get_year(post)
154
200
  return post["issued"]["literal"]
@@ -167,7 +213,7 @@ module BibSonomy
167
213
  end
168
214
 
169
215
  #
170
- # only show PDF files and if
216
+ # only show PDF files
171
217
  #
172
218
  def get_public_docs(documents)
173
219
  result = []
@@ -221,93 +267,6 @@ module BibSonomy
221
267
  return [post_id[0, 32], post_id[32, post_id.length]]
222
268
  end
223
269
 
224
- #
225
- # setters
226
- #
227
-
228
- #
229
- # Set the output directory for downloaded PDF files (default: +nil+)
230
- # Params:
231
- # +pdf_dir+:: directory for downloaded PDF files. If set to +nil+, no documents are downloaded.
232
- def pdf_dir=(pdf_dir)
233
- @pdf_dir = pdf_dir
234
- end
235
-
236
- #
237
- # Set the CSL style used for rendering (default: +apa.csl+)
238
- # Params:
239
- # +style+:: CSL style used for rendering
240
- def style=(style)
241
- @style = style
242
- end
243
-
244
- #
245
- # Enable/disable headings for years (default: enabled)
246
- # Params:
247
- # +year_headings+:: boolean indicating whether year headings shall be rendered
248
- def year_headings=(year_headings)
249
- @year_headings = year_headings
250
- end
251
-
252
- #
253
- # The CSS class used to render the surrounding +<ul>+ list (default: 'publications')
254
- # Params:
255
- # +css_class+:: string indicating the CSS class for rendering the publication list
256
- def css_class=(css_class)
257
- @css_class = css_class
258
- end
259
-
260
- #
261
- # Shall links for DOIs be rendered? (default: true)
262
- # Params:
263
- # +doi_link+:: render DOI link
264
- def doi_link=(doi_link)
265
- @doi_link = doi_link
266
- end
267
-
268
- #
269
- # Shall links for URLs of posts be rendered? (default: true)
270
- # Params:
271
- # +url_link+:: render URL link
272
- def url_link=(url_link)
273
- @url_link = url_link
274
- end
275
-
276
- #
277
- # Shall links to the BibTeX of a post (in BibSonomy) be rendered? (default: true)
278
- # Params:
279
- # +bibtex_link+:: render BibTeX link
280
- def bibtex_link=(bibtex_link)
281
- @bibtex_link = bibtex_link
282
- end
283
-
284
- #
285
- # Shall links to BibSonomy be rendered? (default: true)
286
- # Params:
287
- # +bibsonomy_link+:: render BibSonomy link
288
- def bibsonomy_link=(bibsonomy_link)
289
- @bibsonomy_link = bibsonomy_link
290
- end
291
-
292
- #
293
- # Separator between options (default: ' | ')
294
- # Params:
295
- # +opt_sep+:: option separator
296
- def opt_sep=(opt_sep)
297
- @opt_sep = opt_sep
298
- end
299
-
300
- #
301
- # When a post has several documents and the filename of one of
302
- # them ends with +public_doc_postfix+, only this document is
303
- # downloaded and linked, all other are ignored. (default:
304
- # '_oa.pdf')
305
- # Params:
306
- # +public_doc_postfix+:: postfix to check at document filenames
307
- def public_doc_postfix=(public_doc_postfix)
308
- @public_doc_postfix = public_doc_postfix
309
- end
310
-
311
270
  end
312
271
 
313
272
 
@@ -383,8 +342,8 @@ module BibSonomy
383
342
  # do the actual work
384
343
  #
385
344
  csl = BibSonomy::CSL.new(options[:user_name], options[:api_key])
386
- csl.pdf_dir(options[:directory])
387
- csl.style(options[:style])
345
+ csl.pdf_dir = options[:directory]
346
+ csl.style = options[:style]
388
347
 
389
348
  html = csl.render(options[:user], options[:tags], options[:posts])
390
349
 
@@ -16,6 +16,6 @@ module BibSonomy
16
16
  @journal = publication["journal"]
17
17
  @url = publication["url"]
18
18
  end
19
-
19
+
20
20
  end
21
21
  end
@@ -1,3 +1,3 @@
1
1
  module BibSonomy
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
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.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Jäschke
@@ -136,20 +136,6 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.0'
139
- - !ruby/object:Gem::Dependency
140
- name: bibtex-ruby
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '4.0'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '4.0'
153
139
  description: Enables calls to the BibSonomy REST API with Ruby.
154
140
  email:
155
141
  - jaeschke@l3s.de