Lot of improvements

This commit is contained in:
nico202 2018-06-08 23:44:49 +02:00
parent 12866bc20e
commit bb4a38f975
5 changed files with 9 additions and 3 deletions

View File

@ -16,5 +16,6 @@ include("globals.jl")
include("configs.jl")
include("zotero.jl")
include("bibliography.jl")
include("interactions.jl")
end # module

View File

@ -10,7 +10,6 @@ Defines `pre_add_to_bib` and `after_add_to_bib`.
"""
function addtobibliography!(bibliography::Bibliography, id::String, entry::Citation)
@hook :pre_add_to_bib
info("Here")
exists = id in keys(bibliography)
info("The id you are adding $(id) does " * (exists ? "" : "not ") * "exists")
if exists
@ -24,7 +23,7 @@ function addtobibliography!(bibliography::Bibliography, id::String, entry::Citat
differencepercent = compare(TokenMax(RatcliffObershelp()), old, new)
if differencepercent > 0.8
@hook :duplicated_paper
warn("The old and the new seems to be the same paper\n
warn("The old and the new seems to be the same paper
(similarity is $(differencepercent))")
@show json(oldentry)
@show json(entry)

View File

@ -53,6 +53,7 @@ function rmhook!(s::Symbol)
end
function setlibraries!(l::Dict)
empty!(libraries)
merge!(libraries,l)
end

5
src/interactions.jl Normal file
View File

@ -0,0 +1,5 @@
function byyear(year::Int)
global bibliography
[ bibliography[o] for o in keys(bibliography) if ismatch(Regex(string(1999)),
bibliography[o]["year"])]
end

View File

@ -203,7 +203,7 @@ function saveitems(req::Dict, libraries, currentlibrary)
foreach(i -> addtobibliography!(bibliography, i...),
parseitem.(parsed["items"]))
@hook :after_receive
@hook(:after_receive,parsed)
"ok", Dict{String,String}("status"=> string(201))
end