Skip to content

Commit

Permalink
[api,webui] move apidocs to webui, so we can get rid of the remaining…
Browse files Browse the repository at this point in the history
… HTML in api
  • Loading branch information
coolo committed Oct 9, 2012
1 parent 9d90cd7 commit 992aca8
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 52 deletions.
12 changes: 8 additions & 4 deletions docs/api/restility/lib/rest_htmlprinter.rb
Expand Up @@ -83,7 +83,8 @@ def print_request request
def print_text text
@html.p do |p|
text.text.each do |t|
p << t << "\n"
p.span(t)
p.br
end
end
end
Expand Down Expand Up @@ -137,7 +138,7 @@ def print_xml_links title, xmlname, schema
end

def print_contents contents
@html.p do |p|
@html.div do |p|
p << create_contents_list( contents.root, 1 )
end
end
Expand All @@ -155,13 +156,16 @@ def create_contents_list section, min_level
endresult = ""
if ( !result.empty? )
if ( section.level > min_level )
endresult = "<li>" + h( section.to_s ) + "</li>\n"
endresult = "<li>" + h( section.to_s )
end
if ( section.level >= min_level )
endresult += "<ul>\n" + result + "</ul>\n"
endresult += "<ul>\n" + result + "</ul>"
else
endresult = result
end
if ( section.level > min_level )
endresult += "</li>"
end
end
endresult
end
Expand Down
6 changes: 0 additions & 6 deletions src/api/config/deploy.rb
Expand Up @@ -44,7 +44,6 @@
before "deploy:update_code", "deploy:test_suite"

# workaround because we are using a subdirectory of the git repo as rails root
before "deploy:finalize_update", "deploy:apidocs"
before "deploy:finalize_update", "deploy:use_subdir"
after "deploy:finalize_update", "deploy:reset_subdir"
after "deploy:finalize_update", "deploy:notify"
Expand Down Expand Up @@ -101,11 +100,6 @@
run "rm -f #{current_path} && ln -s #{latest_release}#{git_subdir} #{current_path}"
end

desc "Create API docs"
task :apidocs do
run "cd #{release_path}/docs/api && make"
end

desc "Send email notification of deployment"
task :notify do
#diff = `#{source.local.diff(current_revision)}`
Expand Down
1 change: 0 additions & 1 deletion src/api/config/environment.rb
Expand Up @@ -12,7 +12,6 @@
CONFIG = Hash.new
end

CONFIG['apidocs_location'] ||= File.expand_path("../../docs/api/html/")
CONFIG['schema_location'] ||= File.expand_path("public/schema")+"/"
CONFIG['download_url'] ||= 'http://download.opensuse.org/repositories'

Expand Down
2 changes: 0 additions & 2 deletions src/api/config/options.yml.example
Expand Up @@ -44,8 +44,6 @@ source_port: 5352

extended_backend_log: false

#apidocs_location

# Do not allow creating group via API to avoid the conflicts when CONFIG['ldap_group_support'] is :on
# If you do want to import the group data from LDAP to OBS DB manuallly, please set if to :off
disallow_group_creation_with_api: :on
Expand Down
5 changes: 0 additions & 5 deletions src/api/config/routes.rb
Expand Up @@ -262,11 +262,6 @@

match '/lastevents' => 'public#lastevents'

### /apidocs

match 'apidocs' => 'apidocs#index'
match 'apidocs/:filename' => 'apidocs#file', :constraints => cons

### /distributions

match 'distributions' => 'distribution#index'
Expand Down
32 changes: 0 additions & 32 deletions src/api/test/functional/apidocs_controller_test.rb

This file was deleted.

2 changes: 2 additions & 0 deletions src/webui/Gemfile.lock
Expand Up @@ -104,6 +104,7 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
restility (0.0.5)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
Expand Down Expand Up @@ -158,6 +159,7 @@ DEPENDENCIES
pry (>= 0.9.8.4)
rails (~> 3.2.8)
rdoc
restility (~> 0.0.4)
sass-rails
simplecov-rcov
sqlite3
Expand Down
4 changes: 2 additions & 2 deletions src/webui/app/controllers/application_controller.rb
Expand Up @@ -363,7 +363,7 @@ def validate_xhtml
begin
document = Nokogiri::XML::Document.parse(xmlbody, nil, nil, Nokogiri::XML::ParseOptions::STRICT)
rescue Nokogiri::XML::SyntaxError => e
errors << e.inspect
errors << ("[%s:%s]" % [e.line, e.column]) + e.inspect
errors << put_body_to_tempfile(xmlbody)
end

Expand All @@ -373,7 +373,7 @@ def validate_xhtml
document = nil
errors << put_body_to_tempfile(xmlbody)
ses.each do |e|
errors << e.inspect
errors << ("[%s:%s]" % [e.line, e.column]) + e.inspect
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions src/webui/config/deploy.rb
Expand Up @@ -50,6 +50,7 @@
after "deploy:create_symlink", "config:permissions"

# workaround because we are using a subdirectory of the git repo as rails root
before "deploy:finalize_update", "deploy:apidocs"
before "deploy:finalize_update", "deploy:use_subdir"
after "deploy:finalize_update", "deploy:reset_subdir"
after "deploy:finalize_update", "deploy:notify"
Expand Down Expand Up @@ -154,6 +155,11 @@
end
end

desc "Create API docs"
task :apidocs do
run "cd #{release_path}/docs/api && make"
end

end


3 changes: 3 additions & 0 deletions src/webui/config/environment.rb
Expand Up @@ -38,3 +38,6 @@
end
CONFIG['proxy_auth_mode'] ||= :off
CONFIG['frontend_ldap_mode'] ||= :off

CONFIG['apidocs_location'] ||= File.expand_path("../../docs/api/html/")

4 changes: 4 additions & 0 deletions src/webui/config/routes.rb
Expand Up @@ -259,6 +259,10 @@
match 'user/autocomplete' => :autocomplete
end

### /apidocs
match 'apidocs' => 'apidocs#index'
match 'apidocs/:filename' => 'apidocs#file', constraints: { :filename => %r{[^\/]*} }

# Default route matcher:
#match ':controller(/:action(/:id))(.:format)'
end
24 changes: 24 additions & 0 deletions src/webui/test/functional/apidocs_controller_test.rb
@@ -0,0 +1,24 @@
require File.expand_path(File.dirname(__FILE__) + "/..") + "/test_helper"

class ApidocsControllerTest < ActionController::IntegrationTest

def test_index
# rails 3 will always go to #index
visit "/apidocs/"
# no interest in comparing with index.html
end

def test_subpage
visit "/apidocs/whatisthis"
#assert_response 404
#assert_xml_tag :attributes => { :code => "unknown_file_type" }

visit "/apidocs/whatisthis.xml"
#assert_response 404
#assert_xml_tag :attributes => { :code => "file_not_found" }

visit "/apidocs/project.xml"
#assert_response :success
end

end

0 comments on commit 992aca8

Please sign in to comment.