public
Description: open-source e-commerce built on merb
Clone URL: git://github.com/myabc/merb_mart.git
Search Repo:
Click here to lend your support to: merb_mart and make a donation at www.pledgie.com !
Cleanup, merge in changes to merb-core 0.9.3 (retry)

* Merge in changes in merb-core, based on a newly
  generated merb-core 0.9.3 generated app.
  - Various small changes, including new rake env.
  - New autotest/ directory. Deleted out .autotest.
* Added in a couple missing methods provided by
  merbful_authentication generator. Fixed missing
  activation code routes.
* Update list of dependencies in INSTALL and versions.
* Reorganize code in init.rb for clarity. Add FIXMEs.
* Uncomment validations and hooks in User.
* Added GPL header to init.rb.
* Updated copyright year to 2008.
myabc (author)
Wed May 07 11:54:35 -0700 2008
commit  824c2621e5e5efabb05d72feb1cc075cec0364a6
tree    6eb1e68e8b082874398b120b7f10bbce31417903
parent  a0d702a31bb42755f1fefff3da339aa05473588e
...
27
28
29
30
31
32
 
 
 
 
 
 
33
34
35
...
27
28
29
 
 
 
30
31
32
33
34
35
36
37
38
0
@@ -27,9 +27,12 @@ Dependencies for MerbMart:
0
         * *merb\_datamapper*
0
         (do not use the *merb\_datamapper* included in the 0.9.2 distribution of
0
          *merb_plugins*, as it was designed for DataMapper 0.3 series)
0
- * **Merb 0.9.2** (or above)
0
- * *merb-core* : `sudo gem install merb-core`
0
- * *merb-more* : `sudo gem install merb-more`
0
+ * **Merb 0.9.3** (or above)
0
+ * *merb-core* : `sudo gem install merb-core`
0
+ * *merb-more* : `sudo gem install merb-more`
0
+ * *merb\_plugins*
0
+ * *merb\_helpers* : `sudo gem install merb_helpers`
0
+ * *merb\_stories* : `sudo gem install merb_stories`
0
     
0
 Running Specs
0
 -------------
...
62
63
64
65
 
66
67
68
...
62
63
64
 
65
66
67
68
0
@@ -62,7 +62,7 @@ Copyright and License
0
 
0
 MerbMart is licensed under the **GNU Public License (GPL)**:
0
 
0
- > Copyright (C) 2007 Alex Coles
0
+ > Copyright (C) 2008 Alex Coles
0
 
0
    > This program is free software: you can redistribute it and/or modify
0
    > it under the terms of the GNU General Public License as published by
...
27
28
29
30
31
 
32
33
34
35
36
 
37
38
39
40
41
42
43
44
45
 
 
46
47
48
...
27
28
29
 
 
30
31
32
33
 
 
34
35
36
37
38
39
40
 
 
 
41
42
43
44
45
0
@@ -27,22 +27,19 @@ class User
0
   property :updated_at, DateTime
0
   
0
   validates_length_of :login, :within => 3..40
0
- # FIXME: fix validates_uniqueness_of
0
- #validates_uniqueness_of :login
0
+ validates_uniqueness_of :login
0
   validates_presence_of :email
0
   validates_format_of :email, :as => :email_address
0
   validates_length_of :email, :within => 3..100
0
- # FIXME: fix validates_uniqueness_of
0
- #validates_uniqueness_of :email
0
+ validates_uniqueness_of :email
0
   validates_presence_of :password, :if => proc {password_required?}
0
   validates_presence_of :password_confirmation, :if => proc {password_required?}
0
   validates_length_of :password, :within => 4..40, :if => proc {password_required?}
0
   validates_confirmation_of :password, :groups => :create
0
   
0
   before :save, :encrypt_password
0
- # FIXME
0
- #before :create, :make_activation_code
0
- #after :create, :send_signup_notification
0
+ before_class_method :create, :make_activation_code
0
+ after_class_method :create, :send_signup_notification
0
   
0
   def login=(value)
0
     @login = value.downcase unless value.nil?
...
38
39
40
41
42
 
 
 
 
 
 
 
 
 
 
43
44
45
 
