update with changes from Production branch

This commit is contained in:
Lee Lawlor
2014-02-17 12:05:39 -05:00
parent 5b640cf9d8
commit a4937fb2e5
384 changed files with 14690 additions and 2242 deletions

View File

@ -0,0 +1,2 @@
<div id="addPortlets" ></div>

View File

@ -0,0 +1,24 @@
<div id="channel_info" class="FL channelInfo" >
<div class="FL" ><h3 class="channel_info"><%= @channel.name %></h3></div>
<div class="FR list_tags"><%= @channel.list_tags %></div>
<div class="CB"></div>
<p>by <%= link_to @channel.user.login, user_profile_path(@channel.user.login) %></p>
<div class="channelDescription" ><p><%= @channel.description %></p></div>
<p></p>
</div> <!-- end channelInfo -->
<div id="channellinks">
<div class="FR developerlink">
<a id="devInfoLink_<%= zone %>" href="#" class="topLink" ><%= t(:developer_info) %></a>
</div>
<% unless @channel.url.blank? %>
<div class="FR developerlink">
<%= link_to t(:for_more_information), @channel.url, :target => '_blank', :class => 'topLink' %>
</div>
<% end %>
<% if @mychannel %>
<div class="FR developerlink" >
<a href="#" id="portletAddLink_<%= zone %>" class="topLink " ><%= t(:add_portlets) %></a>
</div>
<% end %>
</div> <!-- end channellinks -->

View File

@ -0,0 +1,29 @@
<div id="devInfo" >
<table class="table_no_header dev_info_table1" >
<tr>
<td class="left"><%= @channel.name %> <%= t(:channel_feed) %>:</td>
<td>
<%= link_to 'JSON', "#{@api_domain}channels/#{@channel.id}/feed.json", :target => "_blank" %>
<%= link_to 'XML', "#{@api_domain}channels/#{@channel.id}/feed.xml", :target => "_blank" %>
<%= link_to 'CSV', "#{@api_domain}channels/#{@channel.id}/feed.csv", :target => "_blank" %>
</td>
</tr>
</table >
<table class="table_no_header dev_info_table2">
<% @channel.attribute_names.each do |attr| %>
<% if attr.index('field') and @channel[attr] and !@channel[attr].empty? %>
<tr>
<td class="left" ><%= t(:field) %> <%= attr[-1] %> <%= t(:data) %>: <%= @channel[attr] %> </td>
<td>
<%= link_to 'JSON', "#{@api_domain}channels/#{@channel.id}/field/#{attr[-1]}.json", :target => "_blank" %>
<%= link_to 'XML', "#{@api_domain}channels/#{@channel.id}/field/#{attr[-1]}.xml", :target => "_blank" %>
<%= link_to 'CSV', "#{@api_domain}channels/#{@channel.id}/field/#{attr[-1]}.csv", :target => "_blank" %>
</td>
</tr>
<% end %>
<% end %>
</table>
</div> <!-- end devInfo -->

View File

