Module: BibSonomy
- Defined in:
- lib/bibsonomy/api.rb,
lib/bibsonomy.rb,
lib/bibsonomy/csl.rb,
lib/bibsonomy/post.rb,
lib/bibsonomy/version.rb
Overview
TODO:
escape data
TODO:
make sorting, etc. configurable
TODO:
automatically rename files (TODO: CSL lacks BibTeX key)
TODO:
add intra_hash, user_name, etc. to CSL (cf. bitbucket.org/bibsonomy/bibsonomy/issue/2411/)
TODO:
integrate AJAX abstract
TODO:
make all options available via command line
TODO:
support filtering of posts by group (viewability)
Generates a list of publication posts from BibSonomy
required parameters:
-
user name
-
api key
optional parameters:
-
user name
-
tags
-
number of posts
-
style
-
directory
-
group
Changes: 2017-01-19
-
added optional parameter group to control which posts are included based on their viewability for a specific group (not yet activated!)
2015-02-24
-
initial version
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.4.7"
Class Method Summary collapse
-
.main(args) ⇒ String
Parse command line options.
Class Method Details
.main(args) ⇒ String
Parse command line options
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/bibsonomy/csl.rb', line 301 def self.main(args) # setting default options = OpenStruct.new .documents = false .directory = nil . = [] .style = "apa.csl" .group = "public" .posts = 1000 opt_parser = OptionParser.new do |opts| opts. = "Usage: csl.rb [options] user_name api_key" opts.separator "" opts.separator "Specific options:" # mandatory arguments are handled separately # optional arguments opts.on('-u', '--user USER', 'return posts for USER instead of user') { |v| [:user] = v } opts.on('-t', '--tags TAG,TAG,...', Array, 'return posts with the given tags') { |v| [:tags] = v } opts.on('-s', '--style STYLE', 'use CSL style STYLE for rendering') { |v| [:style] = v } opts.on('-g', '--group GROUP', 'include only posts viewable for GROUP') { |v| [:group] = v } opts.on('-n', '--number-of-posts [COUNT]', Integer, 'number of posts to download') { |v| [:posts] = v } opts.on('-d', '--directory DIR', 'target directory', ' (if not given, no documents are downloaed)') { |v| [:directory] = v } opts.separator "" opts.separator "Common options:" opts.on('-h', '--help', 'show this help message and exit') do puts opts exit end opts.on_tail('-v', "--version", "show version") do puts BibSonomy::VERSION exit end end opt_parser.parse!(args) # handle mandatory arguments begin mandatory = [:user_name, :api_key] missing = [] [:api_key] = args.pop missing << :api_key unless [:api_key] [:user_name] = args.pop missing << :user_name unless [:user_name] if not missing.empty? puts "Missing options: #{missing.join(', ')}" puts opt_parser exit end rescue OptionParser::InvalidOption, OptionParser::MissingArgument puts $!.to_s puts opt_parser exit end # set defaults for optional arguments [:user] = [:user_name] unless [:user] # # do the actual work # csl = BibSonomy::CSL.new([:user_name], [:api_key]) csl.pdf_dir = [:directory] csl.style = [:style] csl.group = [:group] html = csl.render([:user], [:tags], [:posts]) return html end |