1 Commits

Author SHA1 Message Date
Michael Bianco
40bb298bc8 Updating documentation. Adding nginx send_file info 2012-11-06 11:35:30 -05:00
17 changed files with 43 additions and 92 deletions

View File

@@ -9,4 +9,4 @@ group :test do
end
end
gem 'spree', '~> 1.3.2'
gem 'spree', '~> 1.1.3'

View File

@@ -1,5 +1,4 @@
"0.7.x" => { :ref => "eddaea63959586d123007cbca3be5bf9c5edb1a7" }
"1.0.x" => { :ref => "a8c27750ef1cf9d0ad1a2a6ebe33307da900a5c1" }
"1.1.x" => { :branch => "1-1-stable" }
"1.2.x" => { :ref => "9360c635039aaeeee18026b830aa96cc7587cd0d" }
"1.3.x" => { :branch => "master" }
"1.2.x" => { :branch => "master" }

View File

@@ -1,6 +1,6 @@
module Spree
class Admin::DigitalsController < Spree::Admin::ResourceController
belongs_to "spree/product", :find_by => :permalink
belongs_to "spree/product", find_by: :permalink
protected
def location_after_save

View File

@@ -1,7 +0,0 @@
Spree::Admin::OrdersController.class_eval do
def reset_digitals
@order.reset_digital_links!
flash[:notice] = t(:downloads_reset)
redirect_to admin_order_url(@order)
end
end

View File

@@ -1,7 +1,7 @@
module Spree
class DigitalsController < Spree::StoreController
class DigitalsController < Spree::BaseController
ssl_required :show
def show
link = DigitalLink.find_by_secret(params[:secret])
@@ -19,9 +19,9 @@ module Spree
Rails.logger.error "Missing Digital Item: #{attachment.path}"
end
end
render :unauthorized
end
end
end

View File

@@ -9,7 +9,7 @@ Spree::LineItem.class_eval do
private
# TODO there is no reason to create the digital links until the order is complete
# Create the download link for this item if it is digital.
def create_digital_links
digital_links.delete_all

View File

@@ -10,14 +10,8 @@ Spree::Order.class_eval do
false
end
def reset_digital_links!
line_items.select(&:digital?).map(&:digital_links).flatten.each do |digital_link|
digital_link.update_column :access_counter, 0
digital_link.update_column :created_at, Time.now
end
end
# UPGRADE_CHECK this works as of spree 1.1.1; make sure to check the original function on upgrade
# UPGRADE_CHECK this works as of spree 1.2.0. check function for changes on upgrade
def available_shipping_methods(display_on = nil)
return [] unless ship_address
all_methods = Spree::ShippingMethod.all_available(self, display_on)

View File

@@ -1,7 +0,0 @@
Deface::Override.new(:virtual_path => "spree/admin/shared/_order_tabs",
:name => "add_reset_digitals_to_admin_orders",
:insert_after => ".sidebar",
:text => %q{
<%= content_tag(:p, button_link_to(t(:reset_downloads), reset_digitals_admin_order_url(@order)), class: 'clear') if @order.digital? or true %>
},
:disabled => false)

View File

@@ -1,9 +0,0 @@
<% if defined?(SpreeFancy) %>
<% content_for :subheader do %>
<h1><%= t('.unauthorized') %></h1>
<% end %>
<% else %>
<h1><%= t('.unauthorized') %></h1>
<% end %>
<%= t('.explained') %>

View File

@@ -1,7 +1,9 @@
en:
broken_file: Warning! this file is broken
digital_versions: Digital Versions
current_file: Current File
new_file: New File
delete_file: Delete this file
broken_file: Warning! this file is broken
delete_file_cofirmation: Are you sure you want to delete the file %{filename}?
digital_delivery: Digital Delivery
digital_download: Download %{type} ↓
@@ -11,14 +13,5 @@ en:
mobi: Kindle eBook
epub: ePub eBook
pdf: pdf eBook
digital_versions: Digital Versions
downloads_reset: Digital Downloads Reset
new_file: New File
reset_downloads: Reset Digital Downloads
spree:
digitals:
unauthorized:
explained: This download link has expired.
unauthorized: Unauthorized
spree_digital:
upload: Upload
upload: Upload

View File

@@ -1,7 +1,9 @@
it:
broken_file: Attenzione! questo file sembra essere rotto
digital_versions: Versioni Digitali
current_file: File Corrente
new_file: Nuovo File
delete_file: Elimina questo file
broken_file: Attenzione! questo file sembra essere rotto
delete_file_cofirmation: Sei sicuro di voler eliminare il file %{filename}?
digital_delivery: Consegna Digitale
digital_download: Download %{type} ↓
@@ -11,12 +13,6 @@ it:
mobi: Kindle eBook
epub: ePub eBook
pdf: pdf eBook
digital_versions: Versioni Digitali
new_file: Nuovo File
spree:
digitals:
unauthorized:
explained: This download link has expired.
unauthorized: Unauthorized
spree_digital:
upload: Upload
upload: Upload

View File