@ -0,0 +1,174 @@
<div class="FL">
<% flash.each do |name, msg| %>
<div id="<%= name %>" class="fade" >
<p><%= msg %></p>
<div class="clear"></div>
</div>
<% end %>
<%= form_for @channel, :html => {:method => 'put'} do |c| %>
<% unless session[:errors].nil?
session[:errors].each do |attr, msg|
@channel.errors.add(attr, msg)
end
session[:errors] = nil %>
<% end %>
<p>
<%= error_messages_for 'channel', :header_message => t(:try_again), :message => t(:channel_error) %>
</p>
<input name='userlogin' class='userlogin' />
<table class="table_no_header">
<tr>
<td class="left"><%= t(:channel_ranking) %></td>
<td><%= @channel.ranking %>%</td>
</tr>
<tr>
<td class="left"><%= t(:channel_id) %></td>
<td><%= @channel.id %></td>
</tr>
<tr>
<td class="left"><%= t(:channel_name) %></td>
<td><%= c.text_field :name %></td>
</tr>
<tr>
<td class="left"><%= t(:channel_description) %></td>
<td><%= c.text_area :description, :cols => 30, :rows => 4 %></td>
</tr>
<%= fields_for :tags do |t| %>
<tr>
<td class="left"><%= t(:tags) %></td>
<td><%= t.text_area :name, :cols => 30, :rows => 2, :value => @channel.list_tags %></td>
</tr>
<% end %>
<tr>
<td class="left"><%= t(:latitude) %></td>
<td><%= c.text_field :latitude %></td>
</tr>
<tr>
<td class="left"><%= t(:longitude) %></td>
<td><%= c.text_field :longitude %></td>
</tr>
<tr>
<td class="left"><%= t(:elevation) %></td>
<td><%= c.text_field :elevation %></td>
</tr>
<tr>
<td class="left"><%= t(:public) %></td>
<td><%= c.check_box :public_flag %></td>
</tr>
<tr>
<td class="left"><%= t(:channel_url) %></td>
<td><%= c.text_field :url %></td>
</tr>
<tr>
<td class="left"><%= t(:video_id) %></td>
<td >
<%= c.text_field :video_id, :class=>'video_narrow'%>
<%= c.radio_button :video_type, 'youtube' %>
<span class="small"><%= t(:youtube) %></span>
<%= c.radio_button :video_type, 'vimeo' %>
<span class="small"><%= t(:vimeo) %></span>
</td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 1</td>
<td><%= c.text_field :field1, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 2</td>
<td><%= c.text_field :field2, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 3</td>
<td><%= c.text_field :field3, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 4</td>
<td><%= c.text_field :field4, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 5</td>
<td><%= c.text_field :field5, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 6</td>
<td><%= c.text_field :field6, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 7</td>
<td><%= c.text_field :field7, :class => 'field' %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 8</td>
<td><%= c.text_field :field8, :class => 'field' %></td>
</tr>
<tr>
<td class="left"></td>
<td><%= c.submit t(:channel_update) %></td>
</tr>
</table>
<% end %>
<br /><br />
<h2><%= t(:channel_clear_message) %></h2>
<%= button_to t(:channel_clear), { :controller => 'channels', :action => 'clear', :id => @channel.id }, :data => { :confirm => t(:confirm_channel_clear) } %>
<br /><br />
<h2><%= t(:channel_delete_message) %></h2>
<%= button_to t(:channel_delete), channel_path(@channel.id), :method => 'delete', :data => { :confirm => t(:confirm_channel_delete) } %>
</div>
<div id="sidebar">
<ul>
<li>
<h2><%= t(:help) %></h2>
<%= t(:help_channel_public) %>
<br /><br />
<%= t(:help_channel_url) %>
<br /><br />
<%= t(:help_channel_video) %>
<br /><br />
<%= t(:help_channel_fields) %>
<br /><br />
<%= t(:help_channel_clear) %>
<br /><br />
<%= t(:help_channel_ranking) %>
<br /><br />
</li>
</ul>
</div>
<script type="text/javascript">
// remember default field label
var default_label = '<%= t(:channel_default_field) %>';
// when document is ready
$(function() {
// iterate through each field textbox
$('.field').each(function() {
// if a value is present, show the 'remove' checkbox
if ($(this).val()) {
$(this).after('<span class="small" id="span_' + $(this).attr('id') + '"><input type="checkbox" onclick="removeField(\'' + $(this).attr('id') + '\')" /><span class="up2">remove field</span></span>');
// else disable
} else {
$(this).after('<span class="small" id="span_' + $(this).attr('id') + '"><input type="checkbox" onclick="addField(\'' + $(this).attr('id') + '\')" /><span class="up2">add field</span></span>');
}
});
});
// adds a field
function addField(id) {
$('#span_'+id).remove()
$('#'+id).val(default_label + ' ' + id.substring(id.length-1));
$('#'+id).after('<span class="small" id="span_' + id + '"><input type="checkbox" onclick="removeField(\'' + id + '\')" /><span class="up2">remove field</span></span>');
$('#'+id).select();
}
// removes a field
function removeField(id) {
$('#span_'+id).remove();
$('#'+id).val('');
$('#'+id).after('<span class="small" id="span_' + id + '"><input type="checkbox" onclick="addField(\'' + id + '\')" /><span class="up2">add field</span></span>');
}
</script>

View File

@ -0,0 +1,48 @@
<div class="FL">
<%= t(:upload_select) %>
<br /><br />
<% flash.each do |name, msg| %>
<div id="<%= name %>" class="fade" >
<p><%= msg %></p>
<div class="clear"></div>
</div>
<% end %>
<%= form_for :upload, :url => upload_channel_path(@channel), :html => { :multipart => true } do |f| %>
<%= f.file_field :csv %>
<br /><br />
<%= t(:time_zone) %>
<%= time_zone_select 'feed', 'time_zone', nil, :default => 'UTC' %>
<br /><br />
<%= f.submit t(:upload), :disable_with => t(:uploading) %>
<% end %>
</div>
<div id="sidebar" >
<ul>
<li>
<div class="helplink">(<a target="_blank" href="http://community.thingspeak.com/documentation/api/#send_data"><%= t(:help_options) %></a>)</div>
<h2><%= t(:help_channel_update) %></h2>
<%= t(:help_channel_post) %>
<div class="code"><%= "#{@api_domain}update" %></div>
<%= t(:help_channel_post_example) %>
<div class="code"><%= "#{@api_domain}update?key=#{@key}&field1=0" %></div>
<br /><br />
<div class="helplink">(<a target="_blank" href="http://community.thingspeak.com/documentation/api/#view_data"><%= t(:help_options) %></a>)</div>
<h2><%= t(:help_channel_feed) %></h2>
<%= t(:help_channel_view) %>
<br />
<div class="code"><%= link_to "#{@api_domain}channels/#{@channel.id}/feed.json?key=#{@key}", "#{@api_domain}channels/#{@channel.id}/feed.json?key=#{@key}", :target => '_blank' %></div>
<br />
</li>
<li>
<div class="helplink">(<a target="_blank" href="http://community.thingspeak.com/documentation/#importer"><%= t(:help_options) %></a>)</div>
<h2><%= t(:help) %></h2>
<%= t(:help_channel_import) %>
</li>
</ul>
</div>

