OSDN Git Service

t#:31222
authoryasushiito <yas@pen-chan.jp>
Fri, 3 May 2013 10:25:19 +0000 (19:25 +0900)
committeryasushiito <yas@pen-chan.jp>
Fri, 3 May 2013 10:25:19 +0000 (19:25 +0900)
27 files changed:
app/controllers/panels_controller.rb
app/models/balloon.rb
app/models/ground_color.rb
app/models/ground_picture.rb
app/models/panel.rb
app/models/panel_color.rb
app/models/panel_picture.rb
app/models/speech.rb
app/models/speech_balloon.rb
app/views/panels/index.atom.builder [new file with mode: 0644]
app/views/panels/index.html.erb
app/views/panels/index.rss.builder [new file with mode: 0644]
config/profile.json.org
db/migrate/20130503090911_add_caption_on_panels.rb [new file with mode: 0644]
public/assets/StandardA.gif [deleted file]
public/assets/StandardB.gif [deleted file]
public/assets/TestA.gif [deleted file]
public/assets/TestB.gif [deleted file]
public/assets/black_50pct.gif [deleted file]
public/assets/black_50pct.png [deleted file]
public/assets/error.png [deleted file]
public/assets/grid.gif [deleted file]
public/assets/loading.gif [deleted file]
public/assets/manifest.yml [deleted file]
public/assets/opacity0.gif [deleted file]
public/assets/sprite.gif [deleted file]
public/assets/white_70pct.png [deleted file]

index 3757298..2804bad 100644 (file)
@@ -20,6 +20,8 @@ class PanelsController < ApplicationController
     respond_to do |format|
       format.html # index.html.erb
       format.json { render text: Panel.list_as_json_text(@panels) }
+      format.atom 
+      format.rss { render :layout => false }
     end
   end
 
index 7d4de0e..94e325b 100644 (file)
@@ -87,4 +87,20 @@ class Balloon < ActiveRecord::Base
     {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :speeches => {}, :speech_balloon_template => {} }}}}
   end
   
+  def scenario
+    if caption.blank?
+      ''
+    else
+      '<p>' + ERB::Util.html_escape(self.caption) + '</p>'
+    end
+  end
+  
+  def plain_scenario
+    if caption.blank?
+      ''
+    else
+      self.caption + "\n"
+    end
+  end
+  
 end
index b89e698..aac711b 100644 (file)
@@ -83,4 +83,8 @@ class GroundColor < ActiveRecord::Base
     {:include => {:panel => {:include => {:author => {}}}, :color => {} }}
   end
   
+  def scenario
+    ''
+  end
+  
 end
index bda16d3..ca716c0 100644 (file)
@@ -89,4 +89,8 @@ class GroundPicture < ActiveRecord::Base
     {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }}
   end
   
+  def scenario
+    ''
+  end
+  
 end
index 3ff90f6..208def0 100644 (file)
@@ -200,6 +200,18 @@ class Panel < ActiveRecord::Base
     '[' + ary.map {|i| i.panel_elements_as_json }.join(',') + ']'
   end
   
+  def scenario
+    panel_elements.map { |e|
+      e.scenario
+    }.join
+  end
+  
+  def plain_scenario
+    panel_elements.map { |e|
+      e.plain_scenario
+    }.join
+  end
+  
   def licensed_pictures
     r = {}
     ((self.panel_pictures || []) + (self.ground_pictures || [])).compact.each do |elm|
index 6683029..8668724 100644 (file)
@@ -82,4 +82,8 @@ class PanelColor < ActiveRecord::Base
     {:include => {:panel => {:include => {:author => {}}} }}
   end
   
+  def scenario
+    ''
+  end
+  
 end
index 907e1a7..d4720ce 100644 (file)
@@ -115,4 +115,20 @@ class PanelPicture < ActiveRecord::Base
     {:include => {:panel => {:include => {:author => {}}}, :picture => {:include => {:artist => {}, :license => {}}} }}
   end
   