46
47
48
...
38
39
40
 
 
41
42
43
44
45
46
47
48
49
50
51
52
 
53
54
55
56
0
@@ -38,11 +38,19 @@
0
 
0
     <h3>Where can I find help?</h3>
0
     <p>If you have any questions or if you can't figure something out, please take a
0
- look at our <a href="http://merb.devjavu.com/"> project development page</a> or,
0
- feel free to come chat at irc.freenode.net, channel #merb.</p>
0
+ look at our <a href="http://merbivore.com/"> project page</a>,
0
+ feel free to come chat at irc.freenode.net, channel #merb,
0
+ or post to <a href="http://groups.google.com/group/merb">merb mailing list</a>
0
+ on Google Groups.</p>
0
+
0
+ <h3>What if I've found a bug?</h3>
0
+ <p>If you want to file a bug or make your own contribution to Merb,
0
+ feel free to register and create a ticket at our
0
+ <a href="http://merb.lighthouseapp.com/">project development page</a>
0
+ on Lighthouse.</p>
0
 
0
     <h3>How do I edit this page?</h3>
0
- <p>You can change what people see when this happens byy editing <tt>app/views/exceptions/not_found.html.erb</tt>.</p>
0
+ <p>You can change what people see when this happens by editing <tt>app/views/exceptions/not_acceptable.html.erb</tt>.</p>
0
 
0
   </div>
0
 
...
17
18
19
20
21
 
 
 
 
 
 
 
 
 
 
22
23
24
...
17
18
19
 
 
20
21
22
23
24
25
26
27
28
29
30
31
32
0
@@ -17,8 +17,16 @@
0
     
0
     <h3>Where can I find help?</h3>
0
     <p>If you have any questions or if you can't figure something out, please take a
0
- look at our <a href="http://merb.devjavu.com/"> project development page</a> or,
0
- feel free to come chat at irc.freenode.net, channel #merb.</p>
0
+ look at our <a href="http://merbivore.com/"> project page</a>,
0
+ feel free to come chat at irc.freenode.net, channel #merb,
0
+ or post to <a href="http://groups.google.com/group/merb">merb mailing list</a>
0
+ on Google Groups.</p>
0
+
0
+ <h3>What if I've found a bug?</h3>
0
+ <p>If you want to file a bug or make your own contribution to Merb,
0
+ feel free to register and create a ticket at our
0
+ <a href="http://merb.lighthouseapp.com/">project development page</a>
0
+ on Lighthouse.</p>
0
 
0
     <h3>How do I edit this page?</h3>
0
     <p>You're seeing this page because you need to edit the following files:
...
3
4
5
 
6
...
3
4
5
6
7
0
@@ -3,4 +3,5 @@ Merb::Config.use { |c|
0
   c[:exception_details] = true
0
   c[:reload_classes] = true
0
   c[:reload_time] = 0.5
0
+ c[:log_auto_flush ] = true
0
 }
...
2
3
4
 
 
5
...
2
3
4
5
6
7
0
@@ -2,4 +2,6 @@ Merb.logger.info("Loaded PRODUCTION Environment...")
0
 Merb::Config.use { |c|
0
   c[:exception_details] = false
0
   c[:reload_classes] = false
0
+ c[:log_level] = :error
0
+ c[:log_file] = Merb.log_path + "/production.log"
0
 }
...
2
3
4
5
 
6
...
2
3
4
 
5
6
0
@@ -2,5 +2,5 @@ Merb.logger.info("Loaded TEST Environment...")
0
 Merb::Config.use { |c|
0
   c[:testing] = true
0
   c[:exception_details] = true
0
- c[:reload_classes] = false
0
+ c[:log_auto_flush ] = true
0
 }
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
 
 
 
 
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
34
35
36
...
46
47
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
 
 
 
 
 
 
 
 
28
29
30
31
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
34
35
36
...
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
0
@@ -1,36 +1,36 @@
0
+# __ __ _ __ __ _
0
+# | \/ |___ _ _| |__| \/ |__ _ _ _| |_
0
+# | |\/| / -_) '_| '_ \ |\/| / _` | '_| _|
0
+# |_| |_\___|_| |_.__/_| |_\__,_|_| \__|
0
+#
0
+# Copyright (C) 2008 Alex Coles
0
+#
0
+# This program is free software: you can redistribute it and/or modify
0
+# it under the terms of the GNU General Public License as published by
0
+# the Free Software Foundation, either version 2 of the License, or
0
+# (at your option) any later version.
0
+#
0
+# This program is distributed in the hope that it will be useful,
0
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
0
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0
+# GNU General Public License for more details.
0
+#
0
+# You should have received a copy of the GNU General Public License
0
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
0
+#
0
+
0
+# ==== Load paths
0
+
0
 # Make the app's "gems" directory a place where gems are loaded from
