Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional PDF link prefix #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/bibsonomy/csl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
# - number of posts
# - style
# - directory
# - pdf_link_prefix
# - group
# - altmetric
#
# Changes:
# 2018-10-13
# - added pdf_link_prefix
# 2018-08-09 (rja)
# - shortened DOI URL
# 2017-07-05 (rja)
Expand Down Expand Up @@ -51,6 +54,9 @@ class CSL
# @return [String] the output directory for downloaded PDF files. If set to `nil`, no documents are downloaded. (default: `nil`)
attr_accessor :pdf_dir

# @return [String] prefix of link to downloaded PDFs. E.g., to prepend a slash (default: ``)
attr_accessor :pdf_link_prefix

# @return [String] the {http://citationstyles.org/ CSL} style used for rendering. (default: `apa.csl`)
attr_accessor :style

Expand Down Expand Up @@ -98,6 +104,7 @@ def initialize(user_name, api_key)
# setting some defaults
@style = 'apa.csl'
@pdf_dir = nil
@pdf_link_prefix = ''
@css_class = 'publications'
@year_headings = true
@public_doc_postfix = '_oa.pdf'
Expand Down Expand Up @@ -182,7 +189,7 @@ def render(grouping, name, tags, count)
for doc in get_public_docs(post["documents"])
# fileHash, fileName, md5hash, userName
file_path = get_document(@bibsonomy, intra_hash, user_name, doc, @pdf_dir, file_names)
options << "<a href='#{file_path}'>PDF</a>"
options << "<a href='#{@pdf_link_prefix}#{file_path}'>PDF</a>"
end
end
# attach DOI
Expand Down Expand Up @@ -335,6 +342,7 @@ def get_intra_hash(post_id)
# @return [String] the rendered posts as HTML
def self.main(args)

# TODO add "pdf_link_prefix" below
# setting default options
options = OpenStruct.new
options.documents = false
Expand Down
2 changes: 1 addition & 1 deletion lib/bibsonomy/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module BibSonomy
VERSION = "0.4.16"
VERSION = "0.4.17"
end