View File

@ -0,0 +1,23 @@
<div style="width:90%;">
<% @channels.each do |channel| %>
<% channel.ranking = channel.calc_ranking if channel.ranking.blank? %>
<div class="public_channel_box">
<div class="public_channel_inner">
<p class="public_channel_name">
<%= link_to channel.name, channel_path(channel.id), :id => "showsite_#{channel.id}" %>
</p>
<p class="public_channel_user" >by <%= channel.user.login %></p>
<p class="public_channel_desc"><%= channel.description %></p>
<div class="progressbar" rel="<%= channel.ranking %>"></div>
<p class="public_channel_tags">
<% channel.tags.each do |tag| %>
<a href="/channels/public?tag=<%=u tag.name %>"><%= tag.name %></a><% unless tag == channel.tags.last %>, <% end %>
<% end %>
</p>
</div>
</div>
<% end %>
</div>

View File

@ -0,0 +1,31 @@
<%= render :partial => 'channelinfo', :locals => { :zone => "private" } %>
<div class="channel_stats_location">
<span class="channel_stats_text">Channel Stats</span>
<table>
<tr><td>Created</td><td ><abbr class="timeago channel_time_text" title="<%= @channel.created_at %>" ><%= @channel.created_at %></abbr></td></tr>
<tr><td>Updated</td><td ><abbr class="timeago channel_time_text" title="<%= @channel.updated_at %>" ><%= @channel.updated_at %></abbr></td></tr>
</table>
<span><%= @channel.feeds.count %> Entries</span>
</div>
<div class="CB" >
<div id="private_dialog0" class="column" > </div>
<div id="private_dialog1" class="column" > </div>
</div>
<script>
$(function() {
$("#devInfoLink_private").click(
function(e) {
var element = $("#devInfo");
openDialogCenter(element);
});
$("#portletAddLink_private").click(
function(e) {
$("#addPortlets").load('/channels/<%=@channel.id %>/hidden_windows?visibility_flag=private',
function(e) {
var element = $("#addPortlets");
openDialogCenter(element);
}) ;
});
});
</script>

View File

@ -0,0 +1,75 @@
<% if @channel.public? %>
<%= render :partial => 'channelinfo', :locals => { :zone => "public" } %>
<div class="CB">
<div id="public_dialog0" class="column" > </div>
<div id="public_dialog1" class="column" > </div>
</div>
<div class="commentlink" >
<% if !current_user %>
<%= link_to t(:comment_add), channel_comments_path(@channel), :class => 'boldlink' %>
<% else %>
<span class="mainlink spanlink boldlink" onclick="$('#commentmain').toggle();"><%= t(:comment_add) %></span>
<% end %>
<div id="commentmain" style="display:none" >
<%= form_for :comment, :url => channel_comments_path(@channel) do |f| %>
<%= f.error_messages %>
<input name='userlogin' class='userlogin' />
<%= f.text_area :body, :rows => 7, :cols => 54 %>
<br />
<%= submit_tag %>
<% end %>
</div>
<br/><br/>
<div id='comments' >
<% @channel.comments.each do |c| %>
<%= render :partial => 'comments/comment', :object => c if c.parent_id.nil? %>
<% end %>
</div>
</div>
<script>
$("#devInfoLink_public").click(function() {
var element = $("#devInfo");
openDialogCenter(element);
});
$("#portletAddLink_public").click(function()
{
$("#addPortlets").load('/channels/<%=@channel.id %>/hidden_windows?visibility_flag=public',
function() {
var element = $("#addPortlets");
openDialogCenter(element);
})
});
// comment flag function
function commentflag(m_id, user_id)
{
$.ajax({
url: '/comments/vote/' + m_id,
type: 'POST',
data: {user_id : user_id},
success: function(data) {
$('#commentflag' + m_id).parent().parent().append("<span id='votemsg" + m_id + "'><br /><br /><%= t(:comment_reported) %></span>");
$('#imgflag' + m_id).attr('src', '/images/flag_red.gif');
$('#flaglink' + m_id).removeAttr('onclick');
$('#flaglink' + m_id).unbind('mouseenter mouseleave');
setTimeout(function() { $("#votemsg" + m_id).fadeOut(); }, 2600);
}
});
return false;
}
</script>
<% else %>
<div class="FL" >
<h3 class="channel_info"><%= t(:channel_not_public) %></h3>
</div>
<% end %>

View File

@ -0,0 +1,26 @@
<div class="socialButtons" >
<% if current_user %>
<div class="buttonlets padded watchButtonPadding">
<%= check_box_tag 'watch', 1, current_user.watchings.check(current_user.id, @channel.id) %>
<label for="watch" class="watchButtonLabel" >
<div class="watchButtonImage"></div>
<div id="watchText" class="watchButtonText">Watch</div>
</label>
</div>
<% end %>
<div class="addthis_toolbox addthis_default_style buttonlets padded tweetButton" >
<a class="addthis_button_tweet"></a>
</div>
<div class="addthis_toolbox addthis_default_style buttonlets padded facebookButton" >
<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
</div>
<div class="addthis_toolbox addthis_default_style buttonlets padded googleplusButton" >
<a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
</div>
<div class="addthis_toolbox addthis_default_style buttonlets padded" >
<a class="addthis_counter addthis_pill_style"></a>
</div>
</div>
<script type="text/javascript" src="https://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f9168ce642d4694"></script>