0
 Gem.clear_paths
0
 Gem.path.unshift(Merb.root / "gems")
0
 
0
-# Make the app's "lib" directory a place where ruby files get "require"d from
0
-$LOAD_PATH.unshift(Merb.root / "lib")
0
-
0
-
0
-Merb::Config.use do |c|
0
- c[:session_secret_key] = 'efeb3cd8e1d8a6deedefd479843705ff21c022a1'
0
- #c[:session_store] = 'datamapper' -- TEMPORARILY DISABLE
0
- c[:session_store] = 'cookie'
0
-end
0
+# If you want modules and classes from libraries organized like
0
+# merbapp/lib/magicwand/lib/magicwand.rb to autoload,
0
+# uncomment this.
0
+# Merb.push_path(:lib, Merb.root / "lib") # uses **/*.rb as path glob.
0
 
0
-### Globals
0
-MEGABYTE = 1024.0 * 1024.0
0
-MAX_SIZE = 10 * MEGABYTE
0
-
0
-### Specify the ORM: DataMapper
0
-use_orm :datamapper
0
-
0
-### Specify the Test Framework: RSpec
0
-use_test :rspec
0
-
0
-### Specify Other Dependencies
0
-
0
-# These are some examples of how you might specify dependencies.
0
-#
0
-# dependencies "RedCloth", "merb_helpers"
0
-# OR
0
-# dependency "RedCloth", "> 3.0"
0
-# OR
0
-# dependencies "RedCloth" => "> 3.0", "ruby-aes-cext" => "= 1.0"
0
+# ==== Dependencies
0
 
0
 dependency "merb-assets"
0
 dependency "merb-mailer"
0
@@ -46,3 +46,33 @@ Merb::BootLoader.after_app_loads do
0
 
0
   # dependency "magic_admin" # this gem uses the app's model classes
0
 end
0
+
0
+# ==== Object Relation Mapping (ORM) Framework
0
+
0
+# DataMapper
0
+use_orm :datamapper
0
+
0
+# ==== Testing Framework
0
+
0
+# RSpec
0
+use_test :rspec
0
+
0
+# ==== Application Globals
0
+
0
+MEGABYTE = 1024.0 * 1024.0
0
+MAX_SIZE = 10 * MEGABYTE
0
+
0
+# ==== Application Configuration
0
+
0
+Merb::Config.use do |c|
0
+
0
+ c[:session_secret_key] = 'ea30e9cd9614d32ab7823fb081104ecca546beee'
0
+ c[:session_store] = 'cookie'
0
+ # c[:session_store] = 'datamapper' ## FIXME: temporarily disabled
0
+ # c[:use_mutex] = false ## FIXME: disable Mutex
0
+
0
+end
0
+
0
+# ==== Inflector Customization
0
+
0
+# Language::English::Inflector.word "Store", "A Chain"
...
1
 
2
3
4
...
1
2
3
4
5
0
@@ -1,4 +1,5 @@
0
 require 'merb_helpers'
0
+require 'merb-mailer'
0
 
0
 base = File.dirname(__FILE__)
0
 
...
5
6
7
 
 
8
9
10
...
5
6
7
8
9
10
11
12
0
@@ -5,6 +5,8 @@ module AuthenticatedSystem
0
       Merb::Router.prepend do |r|
0
         r.match("/login").to(:controller => "Session", :action => "create").name(:login)
0
         r.match("/logout").to(:controller => "Session", :action => "destroy").name(:logout)
0
+ r.match("/users/activate/:activation_code").to(:controller => "User", :action => "activate").name(:user_activation)
0
+
0
         r.resources :users
