orange 0.2.11 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/orange-more/analytics/middleware/analytics.rb +2 -2
- data/lib/orange-more/analytics/resources/analytics_resource.rb +11 -1
- data/lib/orange-more/pages/resources/page_resource.rb +16 -0
- data/lib/orange-more/pages/views/pages/edit.haml +2 -2
- data/lib/orange-more/sitemap/resources/sitemap_resource.rb +3 -0
- metadata +3 -3
@@ -6,8 +6,8 @@ module Orange::Middleware
|
|
6
6
|
# Passes packet then parses the return
|
7
7
|
def packet_call(packet)
|
8
8
|
pass packet
|
9
|
-
|
10
|
-
|
9
|
+
ga_key = orange.options['google_analytics_key'] || false
|
10
|
+
if packet['route.context'] == :live && ga_key
|
11
11
|
ga = "<script type=\"text/javascript\">
|
12
12
|
|
13
13
|
var _gaq = _gaq || [];
|
@@ -3,15 +3,25 @@ require 'gattica'
|
|
3
3
|
module Orange
|
4
4
|
class AnalyticsResource < Orange::Resource
|
5
5
|
call_me :analytics
|
6
|
+
def stack_init
|
7
|
+
options[:email] = orange.options['ga_email']
|
8
|
+
options[:password] = orange.options['ga_password']
|
9
|
+
end
|
10
|
+
|
11
|
+
def gattica
|
12
|
+
return false unless options[:email]
|
13
|
+
@gattica ||= Gattica.new(options)
|
14
|
+
end
|
6
15
|
|
7
16
|
def pageviews(route)
|
17
|
+
return "No GA" unless gattica
|
8
18
|
r = route.to_s
|
9
19
|
# Strip of trailing slash if present. GA doesn't like it.
|
10
20
|
if r.rindex('/') > 0
|
11
21
|
r[r.rindex('/')] = ''
|
12
22
|
end
|
13
23
|
# authenticate with the API via email/password
|
14
|
-
ga =
|
24
|
+
ga = gattica
|
15
25
|
accounts = ga.accounts
|
16
26
|
ga.profile_id = accounts.first.profile_id
|
17
27
|
views = ""
|
@@ -42,11 +42,27 @@ module Orange
|
|
42
42
|
params = {}
|
43
43
|
params[:published] = true
|
44
44
|
m.update(params)
|
45
|
+
|
45
46
|
params = m.attributes.merge(params)
|
46
47
|
params.delete(:id)
|
47
48
|
max = m.versions.max(:version) || 0
|
48
49
|
m.versions.new(params.merge(:version => max + 1))
|
49
50
|
m.save
|
51
|
+
|
52
|
+
r = orange[:sitemap].routes_for(packet, :resource_id => m.id, :resource => @my_orange_name)
|
53
|
+
if r.blank?
|
54
|
+
route_hash = {
|
55
|
+
:orange_site_id => m.orange_site_id,
|
56
|
+
:resource => @my_orange_name,
|
57
|
+
:resource_id => m.id,
|
58
|
+
:slug => orange[:sitemap].slug_for(m, params),
|
59
|
+
:show_in_nav => false,
|
60
|
+
:link_text => m.title
|
61
|
+
}
|
62
|
+
parents = orange[:sitemap].routes_for(packet, :resource => '', :resource_id => '', :slug => "pages")
|
63
|
+
route_hash[:parent] = parents.first unless parents.blank?
|
64
|
+
orange[:sitemap].add_route_for(packet, route_hash)
|
65
|
+
end
|
50
66
|
end
|
51
67
|
end
|
52
68
|
packet.reroute(@my_orange_name, :orange) unless (packet.request.xhr? || no_reroute)
|
@@ -9,11 +9,11 @@
|
|
9
9
|
$(function(){
|
10
10
|
$('button.link_button').click(
|
11
11
|
function(){
|
12
|
-
$('input[name="pages[published]"]').val('
|
12
|
+
$('input[name="pages[published]"]').val('1');
|
13
13
|
}
|
14
14
|
);
|
15
15
|
});
|
16
|
-
%input{:type => 'hidden', :id => 'pages[published]', :name => 'pages[published]', :value => '
|
16
|
+
%input{:type => 'hidden', :id => 'pages[published]', :name => 'pages[published]', :value => '0'}
|
17
17
|
%input{:type => 'submit', :value => 'Save Changes'}
|
18
18
|
/ = route_to(model_name, model[:id], 'publish')
|
19
19
|
= form_link('Publish', packet.route_to(model_name, model[:id], 'save'))
|
@@ -166,6 +166,9 @@ module Orange
|
|
166
166
|
def add_route_for(packet, opts = {})
|
167
167
|
unless opts.blank?
|
168
168
|
parent = opts.delete(:parent) || home(packet, opts)
|
169
|
+
unless parent.is_a? model_class
|
170
|
+
parent = model_class.get(parent) # Get parent object if parent was an id number
|
171
|
+
end
|
169
172
|
me = model_class.new(opts)
|
170
173
|
me.save
|
171
174
|
me.move(:into => parent)
|