cafepress_wrapper 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. data/Gemfile +33 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +33 -0
  5. data/app/controllers/content_controller.rb +26 -0
  6. data/app/controllers/products_controller.rb +30 -0
  7. data/app/controllers/sitemap_controller.rb +26 -0
  8. data/app/controllers/stores_controller.rb +37 -0
  9. data/app/models/image_url.rb +3 -0
  10. data/app/models/product.rb +89 -0
  11. data/app/models/size.rb +3 -0
  12. data/app/models/store.rb +91 -0
  13. data/app/models/user_token.rb +36 -0
  14. data/app/views/content/about.html.erb +71 -0
  15. data/app/views/content/contact.html.erb +30 -0
  16. data/app/views/layouts/cafepress_wrapper.html.erb +75 -0
  17. data/app/views/products/show.rjs +14 -0
  18. data/app/views/sitemap/index.xml.erb +39 -0
  19. data/app/views/stores/_front_back_image.html.erb +15 -0
  20. data/app/views/stores/_product_details.html.erb +71 -0
  21. data/app/views/stores/feed.rss.builder +43 -0
  22. data/app/views/stores/index.html.erb +45 -0
  23. data/app/views/stores/show.html.erb +83 -0
  24. data/config/initializers/cafepress.rb +23 -0
  25. data/config/routes.rb +13 -0
  26. data/lib/cafepress_wrapper.rb +21 -0
  27. data/lib/db/migrate/20101103152700_create_user_tokens.rb +13 -0
  28. data/lib/db/migrate/20101104032051_create_stores.rb +13 -0
  29. data/lib/db/migrate/20101104032412_create_products.rb +16 -0
  30. data/lib/db/migrate/20101111004355_add_description_to_store.rb +9 -0
  31. data/lib/db/migrate/20101111025931_add_cafepress_design_id_to_products.rb +9 -0
  32. data/lib/db/migrate/20101119163852_add_cafepress_design_url_to_stores.rb +9 -0
  33. data/lib/db/migrate/20101119171328_add_design_background_color_to_stores.rb +9 -0
  34. data/lib/db/migrate/20101120003908_add_cafepress_back_design_id_to_products.rb +9 -0
  35. data/lib/db/migrate/20101123021036_add_cafepress_back_design_url_to_stores.rb +9 -0
  36. data/lib/db/migrate/20110301072358_add_gender_to_products.rb +9 -0
  37. data/lib/db/migrate/20110302191748_create_thumbnail_urls.rb +14 -0
  38. data/lib/db/migrate/20110302195801_add_view_to_thumbnail_urls.rb +9 -0
  39. data/lib/db/migrate/20110305004142_rename_thumbnail_urls_to_image_urls.rb +9 -0
  40. data/lib/db/migrate/20110305004402_add_image_size_to_image_urls.rb +9 -0
  41. data/lib/db/migrate/20110307005237_add_cafepress_merchandise_id_to_products.rb +9 -0
  42. data/lib/db/migrate/20110307014703_add_default_color_id_to_products.rb +9 -0
  43. data/lib/db/migrate/20110307063709_create_sizes.rb +16 -0
  44. data/lib/db/migrate/20110307064131_add_default_cafepress_size_id_to_products.rb +9 -0
  45. data/lib/db/migrate/20110308010304_add_title_to_stores.rb +9 -0
  46. data/lib/db/migrate/20110308050955_add_price_to_products.rb +9 -0
  47. data/lib/tasks/cafepress_wrapper.rake +48 -0
  48. data/public/images/ajax-loader.gif +0 -0
  49. data/public/images/back_bg.png +0 -0
  50. data/public/images/cart.png +0 -0
  51. data/public/images/fabric_bg.png +0 -0
  52. data/public/images/footer_bg.png +0 -0
  53. data/public/images/front_bg.png +0 -0
  54. data/public/images/header_bg.png +0 -0
  55. data/public/javascripts/cafepress_wrapper.js +118 -0
  56. data/public/stylesheets/cafepress_wrapper.css +473 -0
  57. metadata +137 -0
