Skip to content
This repository has been archived by the owner on Nov 13, 2019. It is now read-only.

Commit

Permalink
Merge pull request #90 from OSC/manifest_url
Browse files Browse the repository at this point in the history
in manifest, add ability to specify app url
  • Loading branch information
ericfranz committed Dec 12, 2016
2 parents 5914c22 + db27803 commit b694774
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 11 deletions.
6 changes: 5 additions & 1 deletion app/apps/dev_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class DevRouter
attr_reader :name, :owner, :caption, :category

def initialize(name, owner=OodSupport::Process.user.name)
@name = name
@name = name.to_s
@owner = owner
@caption = "Sandbox App"
@category = "Sandbox Apps"
Expand Down Expand Up @@ -40,4 +40,8 @@ def url
def path
@path ||= base_path.join(name)
end

def token
"#{type}/#{name}"
end
end
5 changes: 3 additions & 2 deletions app/apps/manifest.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'yaml'

class Manifest
attr_reader :name, :description, :category, :subcategory, :icon, :role
attr_reader :name, :description, :category, :subcategory, :icon, :role, :url

class InvalidContentError < StandardError
def initialize
Expand Down Expand Up @@ -50,7 +50,7 @@ def self.load_from_string(yaml)
end

def defaults
{"name" => "", "description" => "", "category" => "", "subcategory" => "" , "icon" => "", "role" => ""}
{"name" => "", "description" => "", "category" => "", "subcategory" => "" , "icon" => "", "role" => "", "url" => ""}
end

def initialize(opts)
Expand All @@ -65,6 +65,7 @@ def initialize(opts)
@subcategory = opts.fetch("subcategory")
@icon = opts.fetch("icon")
@role = opts.fetch("role")
@url = opts.fetch("url")
end

def valid?
Expand Down
19 changes: 14 additions & 5 deletions app/apps/ood_app.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class OodApp
attr_reader :router
delegate :owner, :caption, :url, :type, :path, to: :router
delegate :owner, :caption, :type, :path, :name, :token, to: :router

PROTECTED_NAMES = ["shared_apps", "cgi-bin", "tmp"]

Expand All @@ -19,14 +19,23 @@ def initialize(router)
@router = router
end

def name
path.basename.to_s
end

def title
manifest.name.empty? ? name.titleize : manifest.name
end

def url
if manifest.url.empty?
router.url
else
manifest.url % {
app_type: type,
app_owner: owner,
app_name: name,
app_token: token
}
end
end

def has_gemfile?
path.join("Gemfile").file? && path.join("Gemfile.lock").file?
end
Expand Down
4 changes: 3 additions & 1 deletion app/apps/path_router.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# A special router to use to instantiate an OodApp
# object if all you have is the path to the app
class PathRouter
attr_reader :category, :caption, :url, :type, :path
attr_reader :category, :caption, :url, :type, :path, :name, :token

def initialize(path)
@caption = nil
@category = "App"
@url = "#"
@type = :path
@path = Pathname.new(path)
@name = @path.basename.to_s
@token = @name
end

def owner
Expand Down
6 changes: 5 additions & 1 deletion app/apps/sys_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ def self.apps(require_manifest: true)
end

def initialize(name)
@name = name
@name = name.to_s
end

def token
"#{type}/#{name}"
end

def self.base_path
Expand Down
6 changes: 5 additions & 1 deletion app/apps/usr_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class UsrRouter
attr_reader :name, :owner

def initialize(name, owner=OodSupport::Process.user.name)
@name = name
@name = name.to_s
@owner = owner
end

Expand Down Expand Up @@ -91,4 +91,8 @@ def path
def type
:usr
end

def token
"#{type}/#{owner}/#{name}"
end
end

0 comments on commit b694774

Please sign in to comment.