@@ -1,14 +1,12 @@
ja:
broken_file: 注意! このファイルが壊れている!
current_file: 現在のバージョン
delete_file: このファイルを削除
delete_file_cofirmation: 本当に「%{filename}」を削除しても宜しいですか?
digital_shipping: ダウンロードリンクを<strong>%{email}</strong>に送ります
digital_versions: デジタル版
current_file: 現在のバージョン
new_file: 新しいファイル
spree:
digitals:
unauthorized:
explained: This download link has expired.
unauthorized: Unauthorized
upload: アップロード
delete_file: このファイルを削除
broken_file: 注意! このファイルが壊れている!
delete_file_cofirmation: 本当に「%{filename}」を削除しても宜しいですか?
digital_shipping: ダウンロードリンクを<strong>%{email}</strong>に送ります

View File

@@ -3,13 +3,8 @@ Spree::Core::Engine.routes.draw do
resources :products do
resources :digitals
end
resources :orders do
member do
get :reset_digitals
end
end
end
get '/digital/:secret', :to => 'digitals#show', :via => :get, :as => 'digital', :constraints => { :secret => /[a-zA-Z0-9]{30}/ }
end
end

View File

@@ -17,20 +17,20 @@ The idea is simple. You attach a file to a Product (or a Variant of this Product
* The file `views/order_mailer/confirm_email.text.erb` is the only thing that should need customization. If you are looking for HTML emails, [this branch of spree-html-email](http://github.com/iloveitaly/spree-html-email) supports spree_digital
* A purchased product can be downloaded even if you disable the product immediately. You would have to remove the attached file in your admin section to prevent people from downloading purchased products.
* File are uploaded to `rails_root/private`. Make sure it's symlinked in case you're using Capistrano. If you want to change the upload path, [check out this gist](https://gist.github.com/3187793#file_spree_digital_path_change_decorator.rb)
* You must add a `views/spree/digitals/unauthorized.html.erb` file to customize an error message to the user if they exceed the download / days limit
* You must add a `views/spree/digitals/unauthorized.html.erb` file to present an error message to the user if they exceed the download / days limit
* We use send_file to send the files on download. See below for instructions on how to push file downloading off to nginx.
## Installation
Add this line to your gemfile:
```shell
```
gem 'spree_digital', :git => 'git://github.com/halo/spree_digital.git', :branch => 'master'
```
The following terminal commands will copy the migration files to the corresponding directory in your Rails application and apply the migrations to your database.
```shell
```
bundle exec rails g spree_digital:install
bundle exec rake db:migrate
```
@@ -104,14 +104,14 @@ References:
Get the spree framework and spree_digital extension for it:
```shell
```
git clone git://github.com/spree/spree.git
git clone git://github.com/halo/spree_digital.git
```
Go into the spree directory and run the bundle command:
```shell
```
cd spree
bundle install
```
@@ -120,19 +120,19 @@ Go into the spree_digital directory and do the same:
NOTE: At this point you may need to uncomment the stuff in the `Gemfile` before you can start developing and testing!
```shell
```
cd spree_digital
bundle install
```
Bring up the test application (you only need to do this whenever you fiddle around with the migrations) and then you can run the tests as you please.
```shell
```
rake test_app
rake spec
```
This link may be very helpful to you: [http://github.com/spree/spree](http://github.com/spree/spree)
This link may be very helpful to you: "http://github.com/spree/spree":http://github.com/spree/spree
### Authors
@@ -143,4 +143,4 @@ This link may be very helpful to you: [http://github.com/spree/spree](http://git
Copyright (c) 2011 funkensturm.
Released under the MIT License
See [LICENSE](http://github.com/funkensturm/spree_digital/blob/master/LICENSE)
See [LICENSE](http://github.com/funkensturm/spree_digital/blob/master/LICENSE)

View File

@@ -2,8 +2,5 @@ FactoryGirl.define do
factory :digital, :class => Spree::Digital do |f|
# TODO good to assign variant association if no association is manually defined
# f.variant { |p| p.association(:variant) }
attachment_content_type 'application/octet-stream'
attachment_file_name 'a_great_book.epub'
end
end

View File

@@ -1,14 +1,16 @@
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rspec/rails'
require 'database_cleaner'
require 'ffaker'
require 'shoulda-matchers'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
require 'spree/core/testing_support/factories'
require 'spree/core/testing_support/env'
require 'spree/core/testing_support/controller_requests'
require 'spree/core/url_helpers'
@@ -19,6 +21,7 @@ RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
config.include Spree::Core::UrlHelpers
config.include Spree::Core::TestingSupport::ControllerRequests
config.include Devise::TestHelpers, :type => :controller
config.use_transactional_fixtures = false
config.before(:each) do

View File

@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
s.name = 'spree_digital'
s.version = '1.1.1'
s.summary = ''
s.description = 'Digital download functionality for spree'
s.description = 'Add digital download functionality to spree'
s.authors = ['funkensturm', 'Michael Bianco']
s.email = ['info@cliffsidedev.com']
s.homepage = 'http://www.funkensturm.com'
@@ -12,8 +12,7 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
s.required_ruby_version = '>= 1.8.7'
s.add_dependency 'spree_core', '~> 1.3.0'
s.add_dependency 'spree_core', '>= 1.1.0'
# test suite
s.add_development_dependency 'shoulda-matchers'