View File

@ -1,25 +1,79 @@
<h2><%= t(:channels) %></h2>
<% if @channels.length > 0 %>
<table class="nicetable">
<tr class="header TAC">
<td><%= t(:channel_id) %></td>
<td><%= t(:channel_name) %></td>
</tr>
<% @channels.each do |d| %>
<tr>
<td class="left"><%= link_to d.id, channel_path(d.id) %></td>
<td><%= link_to d.name, channel_path(d.id) %></td>
</tr>
<div class="row">
<div class="col-xs-12 col-sm-6">
<h4 class="breadcrumb"><%= t(:channels_my) %></h4>
<div class="col-pad">
<% if @channels.length > 0 %>
<table class="nicetable-borderless">
<% @channels.each do |channel| %>
<% if !channel.social %>
<tr>
<td>
<h3 class="signed_in_channel_header" ><%= link_to channel.name, channel_path(channel.id), :id => "showsite_#{channel.id}" %></h3>
<div class="public_private_icon">
<%= channel.public_flag ? image_tag('icons/Unlocked.png', :title=> t(:public_true)) : image_tag('icons/Locked.png', :title=> t(:channel_not_public)) %>
</div>
</td>
</tr>
<tr><td><p><%= link_to t(:private_link), channel_path(channel.id, :anchor => 'privateview') %> |
<%= link_to t(:public_link), channel_path(channel.id, :anchor => 'publicview') %> |
<%= link_to t(:settings_link), channel_path(channel.id, :anchor => 'channelsettings') %> |
<%= link_to t(:api_key_link), channel_path(channel.id, :anchor => 'apikeys') %> |
<%= link_to t(:data_import_link), channel_path(channel.id, :anchor => 'dataimport') %> </p></td></tr>
<tr><td><p><%= channel.description %></p></td></tr>
<% end %>
<% end %>
</table>
<br />
<% end %>
</table>
<br /><br />
<% end %>
<%= form_for :channel do |d| %>
<input name='userlogin' class='userlogin' />
<%= d.submit t(:channel_create) %>
<% end %>
<%= form_for :channel do |d| %>
<input name='userlogin' class='userlogin' />
<%= d.submit t(:channel_create), :class => 'btn btn-primary' %>
<% end %>
<% if is_admin? %>
<br /><br /><br />
<% @channels.each do |c| %>
<% if c.social %>
<%= t(:social_channel) %>: <%= link_to c.name, (Rails.env == 'production') ? "http://www.socialsensornetwork.com/#{c.slug}" : "/s/#{c.slug}" %>
<br />
<% end %>
<% end %>
<br />
<%= link_to t(:social_channel_create), :controller => 'channels', :action => 'social_new' %>
<% end %>
</div>
</div>
<div id="sidebar" class="col-xs-12 col-sm-6">
<h4 class="breadcrumb"><%= t(:help) %></h4>
<div class="col-pad">
<%= t(:help_channel) %>
(<a href="http://community.thingspeak.com/documentation/api/"><%= t(:help_options) %></a>)
<ul>
<li><a href="http://community.thingspeak.com/tutorials/arduino/using-an-arduino-ethernet-shield-to-update-a-thingspeak-channel/">Arduino Tutorial</a></li>
<li><a href="http://community.thingspeak.com/tutorials/netduino/create-your-own-web-of-things-using-the-netduino-plus-and-thingspeak/">Netduino Plus Tutorial</a></li>
</ul>
</div>
</div>
</div>

View File

