Skip to content

Commit

Permalink
Improved version for Mozfest that includes PDF previews
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Kraker committed Nov 5, 2015
1 parent 3e58680 commit 9b5ad83
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 23 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
, "visualization" //append to tag
, [{
title: "dna"
, file: "test_rplos"
, file: "bibliometrics"
}
] //data
, {title: "Overview of dna"
, max_diameter_size: 50
, min_diameter_size: 30
, max_area_size: 110
, min_area_size: 50
, use_area_uri: false
, input_format: "json"
, use_area_uri: true
, base_unit: "views"
, force_areas: true
} //options
)
</script>
Expand Down
5 changes: 3 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
, min_diameter_size: 30
, max_area_size: 110
, min_area_size: 50
, use_area_uri: false
, input_format: "json"
, use_area_uri: true
, input_format: "json"
, base_unit: "views"
, show_timeline: false
, show_dropdown: false
, is_force_areas: true
, preview_type: "pdf"
} //options
)
</script>
Expand Down
15 changes: 9 additions & 6 deletions search_plos.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,30 @@
-->
<html>
<head>
<title>Turn a PLOS search into a visualization</title>
<title>Search PLOS and turn it into a visualization</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<!--<script type="text/javascript" src="vis/lib/jquery-1.8.1.min.js"></script>-->
<script type="text/javascript" src="vis/lib/d3.v3.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js"></script>
<link rel="stylesheet" type="text/css" href="vis/style.css"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" integrity="sha512-dTfge/zgoMYpP7QbHy4gWMEGsbsdZeCXz7irItjcC3sPUFtf0kuFbDz/ixG7ArTxmDjLXDmezHubeNikyKGVyQ==" crossorigin="anonymous">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
</head>
<body>
<body style="padding-left:10px; padding-right:10px;">
<div>
<form id="searchform" action="server/services/searchPLOS.php">
<h2>Search PLOS and turn it into a visualization</h2>
<form id="searchform" action="server/services/searchPLOS.php" style="margin-top:20px">
<label for="q">Search term:</label>
<input type="text" name="q" required><br>
<input type="text" name="q" size="40" required>
<button type="submit" class="btn">Submit</button>
</form>
</div>

<div id="progress"></div>
<div id="progress" style="margin-top: 20px;"></div>

<a href="http://github.com/pkraker/Headstart" target="_blank">Github repo</a>

<script type="text/javascript">
$("#searchform").validate({
Expand Down
5 changes: 3 additions & 2 deletions server/preprocessing/other-scripts/rplos.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ library(jsonlite)
#library(lsa)
#library(stylo)

# Read input files

# Get data from PLOS API
start.time <- Sys.time()

search_data <- searchplos(q=query, fl='title,id,counter_total_month,abstract,journal,publication_date,author,everything,subject',
Expand All @@ -36,6 +35,8 @@ names(cooc)[names(cooc)=="publication_date"] <- "year"
names(cooc)[names(cooc)=="author"] <- "authors"
cooc["url"] = paste("http://dx.doi.org/", cooc$id, sep="")
cooc["titleabstract"] = paste(cooc$title, cooc$abstract, sep=" ")
dates = as.Date(cooc$year)
cooc$year = format(dates, format="%B %d %Y")


metadata = cooc
Expand Down
4 changes: 4 additions & 0 deletions vis/headstart.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ HeadstartFSM = function(host, path, tag, files, options) {
this.circle_zoom = 0;
this.current_circle = null;
this.is_zoomed = false;

this.url_plos_pdf = "http://www.plosone.org/article/fetchObject.action?representation=PDF&uri=info:doi/";

this.subdiscipline_title = initVar(options.title, "");

Expand Down Expand Up @@ -105,6 +107,8 @@ HeadstartFSM = function(host, path, tag, files, options) {
this.use_area_uri = initVar(options.use_area_uri, false);

this.input_format = initVar(options.input_format, "csv");

this.preview_type = initVar(options.preview_type, "images");

// contains bubbles objects for the timline view
// elements get added to bubbles by calling registerBubbles()
Expand Down
Binary file added vis/images/preview_pdf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 23 additions & 11 deletions vis/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,24 +510,36 @@ list.loadAndAppendImage = function(image_src, page_number) {

list.populateOverlay = function (d) {

var this_d = d;

popup.paper_frame
.style("display","block")

popup.current = "visible";

list.loadAndAppendImage(headstart.images_path + d.id + "/page_1.png", 1);
if(headstart.preview_type == "image") {
list.loadAndAppendImage(headstart.images_path + d.id + "/page_1.png", 1);

var images_finished = false
, counter = 2;
var images_finished = false
, counter = 2;

while(!images_finished) {
var image_src = headstart.images_path + d.id + "/page_" + counter + ".png";
if (!list.loadAndAppendImage(image_src, counter)) {
images_finished = true;
}
while(!images_finished) {
var image_src = headstart.images_path + d.id + "/page_" + counter + ".png";

if (!list.loadAndAppendImage(image_src, counter)) {
images_finished = true;
}

counter++;
counter++;
}
} else if (headstart.preview_type == "pdf") {
popup.paper_frame.select("#preview")
.append("iframe")
.attr("width", 781 - 4)
.attr("height", 460 - 75)
.attr("src", function() {
return headstart.url_plos_pdf + this_d.id
})
}
}

Expand All @@ -538,7 +550,7 @@ list.setImageForListHolder = function(d) {
return (x.id == d.id)
});

var image_src = headstart.images_path + d.id + "/page_1.png";
var image_src = (headstart.preview_type=="image")?(headstart.images_path + d.id + "/page_1.png"):(headstart.images_path + "/preview_pdf.png");

if (this.testImage(image_src)) {

Expand Down
1 change: 1 addition & 0 deletions vis/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ div#preview {
background-color: #EEE;
padding-top: 5px;
padding-bottom: 5px;
overflow: auto;
}

table#legend_table {
Expand Down

0 comments on commit 9b5ad83

Please sign in to comment.