0
         r.resources :session
0
       end
...
55
56
57
58
 
 
 
 
 
59
60
61
...
69
70
71
72
73
 
 
74
75
76
...
134
135
136
137
138
 
...
55
56
57
 
58
59
60
61
62
63
64
65
...
73
74
75
 
 
76
77
78
79
80
...
138
139
140
 
141
142
0
@@ -55,7 +55,11 @@ module AuthenticatedSystem
0
 
0
       # Redirect as appropriate when an access request fails.
0
       #
0
- # The default action is to redirect to the login screen.
0
+ # The default HTML action is to redirect to the login screen.
0
+ #
0
+ # The default XML action is to render the text Couldn't authenticate you.
0
+ # To provide this response wrapped in XML, make sure to specify an
0
+ # XML layout, such as /app/views/layouts/application.xml.builder.
0
       #
0
       # Override this method in your controllers if you want to have special
0
       # behavior in case the user is not authorized
0
@@ -69,8 +73,8 @@ module AuthenticatedSystem
0
         when :xml
0
           headers["Status"] = "Unauthorized"
0
           headers["WWW-Authenticate"] = %(Basic realm="Web Password")
0
- set_status(401)
0
- render :text => "Couldn't authenticate you"
0
+ self.status = 401
0
+ render "Couldn't authenticate you"
0
         end
0
       end
0
     
0
@@ -134,4 +138,4 @@ end
0
 
0
 Merb::BootLoader.after_app_loads do
0
   Application.send(:include, AuthenticatedSystem::Controller)
0
-end
0
\ No newline at end of file
0
+end
...
51
52
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
 
 
55
56
57
...
74
75
76
77
78
 
...
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
...
91
92
93
 
94
95
0
@@ -51,7 +51,24 @@ module AuthenticatedSystem
0
         self.save
0
       end
0
       
0
+ # Returns true if the <%= singular_name %> has just been activated.
0
+ def recently_activated?
0
+ @activated
0
+ end
0
+
0
+ def activated?
0
+ return false if self.new_record?
0
+ !! activation_code.nil?
0
+ end
0
+
0
+ def active?
0
+ # the existence of an activation code means they have not activated yet
0
+ activation_code.nil?
0
+ end
0
       protected
0
+ def make_activation_code
0
+ self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
0
+ end
0
       
0
       def password_required?
0
         crypted_password.blank? || !password.blank?
0
@@ -74,4 +91,4 @@ module AuthenticatedSystem
0
 
0
     
0
   end
0
-end
0
\ No newline at end of file
0
+end
...
1
 
 
 
2
3
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
 
 
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
0
@@ -1,4 +1,22 @@
0
 #!/usr/bin/env ruby
0
+
0
+require 'rubygems'
0
+require 'merb-core'
0
 
0
-argv = ARGV + %w[-a fcgi]
0
-Merb.start(argv)
0
+# this is Merb.root, change this if you have some funky setup.
0
+merb_root = File.expand_path(File.dirname(__FILE__) / '../')
0
+
0
+# If the fcgi process runs as apache, make sure
0
+# we have an inlinedir set for Rubyinline action-args to work
0
+unless ENV["INLINEDIR"] || ENV["HOME"]
0
+ tmpdir = merb_root / "tmp"
0
+ unless File.directory?(tmpdir)
0
+ Dir.mkdir(tmpdir)
0
+ end
0
+ ENV["INLINEDIR"] = tmpdir
0
+end
0
+
0
+# start merb with the fcgi adapter, add options or change the log dir here
0
+Merb.start(:adapter => 'fcgi',
0
+ :merb_root => merb_root,
0
+ :log_file => merb_root /'log'/'merb.log')
...
1
2
 
3
4
5
...
1
2
3
4
5
6
0
@@ -1,5 +1,6 @@
0
 require 'rubygems'
0
 require 'merb-core'
0
+require 'spec' # Satiates Autotest and anyone else not using the Rake tasks
0
 
0
 Merb.start_environment(:testing => true, :adapter => 'runner', :environment => ENV['MERB_ENV'] || 'test')
0
 

Comments

    No one has commented yet.