@ -0,0 +1,133 @@
<%= render :partial => "devinfo" %>
<%= render :partial => "addportlet" %>
<div class="col-xs-12 col-sm-6">
<ol class="breadcrumb">
<li><%= link_to t(:channels), channels_path %></li>
<li class="active"><%= t(:channel) %> <%= @channel.id %></li>
</ol>
</div>
<%= render :partial => "socialbuttons" %>
<div id="maincontent" >
<ul>
<li><a href="#privateview"><%= t("private_view") %></a></li>
<li><a href="#publicview"><%= t("public_view") %></a></li>
<li><a href="#channelsettings"><%= t("channel_settings") %></a></li>
<li><a href="#apikeys"><%= t("api_keys") %></a></li>
<li><a href="#dataimport"><%= t("data_import") %></a></li>
</ul>
<div id="privateview">
<%= render :partial => "private_show" %>
</div>
<div id="publicview">
<%= render :partial => "public_show" %>
</div>
<div id="channelsettings">
<%= render :partial => "edit" %>
</div>
<div id="apikeys">
<%= render :partial => "api_keys/index" %>
</div>
<div id="dataimport">
<%= render :partial => "import" %>
</div>
</div>
<script type="text/javascript">
$('#watch').click(function() {
$.update(
'/channels/<%= @channel.id %>/watch',
// data to send
{
flag: this.checked
},
// if post was successful
function (response) {
if ($("#watch").attr("checked")) {
$("#watchText").text("Un-watch");
}
else {
$("#watchText").text("Watch");
}
}
);
});
$(function () {
$(".timeago").timeago();
if(document.location.hash!='') {
$('html').animate({scrollTop:0}, 'normal');//IE, FF
$('body').animate({scrollTop:0}, 'normal');//chrome, don't know if safari works
}
$('.fade').fadeIn('normal').fadeOut(3500, function() {
$(this).remove();
});
$("#devInfo").dialog({
autoOpen:false,
resizable:false,
width:"500px",
title: "<%= t('developer_info') %>",
dialogClass: "dev-info-dialog"
});
$("#addPortlets").dialog({
modal:true,
autoOpen:false,
resizable:false,
width:"500px",
dialogClass: "dev-info-dialog"
});
$("#watch").button();
if ($("#watch").attr("checked")) {
$("#watchText").text("Un-watch");
}
else {
$("#watchText").text("Watch");
}
$("#maincontent").tabs( {
select: function( e, ui)
{
$.cookie('stickyTab', ui.index );
}
}
);
stickyTab = $.cookie( 'stickyTab' );
anchor = window.location.hash;
if (anchor.length > 0) {
stickyTab = anchor.substring(anchor.length - 1);
}
if( ! isNaN( stickyTab ) )
{
$("#maincontent").tabs( 'select', stickyTab );
}
var current_user = "<%= @mychannel %>";
var channel_id = <%= @channel.id %>;
setupColumns(current_user, channel_id);
$.getJSON('/channels/<%=@channel.id %>/private_windows.json', function(data) {
createWindowsWithData (data, current_user, channel_id, "private");
$.getJSON('/channels/<%=@channel.id %>/windows.json',
createWindows (current_user, channel_id, "public")
);
});
});
</script>

View File

@ -0,0 +1,11 @@
<div class="row">
<div class="col-xs-12 col-sm-12">
<h4 class="breadcrumb"><%= flash[:notice] %></h4>
<%= render :partial => 'list' %>
<br />
<%= will_paginate @channels %>
</div>
</div>

View File

@ -0,0 +1,92 @@
<%= render :partial => "devinfo" %>
<div class="col-xs-12 col-sm-6">
<ol class="breadcrumb">
<li><%= link_to t(:channels), auth_channels_path %></li>
<li class="active"><%= t(:channel) %> <%= @channel.id %></li>
</ol>
</div>
<%= render :partial=>"socialbuttons" %>
<div id="maincontent">
<ul>
<li><a href="#publicview">Public View</a></li>
</ul>
<div id="publicview">
<%= render :partial => "public_show" %>
</div>
</div>
<script type="text/javascript">
$('#watch').click(function() {
$.update(
'/channels/<%= @channel.id %>/watch',
{
flag: this.checked
},
function (response) {
if ($("#watch").attr("checked")) {
$("#watchText").text("Un-watch");
}
else {
$("#watchText").text("Watch");
}
}
);
});
$("#devInfoLink").click(function() {
$("#devInfo").dialog("open") ;
});
$(function () {
$("#devInfo").dialog({
autoOpen:false,
resizable:false,
width:"500px",
position: {
my: 'top',
at: 'top',
of: $('#maincontent')
},
title: "Developer Info",
dialogClass: "dev-info-dialog"
});
$("#watch").button();
if ($("#watch").attr("checked")) {
$("#watchText").text("Un-watch");
}
else {
$("#watchText").text("Watch");
}
$("#maincontent").tabs( {
select: function( e, ui)
{
$.cookie('stickyTab', ui.index );
}
}
);
stickyTab = $.cookie( 'stickyTab' );
if( ! isNaN( stickyTab ) )
{
$("#maincontent").tabs( 'select', stickyTab );
}
var current_user = "<%= @mychannel %>" ;
var channel_id = <%= @channel.id %>;
$.getJSON('/channels/<%=@channel.id %>/windows.json', createWindows (current_user, channel_id, "public") )
.complete(function() {
setupColumns(current_user, channel_id);
})
});
</script>

View File