+  def scenario
+    if caption.blank?
+      ''
+    else
+      '<p>' + ERB::Util.html_escape(self.caption) + '</p>'
+    end
+  end
+  
+  def plain_scenario
+    if caption.blank?
+      ''
+    else
+      self.caption + "\n"
+    end
+  end
+  
 end
index fbc9738..750e5f5 100644 (file)
@@ -80,4 +80,20 @@ class Speech < ActiveRecord::Base
     {:include => {:speech_balloon => {:include => {:panel => {:include => {:author => {} }}, :balloons => {}, :speech_balloon_template => {} }}}}
   end
   
+  def scenario
+    if content.blank?
+      ''
+    else
+      '<p>' + ERB::Util.html_escape(self.content) + '</p>'
+    end
+  end
+  
+  def plain_scenario
+    if content.blank?
+      ''
+    else
+      self.content + "\n"
+    end
+  end
+  
 end
index c4a7273..31a54bd 100644 (file)
@@ -86,4 +86,14 @@ class SpeechBalloon < ActiveRecord::Base
     {:include => {:panel => {:include => {:author => {} }}, :balloons => {}, :speeches => {}, :speech_balloon_template => {} }}
   end
   
+  def scenario
+    balloons.first.scenario.to_s + 
+    speeches.map {|s| s.scenario }.join
+  end
+  
+  def plain_scenario
+    balloons.first.plain_scenario.to_s + 
+    speeches.map {|s| s.plain_scenario }.join
+  end
+  
 end
diff --git a/app/views/panels/index.atom.builder b/app/views/panels/index.atom.builder
new file mode 100644 (file)
index 0000000..d26b763
--- /dev/null
@@ -0,0 +1,25 @@
+atom_feed(
+  :language => 'ja-JP',
+  :root_url => root_url,
+  :url => root_url(:format => :atom),
+  :id => root_url
+) do |feed|
+  feed.title MagicNumber['profile']['users']['caption']
+  feed.subtitle sanitize(MagicNumber['profile']['users']['description'], :tags => %w(a p img br))
+  feed.updated Time.now
+  feed.author {|author| author.name(MagicNumber['profile']['web_master'])}
+
+  @panels.each do |panel|
+    feed.entry(
+      panel,
+      :url => panel_url(panel),
+      :id => panel_url(panel),
+      :published => panel.updated_at,
+      :updated => panel.updated_at
+    ) do |item|
+      item.title(panel.caption)
+      item.content(panel.scenario, :type => 'html')
+      item.author {|author| author.name(panel.author.name)}
+    end
+  end
+end
index 0f61452..9f511b9 100644 (file)
@@ -3,3 +3,8 @@
   <%= render 'standard', :panel => panel, :author => @author %>
 <% end %>
 <%= link_to t('panels.new.title'), new_panel_path %>
