orange 0.2.9 → 0.2.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -109,6 +109,7 @@ Required Gems
109
109
  * hominid
110
110
  * mail
111
111
  * tlsmail (If Ruby version <= 1.8.6)
112
+ * gattica
112
113
 
113
114
  All dependencies should be loaded if you install the gem except for the datamapper
114
115
  adapter relevant to your set up. If, for example, you want to use a mysql database,
@@ -2,7 +2,7 @@
2
2
  %thead
3
3
  %tr
4
4
  - for prop in props
5
- %th= prop[:name]
5
+ %th= prop[:name].to_s.capitalize
6
6
  %th
7
7
  %tbody
8
8
  - for obj in list
@@ -14,6 +14,7 @@ require File.join(libdir, 'orange-more', 'disqus')
14
14
  require File.join(libdir, 'orange-more', 'testimonials')
15
15
  require File.join(libdir, 'orange-more', 'adverts')
16
16
  require File.join(libdir, 'orange-more', 'contactforms')
17
+ require File.join(libdir, 'orange-more', 'analytics')
17
18
  require File.join(libdir, 'orange-more', 'cloud')
18
19
  require File.join(libdir, 'orange-more', 'debugger')
19
20
  require File.join(libdir, 'orange-more', 'subsites')
@@ -0,0 +1 @@
1
+ require File.join('orange-more', 'analytics', 'plugin')
@@ -0,0 +1,30 @@
1
+ require 'orange-core/middleware/base'
2
+
3
+ module Orange::Middleware
4
+ class Analytics < Base
5
+
6
+ # Passes packet then parses the return
7
+ def packet_call(packet)
8
+ pass packet
9
+ unless packet['route.context'] != :live
10
+ ga_key = orange.options['google_analytics_key'];
11
+ ga = "<script type=\"text/javascript\">
12
+
13
+ var _gaq = _gaq || [];
14
+ _gaq.push(['_setAccount', '"+ga_key+"']);
15
+ _gaq.push(['_trackPageview']);
16
+
17
+ (function() {
18
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
19
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
20
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
21
+ })();
22
+
23
+ </script>"
24
+ packet[:content] = packet[:content].sub(/.*<\/body>$/, ga + '</body>')
25
+ end
26
+ packet.finish
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ Dir.glob(File.join(File.dirname(__FILE__), 'resources', '*.rb')).each {|f| require f }
2
+ Dir.glob(File.join(File.dirname(__FILE__), 'middleware', '*.rb')).each {|f| require f }
3
+
4
+ module Orange::Plugins
5
+ class Analytics < Base
6
+ resource Orange::AnalyticsResource.new
7
+ prerouter Orange::Middleware::Analytics
8
+ end
9
+ end
10
+
11
+ Orange.plugin(Orange::Plugins::Analytics.new)
@@ -0,0 +1,32 @@
1
+ require 'gattica'
2
+
3
+ module Orange
4
+ class AnalyticsResource < Orange::Resource
5
+ call_me :analytics
6
+
7
+ def pageviews(route)
8
+ r = route.to_s
9
+ # Strip of trailing slash if present. GA doesn't like it.
10
+ if r.rindex('/') > 0
11
+ r[r.rindex('/')] = ''
12
+ end
13
+ # authenticate with the API via email/password
14
+ ga = Gattica.new({:email => 'erictasticfosterama@gmail.com', :password => 'tailfish'})
15
+ accounts = ga.accounts
16
+ ga.profile_id = accounts.first.profile_id
17
+ views = ""
18
+ data = ga.get({ :start_date => '2009-01-01',
19
+ :end_date => Time.now.localtime.strftime("%Y-%m-%d"),
20
+ :dimensions => ['pagePath'],
21
+ :metrics => ['pageviews'],
22
+ :filters => ['pagePath == '+route.to_s[0..-1]]
23
+ })
24
+ unless data.points.length == 0
25
+ views = data.points[0].metrics[0][:pageviews]
26
+ views
27
+ else
28
+ 0
29
+ end
30
+ end
31
+ end
32
+ end
@@ -3,7 +3,7 @@ class OrangeNews < Orange::Carton
3
3
  id
4
4
  front do
5
5
  title :title
6
- text :link
6
+ text :link, :length => 255
7
7
  fulltext :description
8
8
  end
9
9
 
@@ -65,5 +65,9 @@ module Orange
65
65
  url = orange[:sitemap, true].url_for(packet, :resource => :news, :resource_action => :archive)
66
66
  url.gsub!(/\/$/, '')
67
67
  end
68
+
69
+ def find_list(packet, mode, opts = {})
70
+ model_class.all(:order => [:updated_at.desc]) || []
71
+ end
68
72
  end
69
73
  end