@ -0,0 +1,93 @@
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="<%= @domain %>javascripts/timeago.min.js"></script>
<style type="text/css">
html, body { margin: 0; padding: 0; font-family: Helvetica, Arial, sans-serif; color: #333333; font-size: 16px;}
.indent { margin-left: 28px; padding: 2px;}
.small { font-size: 80%; }
.status { padding: 3px; color: #ffffff; background-color: #62a09d; }
.timeago { font-size: 10px; }
</style>
<script type="text/javascript">
$(document).ready(function() {
var html = '';
var field1, field2, field3, field4, field5, field6, field7, field8;
// get the data with a webservice call
$.getJSON('<%= "#{@domain}channels/#{params[:channel_id]}/feed.json?callback=?&offset=0&results=10&location=true&status=true" %>', function(data) {
// set channel field names
if (data.channel.field1) { field1 = data.channel.field1; }
if (data.channel.field2) { field2 = data.channel.field2; }
if (data.channel.field3) { field3 = data.channel.field3; }
if (data.channel.field4) { field4 = data.channel.field4; }
if (data.channel.field5) { field5 = data.channel.field5; }
if (data.channel.field6) { field6 = data.channel.field6; }
if (data.channel.field7) { field7 = data.channel.field7; }
if (data.channel.field8) { field8 = data.channel.field8; }
// iterate through each feed
$.each(data.feeds.reverse(), function() {
if (this.location) {
html += '<div id="entry_' + this.entry_id + '"><b><img src="<%= "#{@domain}images/icon_location_24.png" %>" width="24" height="24" border="0" align="absbottom" /> ' + this.location + '</b></div>';
if (this.field1) { html += '<div class="indent">' + data.channel.field1 + ': ' + this.field1 + '</div>'; }
if (this.field2) { html += '<div class="indent">' + data.channel.field2 + ': ' + this.field2 + '</div>'; }
if (this.field3) { html += '<div class="indent">' + data.channel.field3 + ': ' + this.field3 + '</div>'; }
if (this.field4) { html += '<div class="indent">' + data.channel.field4 + ': ' + this.field4 + '</div>'; }
if (this.field5) { html += '<div class="indent">' + data.channel.field5 + ': ' + this.field5 + '</div>'; }
if (this.field6) { html += '<div class="indent">' + data.channel.field6 + ': ' + this.field6 + '</div>'; }
if (this.field7) { html += '<div class="indent">' + data.channel.field7 + ': ' + this.field7 + '</div>'; }
if (this.field8) { html += '<div class="indent">' + data.channel.field8 + ': ' + this.field8 + '</div>'; }
if (this.status) { html += '<div class="indent"><span class="status">"' + this.status + '"</span></div>'; }
html += '<div class="indent small"><abbr class="timeago" title="' + this.created_at + '">' + this.created_at + '</abbr></div>';
html += '<div>&nbsp;</div>';
}
});
// write data to page
$('#feed-container').html(html);
// add timeago
$('abbr.timeago').timeago();
// push data every 15 seconds
setInterval(function() {
// get the data with a webservice call
$.getJSON('<%= "#{@domain}channels/#{params[:channel_id]}/feed/last.json?callback=?&offset=0&location=true&status=true" %>', function(data) {
// if data exists and entry id doesn't already exist
if (data.location && $('#entry_' + data.entry_id).length == 0) {
html = '<div id="entry_' + data.entry_id + '"><b><img src="<%= "#{@domain}images/icon_location_24.png" %>" width="24" height="24" border="0" align="absbottom" /> ' + data.location + '</b></div>';
if (data.field1) { html += '<div class="indent">' + field1 + ': ' + data.field1 + '</div>'; }
if (data.field2) { html += '<div class="indent">' + field2 + ': ' + data.field2 + '</div>'; }
if (data.field3) { html += '<div class="indent">' + field3 + ': ' + data.field3 + '</div>'; }
if (data.field4) { html += '<div class="indent">' + field4 + ': ' + data.field4 + '</div>'; }
if (data.field5) { html += '<div class="indent">' + field5 + ': ' + data.field5 + '</div>'; }
if (data.field6) { html += '<div class="indent">' + field6 + ': ' + data.field6 + '</div>'; }
if (data.field7) { html += '<div class="indent">' + field7 + ': ' + data.field7 + '</div>'; }
if (data.field8) { html += '<div class="indent">' + field8 + ': ' + data.field8 + '</div>'; }
if (data.status) { html += '<div class="indent"><span class="status">"' + data.status + '"</span></div>'; }
html += '<div class="indent small"><abbr class="timeago" title="' + data.created_at + '">' + data.created_at + '</abbr></div>';
html += '<div>&nbsp;</div>';
// write data to page
$(html).prependTo('#feed-container').hide().slideDown();
// add timeago
$('abbr.timeago').timeago();
}
});
}, 15000);
});
});
</script>
</head>
<body style='background-color: <%= params[:bgcolor] ? params[:bgcolor] : 'transparent' %>;'>
<div id="feed-container"></div>
</body>
</html>

View File

@ -0,0 +1,107 @@
<div id="maincontent" class="thin">
<h2>
<%= link_to t(:channels), channels_path %> &raquo;
<%= t(:social_channel_new) %>
</h2>
<%= form_for @channel, :url => { :action => 'social_create' } do |c| %>
<%= error_messages_for 'channel', :header_message => t(:try_again), :message => t(:channel_error) %>
<input name='userlogin' class='userlogin' />
<table class="table_no_header">
<tr>
<td class="left"><%= t(:channel_name) %></td>
<td><%= c.text_field :name %></td>
</tr>
<tr>
<td class="left"><%= t(:slug) %></td>
<td><%= c.text_field :slug %></td>
</tr>
<tr>
<td class="left"><%= t(:channel_directions) %></td>
<td><%= c.text_area :description, :cols => 30, :rows => 4 %></td>
</tr>
<%= fields_for :tags do |t| %>
<tr>
<td class="left"><%= t(:tags) %></td>
<td><%= t.text_area :name, :cols => 30, :rows => 2, :value => @channel.list_tags %></td>
</tr>
<% end %>
<tr>
<td class="left"><%= t(:field) %> 1</td>
<td><%= c.text_field :field1 %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 2</td>
<td><%= c.text_field :field2 %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 3</td>
<td><%= c.text_field :field3 %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 4</td>
<td><%= c.text_field :field4 %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 5</td>
<td><%= c.text_field :field5 %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 6</td>
<td><%= c.text_field :field6 %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 7</td>
<td><%= c.text_field :field7 %></td>
</tr>
<tr>
<td class="left"><%= t(:field) %> 8</td>
<td><%= c.text_field :field8 %></td>
</tr>
<tr>
<td class="left"><%= t(:message_field) %></td>
<td><%= c.text_field :status %></td>
</tr>
<tr>
<td class="left"></td>
<td><%= c.submit t(:social_channel_create) %></td>
</tr>
</table>
<% end %>
</div>
<div id="sidebar" class="ML60 medium">
<ul>
<li>
<h2><%= t(:help) %></h2>
<%= t(:help_social_channel) %>
<br /><br />
<div class="code">http://www.socialsensornetwork.com/<b>slug</b></div>
<br />
<%= t(:help_social_channel_public) %>
</li>
</ul>
</div>
<script type="text/javascript">
// sets the slug field
function slugify() {
$('#channel_slug').val($('#channel_name').val().replace(/ /g, '-').replace(/[^0-9\-a-zA-Z]+/g, '').toLowerCase());
}
// when document is ready
$(function() {
// events to automatically create slug field
$('#channel_name').keyup(function() {
slugify();
});
$('#channel_name').bind('paste', function() {
slugify();
});
});
</script>

View File

@ -0,0 +1,308 @@
<!DOCTYPE html>
<html>
<head>
<title><%= @channel.name %></title>
<style type="text/css">
html, body { font-family: Helvetica, Arial, sans-serif; color: #333333; font-size: 16px; background-color: #bcd1e4; }
a { color: #55a; }
h2 {
margin: 10px 0 0 0;
font: 45px Tahoma, Helvetica, Arial, Sans-Serif;
text-align: left;
color: #535353;
text-shadow: 0px 2px 3px #62a09d;
}
h3 {
margin: 0 0 0 0;
font: 14px Tahoma, Helvetica, Arial, Sans-Serif;
text-align: center;
color: #656fad;
text-shadow: 0px 1px 2px #62a09d;
}
input[type='text'] { width: 180px; }
textarea { width: 178px; height: 40px; overflow: auto; }
input, #submit {
font: 14px Tahoma, Helvetica, Arial, Sans-Serif;
text-align: left;
color: #656fad;
border: 1px solid #535353;
}
#content {
margin: 0 auto;
text-align: left;
width: 980px;
}
#social {
float:left;
}
#developers { float: right; color: #555; font-size: 13px; }
#developers a { font-size: 11px; text-decoration: none; font-weight: bold; }
#footer { font-size: 80%; margin-left: 5px; }
.CB { clear: both; }
.default_text {
margin: 0 0 0 3px;
font: 15px Tahoma, Helvetica, Arial, Sans-Serif;
color: #353f7d;
}
</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-22749436-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="content">
<div id="social">
<script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
<a href="http://twitter.com/share?via=socialsensors" class="twitter-share-button">Tweet</a>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.socialsensornetwork.com%2F<%= @channel.slug.gsub('-', '%2D') %>&amp;layout=button_count&amp;show_faces=true&amp;width=450&amp;action=like&amp;font=tahoma&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>
</div>
<div id="developers">
Developers?
<%= link_to 'JSON', "#{@api_domain}channels/#{@channel.id}/feed.json?results=100&location=true&offset=0&round=2&status=true" %>
<%= link_to 'XML', "#{@api_domain}channels/#{@channel.id}/feed.xml?results=100&location=true&offset=0&round=2&status=true" %>
<%= link_to 'CSV', "#{@api_domain}channels/#{@channel.id}/feed.csv?results=100&location=true&offset=0&round=2&status=true" %>
</div>
<div style="clear:both;"></div>
<div style="float:left; padding-right: 40px;">
<a href="http://www.socialsensornetwork.com">
<img src='<%= "#{@api_domain}images/social_sensor_network_logo.png "%>' width='120' height='120' border='0' />
</a>
</div>
<div style="display: block; padding-top: 25px;">
<h2><%= @channel.name %></h2>
</div>
<br class="CB" />
<% if !@channel.description.blank? %>
<div class="default_text"><%= t(:channel_directions) %>: <%= @channel.description %></div>
<br />
<% end %>
<%= form_tag "#{@post_url}" do %>
<table>
<% @fields.each do |f| %>
<tr>
<td><%= @channel[f] %></td>
<td><%= text_field_tag "#{f}" %></td>
</tr>
<% end %>
<% if !@channel.status.blank? %>
<tr>
<td style="vertical-align: top;"><div style="padding-top: 5px;"><%= @channel.status %></div></td>
<td><%= text_area_tag :status %></td>
</tr>
<% end %>
<tr>
<td></td>
<td>
<%= submit_tag t(:submit), :id => 'submit' %>
<span id="msg" />
</td>
</tr>
</table>
<% end %>
<br /><br />
<div style="float: left; width: 600px;">
<iframe width="600" height="300" frameborder="0" scrolling="no" style="border: 1px solid #cccccc;" src="<%= @api_domain %>channels/<%= @channel.id %>/maps/default?width=600&height=300&results=100&round=2&status=true&dynamic=true"></iframe>
<% @fields.each do |f| %>
<br /><br />
<iframe width="600" height="300" frameborder="0" style="border: 1px solid #cccccc;" src="<%= @api_domain %>channels/<%= @channel.id %>/charts/<%= f[-1] %>?width=600&height=300&results=100&round=2&color=C46353&location=true&dynamic=true&push=false&max=20000&min=-20000"></iframe>
<% end %>
<div id="footer">
<br /><br />
&copy;2011 Social Sensor Network - Powered by <a href="https://www.thingspeak.com/">ThingSpeak</a>
</div>
</div>
<div style="float: right; width: 300px;">
<iframe width="300" height="1100" frameborder="0" scrolling="no" allowTransparency="true" style="border: 0;" src="<%= @api_domain %>channels/<%= @channel.id %>/social_feed"></iframe>
</div>
</div>
<script type="text/javascript" src="<%= @api_domain %>javascripts/rest.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
// keep track of whether user entered something in the form
var thingspeak_user_input = 0;
// keep track of whether user has submitted form
var thingspeak_submitted = 0;
// get location from latitude and longitude
function reverseGeocode(latitude, longitude) {
var geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(latitude,longitude);
var location = '';
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results) {
$.each(results, function() {
// if city
if (this.types == "locality,political") {
location = this.address_components[0].long_name;
}
if (this.types == "administrative_area_level_1,political") {
if (location.length > 0) { location += ', '; }
location += this.address_components[0].short_name;
}
// if country
if (this.types == "country,political") {
if (location.length > 0) { location += ', '; }
location += this.address_components[0].long_name;
}
});
}
}
// submit the post
submitPost(latitude, longitude, location);
});
}
// set the user's location
function setLocation() {
// Try W3C Geolocation method (Preferred)
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
reverseGeocode(position.coords.latitude, position.coords.longitude);
}, function() {
handleNoGeolocation();
});
// Try Google Gears Geolocation
} else if (google.gears) {
var geo = google.gears.factory.create('beta.geolocation');
reverseGeocode(position.latitude, position.longitude);
} else {
// Browser doesn't support Geolocation
handleNoGeolocation();
}
}
// use maxmind's geoip service
function handleNoGeolocation() {
var latitude = geoip_latitude();
var longitude = geoip_longitude();
var location = geoip_city();
if (location.length > 0 && geoip_region()) { location += ', '; }
location += geoip_region();
if (location.length > 0 && geoip_country_name()) { location += ', '; }
location += geoip_country_name();
submitPost(latitude, longitude, location);
}
// do the form post
function submitPost(latitude, longitude, location) {
if (thingspeak_submitted === 0) {
$.create(
// url to post to
'<%= @post_url %>',
// data to send
{
<% @fields.each do |f| %>
<%= f %>: Number($('#<%= f %>').val().replace(/[^0-9\.\-]+/g, "")),
<% end %>
latitude: latitude,
longitude: longitude,
location: location<%= ',' if !@channel.status.blank? %>
<% if !@channel.status.blank? %>status: $('#status').val()<% end %>
},
// if post was successful
function (response) {
var msg = (response == '0') ? '<%= t(:saved_error) %>' : '<%= t(:social_saved) %>';
$('#msg').html(msg);
clearMsg();
},
// if post failed
function (response) {
$('#msg').html('<%= t(:saved_error) %>');
clearMsg();
}
);
}
// mark the form as submitted
thingspeak_submitted = 1;
}
// clears message
function clearMsg() {
setTimeout(function() {
$('#msg').html('');
}, 3000);
}
// when document is ready
$(function() {
// event to make sure user types something into form
<% @fields.each do |f| %>
$('#<%= f %>').keyup(function() {
thingspeak_user_input = 1;
});
$('#<%= f %>').bind('paste', function() {
thingspeak_user_input = 1;
});
<% end %>
<% if !@channel.status.blank? %>
$('#status').keyup(function() {
thingspeak_user_input = 1;
});
$('#status').bind('paste', function() {
thingspeak_user_input = 1;
});
<% end %>
// event to capture update button click
$('#submit').click(function() {
// if nothing entered into form
if (thingspeak_user_input === 0) {
$('#msg').html('<%= t(:social_channel_no_value) %>');
clearMsg();
} else {
// set geolocation data (and submit the post)
setLocation();
}
return false;
});
});
</script>
<script type="text/javascript" src="http://j.maxmind.com/app/geoip.js"></script>
</body>
</html>

View File

@ -0,0 +1,18 @@
<div class="row">
<div class="col-xs-12 col-sm-6">
<h4 class="breadcrumb"><%= t(:watched_channels) %></h4>
<div class="col-pad">
<% if @channels.empty? %>
<%= t(:watched_empty) %>
<br /><br />
<%= link_to t(:watched_find), public_channels_path %>
<% else %>
<%= render :partial => 'list' %>
<% end %>
</div>
</div>
</div>