add metadata field to channels
This commit is contained in:
@ -51,6 +51,7 @@ body { padding-top: 70px; }
|
||||
.format-json,
|
||||
.format-xml { display: none; }
|
||||
.format-block { min-height: 200px; }
|
||||
.format-block-sm { min-height: 50px; }
|
||||
.format-block-lg { min-height: 350px; }
|
||||
.format-block-xl { min-height: 400px; }
|
||||
.format-block-xxl { min-height: 600px; }
|
||||
|
@ -531,7 +531,7 @@ class ChannelsController < ApplicationController
|
||||
|
||||
# only allow these params
|
||||
def channel_params
|
||||
params.require(:channel).permit(:name, :url, :description, :latitude, :longitude, :field1, :field2, :field3, :field4, :field5, :field6, :field7, :field8, :elevation, :public_flag, :status, :video_id, :video_type)
|
||||
params.require(:channel).permit(:name, :url, :description, :metadata, :latitude, :longitude, :field1, :field2, :field3, :field4, :field5, :field6, :field7, :field8, :elevation, :public_flag, :status, :video_id, :video_type)
|
||||
end
|
||||
|
||||
# determine if the date can be parsed
|
||||
|
@ -34,12 +34,12 @@ class FeedController < ApplicationController
|
||||
|
||||
# set output correctly
|
||||
if params[:format] == 'xml'
|
||||
@channel_output = channel.to_xml(channel.select_options).sub('</channel>', '').strip
|
||||
@channel_output = channel.to_xml(channel.select_options(params)).sub('</channel>', '').strip
|
||||
@feed_output = feeds.to_xml(:skip_instruct => true).gsub(/\n/, "\n ").chop.chop
|
||||
elsif params[:format] == 'csv'
|
||||
@feed_output = feeds
|
||||
else
|
||||
@channel_output = channel.to_json(channel.select_options).chop
|
||||
@channel_output = channel.to_json(channel.select_options(params)).chop
|
||||
@feed_output = feeds.to_json(:only => feed_factory.feed_select_options)
|
||||
end
|
||||
|
||||
@ -246,7 +246,7 @@ class FeedController < ApplicationController
|
||||
|
||||
@time_after_sort = Time.now
|
||||
|
||||
@channel_output = channel.to_json(channel.select_options).chop
|
||||
@channel_output = channel.to_json(channel.select_options(params)).chop
|
||||
@feed_output = feeds.to_json
|
||||
|
||||
@time_after_json = Time.now
|
||||
|
@ -47,6 +47,7 @@
|
||||
# ranking :integer
|
||||
# user_agent :string(255)
|
||||
# realtime_io_serial_number :string(36)
|
||||
# metadata :text
|
||||
#
|
||||
|
||||
class Channel < ActiveRecord::Base
|
||||
@ -98,9 +99,10 @@ class Channel < ActiveRecord::Base
|
||||
end
|
||||
|
||||
# select options
|
||||
def select_options
|
||||
def select_options(options = nil)
|
||||
only = [:name, :created_at, :updated_at, :id, :last_entry_id]
|
||||
only += [:description] unless self.description.blank?
|
||||
only += [:metadata] if options.present? && options[:metadata] == 'true'
|
||||
only += [:latitude] unless self.latitude.blank?
|
||||
only += [:longitude] unless self.longitude.blank?
|
||||
only += [:elevation] unless self.elevation.blank?
|
||||
@ -179,7 +181,7 @@ class Channel < ActiveRecord::Base
|
||||
def self.private_options
|
||||
{
|
||||
:root => false,
|
||||
:only => [:id, :name, :description, :latitude, :longitude, :last_entry_id, :elevation, :created_at, :ranking],
|
||||
:only => [:id, :name, :description, :metadata, :latitude, :longitude, :last_entry_id, :elevation, :created_at, :ranking],
|
||||
:methods => :username,
|
||||
:include => {
|
||||
:tags => {:only => [:id, :name]},
|
||||
|
@ -29,6 +29,10 @@
|
||||
<td class="left"><%= t(:channel_description) %></td>
|
||||
<td><%= c.text_area :description, :cols => 30, :rows => 4 %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="left"><%= t(:metadata).capitalize %></td>
|
||||
<td><%= c.text_area :metadata, :cols => 30, :rows => 4 %></td>
|
||||
</tr>
|
||||
<%= fields_for :tags do |t| %>
|
||||
<tr>
|
||||
<td class="left"><%= t(:tags) %></td>
|
||||
|
@ -22,6 +22,7 @@ Valid parameters:
|
||||
<li><b>field8</b> (string) - Field8 name (optional)</li>
|
||||
<li><b>latitude</b> (decimal) - Latitude in degrees (optional)</li>
|
||||
<li><b>longitude</b> (decimal) - Longitude in degrees (optional)</li>
|
||||
<li><b>metadata</b> (text) - Metadata for the Channel, which can include JSON, XML, or any other data (optional)</li>
|
||||
<li><b>name</b> (string) - Name of the Channel (optional)</li>
|
||||
<li><b>public_flag</b> (true/false) - Whether the Channel should be public, default false (optional)</li>
|
||||
<li><b>tags</b> (string) - Comma-separated list of tags (optional)</li>
|
||||
@ -39,11 +40,11 @@ POST <span class="str"><%= @ssl_api_domain %>channels<span class="format format-
|
||||
|
||||
<br>
|
||||
|
||||
<div class="format format-block-xl format-text">
|
||||
<div class="format format-block-xxl format-text">
|
||||
The response will be a webpage with your newly created Channel.
|
||||
</div>
|
||||
|
||||
<div class="format format-block-xl format-json">
|
||||
<div class="format format-block-xxl format-json">
|
||||
The response will be a JSON object of the new channel, for example:
|
||||
|
||||
<pre class="prettyprint">
|
||||
@ -51,6 +52,7 @@ POST <span class="str"><%= @ssl_api_domain %>channels<span class="format format-
|
||||
"id": 4,
|
||||
"name": "My New Channel",
|
||||
"description": null,
|
||||
"metadata": null,
|
||||
"latitude": null,
|
||||
"longitude": null,
|
||||
"created_at": "2014-03-25T13:12:50-04:00",
|
||||
@ -71,7 +73,7 @@ POST <span class="str"><%= @ssl_api_domain %>channels<span class="format format-
|
||||
|
||||
</div>
|
||||
|
||||
<div class="format format-block-xl format-xml">
|
||||
<div class="format format-block-xxl format-xml">
|
||||
The response will be an XML object of the new channel, for example:
|
||||
|
||||
<pre class="prettyprint">
|
||||
@ -80,6 +82,7 @@ POST <span class="str"><%= @ssl_api_domain %>channels<span class="format format-
|
||||
<id type="integer">4</id>
|
||||
<name>My New Channel</name>
|
||||
<description nil="true" />
|
||||
<metadata nil="true" />
|
||||
<latitude type="decimal" nil="true" />
|
||||
<longitude type="decimal" nil="true" />
|
||||
<created-at type="dateTime">2014-03-25T20:17:44-04:00</created-at>
|
||||
|
@ -18,6 +18,7 @@ Valid parameters:
|
||||
<li><b>timezone</b> (string) <a href="/docs#timezones">Timezone identifier</a> for this request (optional)</li>
|
||||
<li><b>offset</b> (integer) Timezone offset that results should be displayed in. Please use the <a href="/docs#timezones">timezone</a> parameter for greater accuracy. (optional)</li>
|
||||
<li><b>status</b> (true/false) Include status updates in feed by setting "status=true" (optional)</li>
|
||||
<li><b>metadata</b> (true/false) Include Channel's metadata by setting "metadata=true" (optional)</li>
|
||||
<li><b>location</b> (true/false) Include latitude, longitude, and elevation in feed by setting "location=true" (optional)</li>
|
||||
<li><b>min</b> (decimal) Minimum value to include in response (optional)</li>
|
||||
<li><b>max</b> (decimal) Maximum value to include in response (optional)</li>
|
||||
|
@ -18,6 +18,7 @@ Valid parameters:
|
||||
<li><b>timezone</b> (string) <a href="/docs#timezones">Timezone identifier</a> for this request (optional)</li>
|
||||
<li><b>offset</b> (integer) Timezone offset that results should be displayed in. Please use the <a href="/docs#timezones">timezone</a> parameter for greater accuracy. (optional)</li>
|
||||
<li><b>status</b> (true/false) Include status updates in feed by setting "status=true" (optional)</li>
|
||||
<li><b>metadata</b> (true/false) Include Channel's metadata by setting "metadata=true" (optional)</li>
|
||||
<li><b>location</b> (true/false) Include latitude, longitude, and elevation in feed by setting "location=true" (optional)</li>
|
||||
<li><b>min</b> (decimal) Minimum value to include in response (optional)</li>
|
||||
<li><b>max</b> (decimal) Maximum value to include in response (optional)</li>
|
||||
@ -166,8 +167,12 @@ Valid parameters:
|
||||
<li><b>status</b> (true/false) Include status updates in feed by setting "status=true" (optional)</li>
|
||||
<li><b>location</b> (true/false) Include latitude, longitude, and elevation in feed by setting "location=true" (optional)</li>
|
||||
<li><b>callback</b> (string) Function name to be used for JSONP cross-domain requests (optional)</li>
|
||||
<li class="format format-text"><b>prepend</b> (string) Text to add before the API response (optional)</li>
|
||||
<li class="format format-text"><b>append</b> (string) Text to add after the API response (optional)</li>
|
||||
<div class="format format-block-sm format-text">
|
||||
<li><b>prepend</b> (string) Text to add before the API response (optional)</li>
|
||||
<li><b>append</b> (string) Text to add after the API response (optional)</li>
|
||||
</div>
|
||||
<div class="format format-block-sm format-json"></div>
|
||||
<div class="format format-block-sm format-xml"></div>
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
|
Reference in New Issue
Block a user