@@ -50,7 +50,7 @@ module Orange
50
50
  end
51
51
  end
52
52
  packet.reroute(@my_orange_name, :orange) unless (packet.request.xhr? || no_reroute)
53
- end
53
+ end
54
54
 
55
55
  # Creates a new model object and saves it (if a post), then reroutes to the main page
56
56
  # @param [Orange::Packet] packet the packet being routed
@@ -104,9 +104,17 @@ module Orange
104
104
  if mode == :show
105
105
  case packet['route.context']
106
106
  when :live
107
+ # Automatically set title, if possible
108
+ unless orange[:page_parts].part(packet)[:title] != ''
109
+ orange[:page_parts].part(packet)[:title] = m.title + " - " + packet['site'].name
110
+ end
107
111
  m = m.versions.last(:published => '1')
108
112
  raise Orange::NotFoundException unless m
109
113
  when :preview
114
+ # Automatically set title, if possible
115
+ unless orange[:page_parts].part(packet)[:title] != ''
116
+ orange[:page_parts].part(packet)[:title] = m.title + " - " + packet['site'].name
117
+ end
110
118
  m
111
119
  end
112
120
  else {}
@@ -21,6 +21,9 @@
21
21
  %p
22
22
  Linked to:
23
23
  %a{:href => route.resource.blank? ? '#' : route_to(route.resource, route.resource_id, 'edit')} [#{route.resource}] ##{route.resource_id}
24
+ %p
25
+ Views:
26
+ = orange[:analytics].pageviews(route.full_path)
24
27
  .actions
25
28
  = form_link('Delete', route_to(:sitemap, route.id, 'delete'), 'Are you sure you want to delete this?', {:method => 'delete'})
26
29
  %a{:href => route_to(:sitemap, route.id, 'edit')} Edit
@@ -21,6 +21,9 @@
21
21
  %p
22
22
  Linked to:
23
23
  %a{:href => model.resource.blank? ? '#' : route_to(model.resource, model.resource_id, 'edit')} [#{model.resource}] ##{model.resource_id}
24
+ %p
25
+ Views:
26
+ = orange[:analytics].pageviews(route.full_path)
24
27
  .actions
25
28
  = form_link('Delete', route_to(model_name, model.id, 'delete'), 'Are you sure you want to delete this?', {:method => 'delete'})
26
29
  %a{:href => route_to(model_name, model.id, 'edit')} Edit
@@ -10,16 +10,16 @@ module Orange
10
10
  # @param [Orange::Packet] packet the packet being routed
11
11
  def new(packet, *opts)
12
12
  if packet.request.post?
13
- m = packet['site'].subsites.new(packet.request.params[@my_orange_name.to_s])
14
- m.save
15
- orange[:sitemap].add_route_for(packet,
16
- :orange_site_id => packet['site'].id,
17
- :resource => :subsites,
18
- :resource_id => m.id,
19
- :slug => 'subsite',
20
- :link_text => 'Orange Subsite'
21
- )
22
- end
13
+ m = packet['site'].subsites.new(packet.request.params[@my_orange_name.to_s])
14
+ m.save
15
+ orange[:sitemap].add_route_for(packet,
16
+ :orange_site_id => packet['site'].id,
17
+ :resource => :subsites,
18
+ :resource_id => m.id,
19
+ :slug => 'subsite',
20
+ :link_text => 'Orange Subsite'
21
+ )
22
+ end
23
23
  packet.reroute(@my_orange_name, :orange)
24
24
  end
25
25
 
@@ -31,6 +31,10 @@ module Orange
31
31
  orange[:sitemap].one_level(packet, :model => orange[:sitemap].home(packet, :subsite => true))
32
32
  end
33
33
 
34
+ def sitemap_row(packet, opts = {})
35
+ do_view(packet, :sitemap_row, opts)
36
+ end
37
+
34
38
  end
35
39
 
36
40
  class Mapper < Resource
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 9
9
- version: 0.2.9
8
+ - 11
9
+ version: 0.2.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Haslem
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-23 00:00:00 -04:00
17
+ date: 2010-05-24 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -140,6 +140,10 @@ files:
140
140
  - lib/orange-more/adverts/plugin.rb
141
141
  - lib/orange-more/adverts/resources/adverts_resource.rb
142
142
  - lib/orange-more/adverts/views/adverts/adverts.haml
143
+ - lib/orange-more/analytics.rb
144
+ - lib/orange-more/analytics/middleware/analytics.rb
145
+ - lib/orange-more/analytics/plugin.rb
146
+ - lib/orange-more/analytics/resources/analytics_resource.rb
143
147
  - lib/orange-more/assets.rb
144
148
  - lib/orange-more/assets/cartons/asset_carton.rb
145
149
  - lib/orange-more/assets/plugin.rb