From bb4a38f9754e0d8edce5e789d6f706deadde71ab Mon Sep 17 00:00:00 2001 From: nico202 Date: Fri, 8 Jun 2018 23:44:49 +0200 Subject: [PATCH] Lot of improvements --- src/Scjrm.jl | 1 + src/bibliography.jl | 3 +-- src/default.jl | 1 + src/interactions.jl | 5 +++++ src/zotero.jl | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/interactions.jl diff --git a/src/Scjrm.jl b/src/Scjrm.jl index 450fc1a..a76da97 100644 --- a/src/Scjrm.jl +++ b/src/Scjrm.jl @@ -16,5 +16,6 @@ include("globals.jl") include("configs.jl") include("zotero.jl") include("bibliography.jl") +include("interactions.jl") end # module diff --git a/src/bibliography.jl b/src/bibliography.jl index 9908254..88999dc 100644 --- a/src/bibliography.jl +++ b/src/bibliography.jl @@ -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) diff --git a/src/default.jl b/src/default.jl index 3b492a7..9da9d7e 100644 --- a/src/default.jl +++ b/src/default.jl @@ -53,6 +53,7 @@ function rmhook!(s::Symbol) end function setlibraries!(l::Dict) + empty!(libraries) merge!(libraries,l) end diff --git a/src/interactions.jl b/src/interactions.jl new file mode 100644 index 0000000..179bf6f --- /dev/null +++ b/src/interactions.jl @@ -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 diff --git a/src/zotero.jl b/src/zotero.jl index 2c314ca..a533f22 100644 --- a/src/zotero.jl +++ b/src/zotero.jl @@ -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