routes.rb
7.98 KB
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
37
38
39
40
41
42
43
44
45
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
require_dependency 'noosfero'
require 'environment_domain_constraint'
Noosfero::Application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', controller: 'catalog', action: 'view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# map.purchase 'products/:id/purchase', controller: 'catalog', action: 'purchase'
# This route can be invoked with purchase_url(id: product.id)
######################################################
## Public controllers
######################################################
match 'test/:controller(/:action(/:id))', controller: /.*test.*/, via: :all
# -- just remember to delete public/index.html.
# You can have the root of your site routed by hooking up ''
root to: 'home#index', constraints: EnvironmentDomainConstraint.new, via: :all
match 'site(/:action)', controller: 'home', via: :all
match 'api(/:action)', controller: 'api', via: :all
match 'images(/*stuff)', to: 'not_found#nothing', via: :all
match 'stylesheets(/*stuff)', to: 'not_found#nothing', via: :all
match 'designs(/*stuff)', to: 'not_found#nothing', via: :all
match 'articles(/*stuff)', to: 'not_found#nothing', via: :all
match 'javascripts(/*stuff)', to: 'not_found#nothing', via: :all
match 'thumbnails(/*stuff)', to: 'not_found#nothing', via: :all
match 'user_themes(/*stuff)', to: 'not_found#nothing', via: :all
# embed controller
match 'embed/:action/:id', controller: 'embed', id: /\d+/, via: :all
# online documentation
match 'doc', to: 'doc#index', as: :doc, via: :all
match 'doc/:section', to: 'doc#section', as: :doc_section, via: :all
match 'doc/:section/:topic', to: 'doc#topic', as: :doc_topic, via: :all
# user account controller
match 'account/new_password/:code', controller: 'account', action: 'new_password', via: :all
match 'account(/:action)', controller: 'account', via: :all
# enterprise registration
match 'enterprise_registration(/:action)', controller: 'enterprise_registration', via: :all
# tags
match 'tag', controller: 'search', action: 'tags', via: :all
match 'tag/:tag', controller: 'search', action: 'tag', tag: /.*/, via: :all
# categories index
match 'cat/*category_path', to: 'search#category_index', as: :category, via: :all
# search
match 'search(/:action(/*category_path))', controller: 'search', via: :all
##
# Keep products URL compatibility
get 'catalog/:profile', to: redirect{ |params, request| "/profile/#{request.params[:profile]}/plugin/products/catalog" }
get 'myprofile/:profile/manage_products(/:action(/:id))', to: (redirect do |params, request|
"/profile/#{request.params[:profile]}/plugin/products/page/#{request.params[:action]}/#{request.params[:id]}"
end)
# events
match 'profile/:profile/events_by_day', controller: 'events', action: 'events_by_day', profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
match 'profile/:profile/events_by_month', controller: 'events', action: 'events_by_month', profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
match 'profile/:profile/events/:year/:month/:day', controller: 'events', action: 'events', year: /\d*/, month: /\d*/, day: /\d*/, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
match 'profile/:profile/events/:year/:month', controller: 'events', action: 'events', year: /\d*/, month: /\d*/, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
match 'profile/:profile/events', controller: 'events', action: 'events', profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
# invite
match 'profile/:profile/invite/friends', controller: 'invite', action: 'invite_friends', profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
match 'profile/:profile/invite/:action', controller: 'invite', profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
# feeds per tag
match 'profile/:profile/tags/:id/feed', controller: 'profile', action:'tag_feed', id: /.+/, profile: /#{Noosfero.identifier_format_in_url}/i, as: :tag_feed, via: :all
# profile tags
match 'profile/:profile/tags/:id', controller: 'profile', action: 'content_tagged', id: /.+/, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
match 'profile/:profile/tags(/:id)', controller: 'profile', action: 'tags', profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
# profile search
match 'profile/:profile/search', controller: 'profile_search', action: 'index', profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
# comments
match 'profile/:profile/comment/:action/:id', controller: 'comment', profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
# public profile information
match 'profile/:profile(/:action(/:id))', controller: 'profile', action: 'index', id: /[^\/]*/, profile: /#{Noosfero.identifier_format_in_url}/i, as: :profile, via: :all
# contact
match 'contact/:profile/:action(/:id)', controller: 'contact', action: 'index', id: /.*/, profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
# map balloon
match 'map_balloon/:action/:id', controller: 'map_balloon', id: /.*/, via: :all
# chat
match 'chat(/:action(/:id))', controller: 'chat', via: :all
######################################################
## Controllers that are profile-specific (for profile admins )
######################################################
# profile customization - "My profile"
match 'myprofile/:profile', controller: 'profile_editor', action: 'index', profile: /#{Noosfero.identifier_format_in_url}/i, via: :all
match 'myprofile/:profile/:controller(/:action(/:id))', controller: Noosfero.pattern_for_controllers_in_directory('my_profile'), profile: /#{Noosfero.identifier_format_in_url}/i, as: :myprofile, via: :all
######################################################
## Controllers that are used by environment admin
######################################################
# administrative tasks for a environment
match 'admin', controller: 'admin_panel', action: :index, via: :all
match 'admin/:controller(/:action((.:format)/:id))', controller: Noosfero.pattern_for_controllers_in_directory('admin'), via: :all
match 'admin/:controller(/:action(/:id))', controller: Noosfero.pattern_for_controllers_in_directory('admin'), via: :all
######################################################
## Controllers that are used by system admin
######################################################
# administrative tasks for a environment
match 'system', controller: 'system', via: :all
match 'system/:controller(/:action(/:id))', controller: Noosfero.pattern_for_controllers_in_directory('system'), via: :all
######################################################
# plugin routes
######################################################
plugins_routes = File.join(File.dirname(__FILE__) + '/../lib/noosfero/plugin/routes.rb')
eval(IO.read(plugins_routes), binding, plugins_routes)
# cache stuff - hack
match 'public/:action/:id', controller: 'public', via: :all
match ':profile/*page/versions', controller: 'content_viewer', action: 'article_versions', profile: /#{Noosfero.identifier_format_in_url}/i, constraints: EnvironmentDomainConstraint.new, via: :all
match '*page/versions', controller: 'content_viewer', action: 'article_versions', via: :all
match ':profile/*page/versions_diff', controller: 'content_viewer', action: 'versions_diff', profile: /#{Noosfero.identifier_format_in_url}/i, constraints: EnvironmentDomainConstraint.new, via: :all
match '*page/versions_diff', controller: 'content_viewer', action: 'versions_diff', via: :all
# match requests for profiles that don't have a custom domain
match ':profile(/*page)', controller: 'content_viewer', action: 'view_page', profile: /#{Noosfero.identifier_format_in_url}/i, constraints: EnvironmentDomainConstraint.new, via: :all
# match requests for content in domains hosted for profiles
match '/(*page)', controller: 'content_viewer', action: 'view_page', via: :all
end