Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
updating sample index page with modified links
Browse files Browse the repository at this point in the history
  • Loading branch information
lusis committed May 4, 2011
1 parent bc9007b commit c34fadb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 23 deletions.
9 changes: 9 additions & 0 deletions lib/noah/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ def delete_service_from_host(servicename, hostname)
r.to_json
end

def find_named_link(path)
link = Noah::Link.find(:path => "/"+path).first
if link.nil?
# try finding it wihtout the slash
link = Noah::Link.find(:path => path).first
(halt 404) if link.nil?
end
return link
end
def add_config_to_app(appname, config_hash)
begin
config = Noah::Configuration.find_or_create(config_hash)
Expand Down
23 changes: 10 additions & 13 deletions lib/noah/routes/links.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
class Noah::App

get '/:link_name/:model_name/:item/?' do |path, model, item|
link_name = find_named_link(path)
(halt 404) if link_name.to_hash.has_key?(model.to_sym) == false
(halt 404) if link_name.to_hash[model.to_sym].has_key?(item) == false
link_name.to_hash[model.to_sym][item].merge({:name => item}).to_json
end

get '/:link_name/:model_name/?' do |path, model|
link_name = Noah::Link.find(:path => "/"+path).first
if link_name.nil?
# So maybe they forgot to add the path with a leading slash?
link_name = Noah::Link.find(:path => path).first
(halt 404) if link_name.nil?
end
link_name = find_named_link(path)
(halt 404) if link_name.to_hash.has_key?(model.to_sym) == false
link_name.to_hash[model.to_sym].to_json
end

get '/:link_name/?' do |link|
link_name = Noah::Link.find(:path => "/"+link).first
if link_name.nil?
# So maybe they forgot to add the path with a leading slash?
link_name = Noah::Link.find(:path => link).first
(halt 404) if link_name.nil?
end
get '/:link_name/?' do |path|
link_name = find_named_link(path)
link_name.to_json
end

Expand Down
2 changes: 1 addition & 1 deletion lib/noah/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Noah
VERSION = "0.8.1"
VERSION = "0.8.2"
end
19 changes: 10 additions & 9 deletions views/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

#header
%h1 Sample links
%p If these links return 404 messages, that simply means the sample data has not been populated.
%p You can click the "All" links on each category to see if there is any data for those object types.
%p The best way to interact with Noah is via API calls.
%a{:href => "http://goo.gl/jYqp2"} Documentation

%h2 System Information
%ul
%li
Expand All @@ -18,7 +23,7 @@
%li
%a{:href => "hosts/localhost"} localhost (this server)
%li
%a{:href => "hosts/localhost/noah"} localhost noah service
%a{:href => "hosts/localhost/services/noah"} localhost noah service
#header
%h2 Services
%ul
Expand All @@ -36,22 +41,18 @@
%li
%a{:href => "applications/noah"} Noah Application entry
%li
%a{:href => "applications/noah/redis"} Noah Redis configuration entry
%a{:href => "applications/noah/configurations/redis_url"} Noah Redis configuration entry
#header
%h2 Configurations
%ul
%li
%a{:href => "configurations/"} All registered Configurations
%li
%a{:href => "configurations/noah"} Noah Configuration entry
%li
%a{:href => "configurations/myrailsapp1"} myrailsapp1 Configuration entry
%li
%a{:href => "configurations/myrestapp1"} myrestapp1 Configuration entry
%a{:href => "configurations/redis_url"} A Redis URL Configuration entry
%li
%a{:href => "configurations/myrailsapp1/database.yml"} database.yml file for myrailsapp1 (should return the proper content-type)
%a{:href => "configurations/database.yml"} database.yml file (most likely will return JSON representation. Send "Accept: application/octet" headers for raw version)
%li
%a{:href => "configurations/myrestapp1/config.json"} config.json file for myrestapp1
%a{:href => "configurations/config.json"} config.json file (see above note about headers)
#header
%h2 Links
%ul
Expand Down

0 comments on commit c34fadb

Please sign in to comment.