+<noscript>
+  <% @panels.each do |panel| %>
+    <%= raw panel.scenario %>
+  <% end %>
+</noscript> 
diff --git a/app/views/panels/index.rss.builder b/app/views/panels/index.rss.builder
new file mode 100644 (file)
index 0000000..f60f243
--- /dev/null
@@ -0,0 +1,24 @@
+xml.instruct!
+xml.rss("version"    => "2.0",
+        "xmlns:dc"   => "http://purl.org/dc/elements/1.1/",
+        "xmlns:atom" => "http://www.w3.org/2005/Atom") do
+  xml.channel do
+    xml.title       MagicNumber['profile']['users']['caption']
+    xml.link        root_url
+    xml.pubDate     Time.now.rfc822
+    xml.description sanitize(MagicNumber['profile']['users']['description'], :tags => %w(a p img br))
+    xml.atom :link, "href" => @rss_url, "rel" => "self", "type" => "application/rss+xml"
+    @panels.each do |panel|
+      xml.item do
+        xml.title        panel.caption
+        xml.link         panel_url(panel)
+        xml.guid         panel_url(panel)
+        xml.description  panel.plain_scenario
+        xml.pubDate      panel.updated_at.to_formatted_s(:rfc822)
+        xml.dc :creator, panel.author.name
+      end
+    end
+  end
+end
index 4c661c2..6712717 100644 (file)
@@ -1,5 +1,6 @@
 {
   "admin@mail.address": {
+    "web_master": "yas",
     "users": {
       "caption": "site name",
       "url": "http://your.site.url/", 
diff --git a/db/migrate/20130503090911_add_caption_on_panels.rb b/db/migrate/20130503090911_add_caption_on_panels.rb
new file mode 100644 (file)
index 0000000..41292f7
--- /dev/null
@@ -0,0 +1,9 @@
+class AddCaptionOnPanels < ActiveRecord::Migration
+  def up
+    add_column :panels, :caption, :string
+  end
+
+  def down
+    remove_column :panels, :caption
+  end
+end
diff --git a/public/assets/StandardA.gif b/public/assets/StandardA.gif
deleted file mode 100644 (file)
index 35f3ae4..0000000
Binary files a/public/assets/StandardA.gif and /dev/null differ
diff --git a/public/assets/StandardB.gif b/public/assets/StandardB.gif
deleted file mode 100644 (file)
index b870b03..0000000
Binary files a/public/assets/StandardB.gif and /dev/null differ
diff --git a/public/assets/TestA.gif b/public/assets/TestA.gif
deleted file mode 100644 (file)
index 9964637..0000000
Binary files a/public/assets/TestA.gif and /dev/null differ
diff --git a/public/assets/TestB.gif b/public/assets/TestB.gif
deleted file mode 100644 (file)
index eac0b5c..0000000
Binary files a/public/assets/TestB.gif and /dev/null differ
diff --git a/public/assets/black_50pct.gif b/public/assets/black_50pct.gif
deleted file mode 100644 (file)
index 6f0aa3a..0000000
Binary files a/public/assets/black_50pct.gif and /dev/null differ
diff --git a/public/assets/black_50pct.png b/public/assets/black_50pct.png
deleted file mode 100644 (file)
index 1c45771..0000000
Binary files a/public/assets/black_50pct.png and /dev/null differ
diff --git a/public/assets/error.png b/public/assets/error.png
deleted file mode 100644 (file)
index 10c0345..0000000
Binary files a/public/assets/error.png and /dev/null differ
diff --git a/public/assets/grid.gif b/public/assets/grid.gif
deleted file mode 100644 (file)
index 5eb20fd..0000000
Binary files a/public/assets/grid.gif and /dev/null differ
diff --git a/public/assets/loading.gif b/public/assets/loading.gif
deleted file mode 100644 (file)
index f864d5f..0000000
Binary files a/public/assets/loading.gif and /dev/null differ
diff --git a/public/assets/manifest.yml b/public/assets/manifest.yml
deleted file mode 100644 (file)
index 1344098..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
----
-error.png: error.png
-folder_album.png: folder_album.png
-folder_general.png: folder_general.png
-grid.gif: grid.gif
-loading.gif: loading.gif
-opacity0.gif: opacity0.gif
-rails.png: rails.png
-sprite.gif: sprite.gif
-application.js: application.js
-application.css: application.css
diff --git a/public/assets/opacity0.gif b/public/assets/opacity0.gif
deleted file mode 100644 (file)
index cfc751a..0000000
Binary files a/public/assets/opacity0.gif and /dev/null differ
diff --git a/public/assets/sprite.gif b/public/assets/sprite.gif
deleted file mode 100644 (file)
index f9d445d..0000000
Binary files a/public/assets/sprite.gif and /dev/null differ
diff --git a/public/assets/white_70pct.png b/public/assets/white_70pct.png
deleted file mode 100644 (file)
index 0b471c2..0000000
Binary files a/public/assets/white_70pct.png and /dev/null differ