forked from publiclab/spectral-workbench
/
spectrum.html.erb
162 lines (129 loc) · 8.89 KB
/
spectrum.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<script src="/javascripts/show.js"> </script>
<script src="/javascripts/analyze.js"> </script>
<%= render :partial => "clone" %>
<%= render :partial => "calibrate" %>
<%= render :partial => "select_row" %>
<%= render :partial => "compare" %>
<div class="container-fluid" style="clear:both;">
<% if logged_in? && @spectrum.author == current_user.login && !@spectrum.calibrated %>
<div class="alert alert-warning"><button type="button" class="close" data-dismiss="alert">×</button>
This spectrum is not yet calibrated. <a class="btn btn-primary btn-small" data-toggle="modal" href="#calibratemodal1">Calibrate</a>
<a class="btn btn-small" href="http://publiclaboratory.org/wiki/spectral-workbench-calibration">Learn more</a>
</div>
<% end %>
<% if mobile? && !@spectrum.calibrated %>
<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>
<i class="icon icon-exclamation-sign"></i> Calibration is easiest <b>from a computer</b>, after which you can use it from your phone.
</div>
<% end %>
<div class="row-fluid" id="display">
<img style="width:95%;height:100px;padding:0 1% 0 4%;background:black;" id="image" src="<%= @spectrum.photo.url(:original) %>" />
<div id="graph" style="width:98%;height:200px;"></div>
<div class="navbar navbar-inverse navbar-static-bottom" style="margin:0;">
<div class="navbar-inner">
<a data-toggle="modal" href="#calibratemodal1" class="btn btn-primary"><i class="icon icon-white icon-screenshot"></i><span class="hidden-phone"> Calibrate</span></a>
<a href="#embedmodal" class="btn btn-inverse hidden-phone" data-toggle="modal"><i class="icon icon-white icon-share"></i><span class="hidden-phone"> Embed</span></a>
<%= render :partial => "embed" %>
<a class="btn btn-inverse" href="javascript:void(0);" onClick="window.location = '/sets/add/'+prompt('Add to which set? (enter an id)')+'?spectrum_id=<%= @spectrum.id %>'"><i class="icon icon-white icon-plus-sign"></i><span class="hidden-phone"> Add to set</span></a>
<a class="btn btn-inverse hidden-phone" id="createSet" href="javascript:void(0);"><i class="icon icon-white icon-list"></i><span class="hidden-phone"> Save as set</span></a>
<a data-toggle="modal" class="btn btn-inverse" href="#comparemodal"><i class="icon icon-white icon-align-left"></i><span class="hidden-phone"> Compare</span></a>
<a rel="popover" data-placement="left" class="pull-right btn btn-inverse" data-content='<ul class="nav nav-list"><li><a onClick="$W.units()">Toggle units</a></li><li><a onClick="$W.toggle_mode()">Toggle RGB</a></li><li><a onClick="$W.extract()"><i class="icon icon-refresh"></i> Re-extract from photo</a></li><li><a href="#selectrowmodal" data-toggle="modal">Set sample row</a></li><li><a href="/spectra/rotate/<%= @spectrum.id %>">Rotate image</a></li><li><a href="/spectra/find_brightest_row/<%= @spectrum.id %>">Auto-detect brightest spectrum</a></li></ul>'><i class="icon icon-white icon-briefcase"></i><span class="hidden-phone"> More tools</span></a>
<b class="pull-right" style="padding-top:10px;margin-right:10px;"><span id="wavelength"></span> <span id="#unit_label">nm</span></b>
<a style="margin-right:4px;" class="pull-right hidden-desktop btn btn-inverse"><i class="icon icon-white icon-search"></i></a></span>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span3">
<h3 style="margin-bottom:0px;"><%= @spectrum.title %></h3>
<p>uploaded by <a href="/profile/<%= @spectrum.author %>"><%= @spectrum.author %></a></p>
<% if @spectrum.lat != 0 && @spectrum.lon != 0 %><p>Collected at: Lat: <%= @spectrum.lat %>, Lon: <%= @spectrum.lon %> (<a href="http://www.openstreetmap.org/?lat=<%= @spectrum.lat %>&lon=<%= @spectrum.lon %>&zoom=10&layers=M">View in OpenStreetMap</a>)</p><% end %>
<p><b>Tags:</b> <% @spectrum.tags.each do |tag| %><a class="label label-info" href="/tag/<%= tag.name %>"><%= tag.name %></a> <% end %></p>
<form class="form" action="/tag/create">
<input type="hidden" name="tag[spectrum_id]" value="<%= @spectrum.id %>" />
<div class="input-prepend">
<span class="add-on"><i class="icon-tags"></i></span>
<input name="tag[name]" type="text" class="span10" placeholder="soil, sunlight" data-provide="typeahead" data-source="['calibration','soil','']">
</div>
</form>
<div class="btn-group hidden-phone">
<hr />
<a class="btn btn-small" href="/spectra/show/<%= @spectrum.id %>.json"><b>JSON</b></a>
<a class="btn btn-small" href="/spectra/show/<%= @spectrum.id %>.csv"><b>CSV</b></a>
<a class="btn btn-small" href="/spectra/show/<%= @spectrum.id %>.xml"><b>XML</b></a>
<a rel="tooltip" class="btn btn-small" href="http://publiclaboratory.org/wiki/spectral-workbench-exporting" title="About export formats"><i class="icon icon-question-sign"></i></a>
</div>
<div class="hidden-phone">
<hr />
<p><b>Sample row:</b> <%= @spectrum.sample_row %></p>
<hr />
</div>
<div xmlns:dct="http://purl.org/dc/terms/" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#">
<p><a rel="license" href="http://creativecommons.org/publicdomain/zero/1.0/"><img src="http://i.creativecommons.org/p/zero/1.0/88x31.png" style="border-style: none;" alt="CC0" /></a></p>
<p class="hidden-phone"><small>
To the extent possible under law,
<%# if @spectrum.author.url %><a rel="dct:publisher" href="http://publiclaboratory.org"><%# end %>
<span property="dct:title"><%= @spectrum.author %></span><%# if @spectrum.author.url %></a><%# end %>
has waived all copyright and related or neighboring rights to
"<span property="dct:title"><%= @spectrum.title %></span>".
</small></p>
</div>
</div>
<div class="span9">
<% if logged_in? && current_user.login == @spectrum.author %>
<div class="btn-group pull-right" style="margin-top:10px;">
<a class="btn btn-small" href="/spectrums/<%= @spectrum.id %>/edit"><i class="icon icon-pencil"></i> Edit</a>
<%= link_to '<i class="icon icon-remove-sign"></i> Delete', "/spectrums/destroy/"+@spectrum.id.to_s, :confirm => 'Are you sure?', :class => "btn btn-small" %>
</div>
<% end %>
<div id="share" class="pull-right" style="margin-top:14px;">
<div class="fb-like" data-send="false" data-layout="button_count" data-width="50" data-show-faces="false" style="vertical-align:top;zoom:1;*display:inline"></div>
<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
<h3>Notes</h3>
<p><%= @spectrum.notes %></p>
<a name="comments"></a>
<h3>Comments (<%= @spectrum.comments.length %>)</h3>
<% if @spectrum.comments.length == 0 %><p><i>No comments</i></p><% end %>
<% @spectrum.comments.each do |comment| %>
<div class="comment">
<a name="comment_<%= comment.id %>"></a>
<b><%= time_ago_in_words(comment.created_at) %> ago,
<% if User.find_by_login(comment.author) %><a href="/spectra/author/<%= comment.author %>"><%= comment.author %></a> wrote:</b>
<% else %><%=h comment.author %> wrote:</b>
<% end %>
<p><%=h comment.body %></p>
<% if logged_in? && current_user.role == "admin" %><p><a href="/comments/delete/<%= comment.id %>">Delete</a></p><% end %>
</div>
<% end %>
<br />
<form action="/spectra/comment/<%= @spectrum.id %>" class="well form" id="new_comment" method="post">
<h3 style="margin-top:0;">Post a comment</h3>
<textarea name="comment[body]" id="body" cols="8" rows="6"></textarea>
<% if !logged_in? %>
<div class="control-group">
<input name="comment[email]" id="email" type="text" placeholder="you@email.com"><br />
<input name="comment[author]" id="author" type="text" placeholder="Your name"><br />
</div>
<% end %>
<% if !logged_in? && !APP_CONFIG["local"] %><p><%= recaptcha_tags :display => {:theme => "white"} %></p><% end %>
<br />
<input type='hidden' name='authenticity_token' value="<%= form_authenticity_token %>"/>
<input type='hidden' name='goto' value="analyze"/>
<input class="btn btn-primary" type="submit" value="Post" />
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
(function () {
$W.initialize({
spectrum_id:<%= @spectrum.id %>,
title: "<%= @spectrum.title.gsub('"',"'") %>",
form_authenticity_token: "<%= form_authenticity_token %>",
spectrum_data: <%= @spectrum.data.gsub('"',"'") %>
})
})()
</script>