@@ -0,0 +1,39 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
3
+ xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
4
+ <url>
5
+ <loc><%= root_url %></loc>
6
+ <changefreq>weekly</changefreq>
7
+ <priority>1.0</priority>
8
+ <% @stores.each do |store| %>
9
+ <% if store.cafepress_back_design_url %>
10
+ <image:image>
11
+ <image:loc><%= store.cafepress_design_url %></image:loc>
12
+ <image:caption><%= store.description %></image:caption>
13
+ <image:title><%= store.description %></image:title>
14
+ </image:image>
15
+ <image:image>
16
+ <image:loc><%= store.cafepress_back_design_url %></image:loc>
17
+ <image:caption><%= store.description %></image:caption>
18
+ <image:title><%= store.description %></image:title>
19
+ </image:image>
20
+ <% else %>
21
+ <image:image>
22
+ <image:loc><%= store.cafepress_design_url %></image:loc>
23
+ <image:caption><%= store.description %></image:caption>
24
+ <image:title><%= store.description %></image:title>
25
+ </image:image>
26
+ <% end %>
27
+ <% end %>
28
+ </url>
29
+ <url>
30
+ <loc><%= content_about_url %></loc>
31
+ <changefreq>monthly</changefreq>
32
+ <priority>0.5</priority>
33
+ </url>
34
+ <url>
35
+ <loc><%= content_contact_url %></loc>
36
+ <changefreq>monthly</changefreq>
37
+ <priority>0.5</priority>
38
+ </url>
39
+ </urlset>
@@ -0,0 +1,15 @@
1
+ <% if defined?(color_id) && color_id %>
2
+ <div class="front-image" style="display:none;">
3
+ <%= image_tag(product.front_image_url_for_color(params[:color_id]), :alt => '') %>
4
+ </div>
5
+ <div class="back-image" style="display:none;">
6
+ <%= image_tag(product.back_image_url_for_color(params[:color_id]), :alt => '') %>
7
+ </div>
8
+ <% else %>
9
+ <div class="front-image" style="display:none;">
10
+ <%= image_tag(product.default_front_image.url, :alt => '') %>
11
+ </div>
12
+ <div class="back-image" style="display:none;">
13
+ <%= image_tag(product.default_back_image.url, :alt => '') %>
14
+ </div>
15
+ <% end %>
@@ -0,0 +1,71 @@
1
+ <div id="image">
2
+ <% if product.has_back_design? %>
3
+ <%= render :partial => '/stores/front_back_image', :locals => {:product => product} %>
4
+ <% else %>
5
+ <%= image_tag(product.default_front_image.url, :alt => '') %>
6
+ <% end %>
7
+ </div>
8
+ <div id="info">
9
+ <%= form_tag(CafePressAPI::ADD_TO_CART_BASE_URL, {:method => :get, :onsubmit => 'return CPW.validate_quantity();'}) do %>
10
+ <%= hidden_field_tag('storeId', 'search') %>
11
+ <%= hidden_field_tag('keepshopping', store_url(product.store, :product_id => product.id)) %>
12
+ <div id="name">
13
+ <%= product.better_default_caption %>&nbsp;&nbsp;<span id="price">$<%= product.price %></span>
14
+ </div>
15
+ <div id="colors">
16
+ <div class="label">
17
+ Color:
18
+ </div>
19
+ <% if product.available_in_multiple_colors? %>
20
+ <div class="multiple_colors">
21
+ <% product.color_ids.each do |color_id| %>
22
+ <% link_to(product_path(product, :color_id => color_id, :id => "color_swatch_#{color_id}"), :remote => true, 'data-color_id' => color_id) do %>
23
+ <%= image_tag(CafePressAPI.lookup_swatch(color_id, product.cafepress_merchandise_id), :alt => '', :class => 'swatch') %>
24
+ <% end %>
25
+ <% end %>
26
+ </div>
27
+ <div id="color_names">
28
+ <% product.color_ids.each do |color_id| %>
29
+ <div class="color_description" id="color_<%= color_id %>_description" style="display:none;">&nbsp;<%= CafePressAPI::COLORS[color_id][:description] %></div>
30
+ <% end %>
31
+ </div>
32
+ <% else %>
33
+ <% if product.default_front_image.color_id == '0' %>
34
+ <div class="one_color">NO COLOR CHOICES</div>
35
+ <% else %>
36
+ <div class="one_color">ONLY AVAILABLE IN <%= CafePressAPI::COLORS[product.default_front_image.color_id][:description].upcase %></div>
37
+ <% end %>
38
+ <% end %>
39
+ <%= hidden_field_tag("color_#{product.cafepress_product_id}", product.default_color_id, :id => 'selected_color_id') %>
40
+ <div style="clear:both;"></div>
41
+ </div>
42
+ <% if product.has_sizes? %>
43
+ <div id="sizes">
44
+ <div class="label">
45
+ Size:
46
+ </div>
47
+ <div class="size_select">
48
+ <%= select_tag("size_#{product.cafepress_product_id}", options_for_select(product.sizes_array,product.default_cafepress_size_id)) %>
49
+ </div>
50
+ <div style="clear:both;"></div>
51
+ </div>
52
+ <% end %>
53
+ <div id="quantity">
54
+ <div class="label">
55
+ Quantity:
56
+ </div>
57
+ <div>
58
+ <%= text_field_tag("qty_#{product.cafepress_product_id}",'1', :onblur => 'CPW.force_numeric_quantity(this);') %>
59
+ </div>
60
+ </div>
61
+ <div id="more_info">
62
+ <%= link_to('More Product Info at CafePress', product.url, :target => '_cafepress') %>
63
+ </div>
64
+ <div id="add_to_cart">
65
+ <%= submit_tag('Add To Cart') %>
66
+ </div>
67
+ <% end %>
68
+ </div>
69
+ <div id="loading_image_icon">
70
+ <%= image_tag('ajax-loader.gif') %>
71
+ </div>
@@ -0,0 +1,43 @@
1
+ xml.instruct! :xml, :version => "1.0"
2
+ xml.rss :version => "2.0", 'xmlns:content' => 'http://purl.org/rss/1.0/modules/content/' do
3
+ xml.channel do
4
+ xml.title "Rockclimbingshirts.com - funny, awesome, and badass climbing shirts"
5
+ xml.description "Hilarious, sweet, and all around kickass shirts for every type of rock climber."
6
+ xml.link root_url
7
+
8
+ for store in @stores
9
+ xml.item do
10
+ xml.title truncate(store.description, :length => 50, :separator => ' ')
11
+ xml.description store.description
12
+ if store.cafepress_back_design_url
13
+ xml.tag! 'content:encoded' do
14
+ xml.cdata! %{
15
+ <a href="http://cafepress.com/#{store.cafepress_store_id}">
16
+ <img src="#{store.cafepress_design_url}"/>
17
+ </a>
18
+ <br/>
19
+ <a href="http://cafepress.com/#{store.cafepress_store_id}">
20
+ <img src=#{store.cafepress_back_design_url}/>
21
+ </a>
22
+ <br/>
23
+ <p>#{store.description}</p>
24
+ }
25
+ end
26
+ else
27
+ xml.tag! 'content:encoded' do
28
+ xml.cdata! %{
29
+ <a href="http://cafepress.com/#{store.cafepress_store_id}">
30
+ <img src="#{store.cafepress_design_url}"/>
31
+ </a>
32
+ <br/>
33
+ <p>#{store.description}</p>
34
+ }
35
+ end
36
+ end
37
+ xml.pubDate store.created_at
38
+ xml.link "http://cafepress.com/#{store.cafepress_store_id}"
39
+ xml.guid store.cafepress_store_id
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,45 @@
1
+ <%
2
+ # Copyright 2010 Benjamin Lee Smith <benjamin.lee.smith@gmail.com>
3
+ #
4
+ # This file is part of CafePress Wrapper.
5
+ # CafePress Wrapper is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # CafePress Wrapper is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with CafePress Wrapper. If not, see <http://www.gnu.org/licenses/>.
17
+ %>
18
+
19
+ <% content_for :title, 'funny, awesome, and badass climbing shirts' %>
20
+ <script type="text/javascript">
21
+ document.observe("dom:loaded", function() {
22
+ setTimeout('CPW.cycle_images();', CPW.cycle_speed);
23
+ });
24
+ </script>
25
+ <div id="stores">
26
+ <% @stores.each do |store| %>
27
+ <%= link_to store_path(store) do %>
28
+ <div class="store">
29
+ <% if store.cafepress_back_design_url %>
30
+ <div class="front-image" style="background-color:#<%= store.design_background_color %>;">
31
+ <%= image_tag(store.cafepress_design_url, :align => 'middle', :alt => store.description, :title => store.description) %>
32
+ </div>
33
+ <div class="back-image" style="background-color:#<%= store.design_background_color %>;display:none;">
34
+ <%= image_tag(store.cafepress_back_design_url, :align => 'middle', :alt => store.description, :title => store.description) %>
35
+ </div>
36
+ <% else %>
37
+ <div class="image" style="background-color:#<%= store.design_background_color %>;">
38
+ <%= image_tag(store.cafepress_design_url, :align => 'middle', :alt => store.description, :title => store.description) %>
39
+ </div>
40
+ <% end %>
41
+ </div>
42
+ <% end %>
43
+ <% end %>
44
+ <div class="clear"></div>
45
+ </div>
@@ -0,0 +1,83 @@
1
+ <%
2
+ # Copyright 2010 Benjamin Lee Smith <benjamin.lee.smith@gmail.com>
3
+ #
4
+ # This file is part of CafePress Wrapper.
5
+ # CafePress Wrapper is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # CafePress Wrapper is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with CafePress Wrapper. If not, see <http://www.gnu.org/licenses/>.
17
+ %>
18
+ <% content_for :title, @store.title %>
19
+ <script type="text/javascript">
20
+ document.observe("dom:loaded", function() {
21
+ Event.observe(window,'scroll', function(evt){
22
+ CPW.update_moving_div();
23
+ });
24
+
25
+ CPW.bind_color_name_events();
26
+ });
27
+
28
+ Event.observe(window, 'load', function() {
29
+ CPW.cycle_speed = 4000;
30
+ CPW.front_images_shown = false;
31
+ setTimeout('CPW.cycle_images();', CPW.cycle_speed);
32
+ });
33
+ </script>
34
+ <div id="active_product">
35
+ &nbsp;
36
+ <div id="moving_div">
37
+ <%= render :partial => 'product_details', :locals => {:product => @product} %>
38
+ </div>
39
+ </div>
40
+ <div id="products">
41
+ <table id="mens_and_womens" cellspacing="4px">
42
+ <tr>
43
+ <% if @store.mens_products.length > 0 %>
44
+ <td id="mens">
45
+ <h2>MEN'S</h2>
46
+ <div class="thumbnails">
47
+ <% @store.mens_products.each do |product| %>
48
+ <%= link_to(product_path(product), :remote => true) do %>
49
+ <%= image_tag(product.default_front_thumbnail_url, :alt => '') %>
50
+ <% end %>
51
+ <% end %>
52
+ </div>
53
+ </td>
54
+ <% end %>
55
+ <% if @store.womens_products.length > 0 %>
56
+ <td id="womens">
57
+ <h2>WOMEN'S</h2>
58
+ <div class="thumbnails">
59
+ <% @store.womens_products.each do |product| %>
60
+ <%= link_to(product_path(product), :remote => true) do %>
61
+ <%= image_tag(product.default_front_thumbnail_url, :alt => '') %>
62
+ <% end %>
63
+ <% end %>
64
+ </div>
65
+ </td>
66
+ <% end %>
67
+ </tr>
68
+ </table>
69
+
70
+ <% if @store.unisex_products.length > 0 %>
71
+ <div id="unisex">
72
+ <h2>UNISEX</h2>
73
+ <div class="thumbnails">
74
+ <% @store.unisex_products.each do |product| %>
75
+ <%= link_to(product_path(product), :remote => true) do %>
76
+ <%= image_tag(product.default_front_thumbnail_url, :alt => '') %>
77
+ <% end %>
78
+ <% end %>
79
+ </div>
80
+ </div>
81
+ <% end %>
82
+ </div>
83
+ <div style="clear:both;"></div>
@@ -0,0 +1,23 @@
1
+ # Copyright 2010 Benjamin Lee Smith <benjamin.lee.smith@gmail.com>
2
+ #
3
+ # This file is part of CafePress Wrapper.
4
+ # CafePress Wrapper is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # CafePress Wrapper is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with CafePress Wrapper. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ begin
18
+ ::CAFEPRESS_CONFIG = YAML.load_file("#{::Rails.root.to_s}/config/cafepress.yml")[::Rails.env]
19
+ rescue
20
+ ::CAFEPRESS_CONFIG = {
21
+ 'google_analytics' => ENV['cp_google_analytics']
22
+ }
23
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,13 @@
1
+ Rails.application.routes.draw do |map|
2
+ get "content/about"
3
+
4
+ get "content/contact"
5
+
6
+ resources :stores
7
+ resources :products
8
+
9
+ root :to => "stores#index"
10
+
11
+ match '/sitemap', :controller => 'sitemap', :action => :index
12
+ match '/feed', :controller => 'stores', :action => :feed
13
+ end
@@ -0,0 +1,21 @@
1
+ require 'cafepress_api'
2
+
3
+ # %w{ models controllers }.each do |dir|
4
+ # path = File.join(File.dirname(__FILE__), 'app', dir)
5
+ # $LOAD_PATH << path
6
+ # ActiveSupport::Dependencies.autoload_paths << path
7
+ # ActiveSupport::Dependencies.autoload_once_paths.delete(path)
8
+ # end
9
+
10
+ module CafepressWrapper
11
+ class Engine < Rails::Engine
12
+ # Dir[File.join(File.dirname(__FILE__),'../app/models/*.rb')].each {|f| config.autoload_paths += f }
13
+ # Dir[File.join(File.dirname(__FILE__),'../app/controllers/*.rb')].each {|f| config.autoload_paths += f }
14
+ config.autoload_paths << File.join(File.dirname(__FILE__),'../app/models/')
15
+ config.autoload_paths << File.join(File.dirname(__FILE__),'../app/controllers/')
16
+
17
+ rake_tasks do
18
+ load File.join(File.dirname(__FILE__), 'tasks/cafepress_wrapper.rake')
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ class CreateUserTokens < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :user_tokens do |t|
4
+ t.string :token
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :user_tokens
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class CreateStores < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :stores do |t|
4
+ t.string :cafepress_store_id
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :stores
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ class CreateProducts < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :products do |t|
4
+ t.string :name
5
+ t.string :default_caption
6
+ t.string :url
7
+ t.integer :store_id
8
+ t.string :cafepress_product_id
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :products
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ class AddDescriptionToStore < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :stores, :description, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :stores, :description
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddCafepressDesignIdToProducts < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :products, :cafepress_design_id, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :products, :cafepress_design_id
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddCafepressDesignUrlToStores < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :stores, :cafepress_design_url, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :stores, :cafepress_design_url
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddDesignBackgroundColorToStores < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :stores, :design_background_color, :string, :default => 'FFFFFF'
4
+ end
5
+
6
+ def self.down
7
+ remove_column :stores, :design_background_color
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddCafepressBackDesignIdToProducts < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :products, :cafepress_back_design_id, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :products, :cafepress_back_design_id
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddCafepressBackDesignUrlToStores < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :stores, :cafepress_back_design_url, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :stores, :cafepress_back_design_url
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddGenderToProducts < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :products, :gender, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :products, :gender
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ class CreateThumbnailUrls < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :thumbnail_urls do |t|
4
+ t.string :url
5
+ t.string :color_id
6
+ t.integer :product_id
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :thumbnail_urls
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class AddViewToThumbnailUrls < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :thumbnail_urls, :view, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :thumbnail_urls, :view
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class RenameThumbnailUrlsToImageUrls < ActiveRecord::Migration
2
+ def self.up
3
+ rename_table :thumbnail_urls, :image_urls
4
+ end
5
+
6
+ def self.down
7
+ rename_table :image_urls, :thumbnail_urls
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddImageSizeToImageUrls < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :image_urls, :size, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :image_urls, :size
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddCafepressMerchandiseIdToProducts < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :products, :cafepress_merchandise_id, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :products, :cafepress_merchandise_id
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddDefaultColorIdToProducts < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :products, :default_color_id, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :products, :default_color_id
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ class CreateSizes < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :sizes do |t|
4
+ t.integer :product_id
5
+ t.string :cafepress_size_id
6
+ t.string :full_name
7
+ t.string :display_sell_price
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ drop_table :sizes
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ class AddDefaultCafepressSizeIdToProducts < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :products, :default_cafepress_size_id, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :products, :default_cafepress_size_id
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddTitleToStores < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :stores, :title, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :stores, :title
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddPriceToProducts < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :products, :price, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :products, :price
8
+ end
9
+ end
@@ -0,0 +1,48 @@
1
+ namespace :db do
2
+ namespace :migrate do
3
+ description = "Migrate the database through scripts in vendor/plugins/cafepress_wrapper/lib/db/migrate"
4
+ description << "and update db/schema.rb by invoking db:schema:dump."
5
+ description << "Target specific version with VERSION=x. Turn off output with VERBOSE=false."
6
+
7
+ desc description
8
+ task :cafepress_wrapper => :environment do
9
+ ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
10
+ ActiveRecord::Migrator.migrate(File.join(File.dirname(__FILE__),'../db/migrate/'), ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
11
+ Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
12
+ end
13
+ end
14
+ end
15
+
16
+ namespace :cafepress_wrapper do
17
+ desc "Reload all cafepress data"
18
+ task :reload_data => :environment do
19
+ Store.load_all_stores_cafepress_data
20
+ end
21
+
22
+ namespace :install do
23
+ def copy_files(source, destination)
24
+ FileUtils.cp_r((Dir.entries(source) - ['.', '..']).collect{|s| "#{source}/#{s}"}, destination)
25
+ end
26
+
27
+ desc 'Copy static assets (images, javascript and stylesheets), into public direction'
28
+ task :assets => :environment do
29
+ source = File.join(File.dirname(__FILE__), '..', '..', 'public', 'images')
30
+ destination = File.join(Rails.root, 'public', 'images')
31
+ copy_files(source, destination)
32
+
33
+ source = File.join(File.dirname(__FILE__), '..', '..', 'public', 'javascripts')
34
+ destination = File.join(Rails.root, 'public', 'javascripts')
35
+ copy_files(source, destination)
36
+
37
+ source = File.join(File.dirname(__FILE__), '..', '..', 'public', 'stylesheets')
38
+ destination = File.join(Rails.root, 'public', 'stylesheets')
39
+ copy_files(source, destination)
40
+ end
41
+ end
42
+ end
43
+
44
+ desc "This task is called by the Heroku cron add-on"
45
+ task :cron => :environment do
46
+ puts 'reloading all store data'
47
+ Store.load_all_stores_cafepress_data
48
+ end
Binary file
Binary file
Binary file
Binary file