-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shuffle helper modules into their own files.
- Loading branch information
1 parent
f889ae3
commit d2734fe
Showing
14 changed files
with
351 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module AudienceAdminSeperation | ||
module InstanceMethods | ||
def admin_window?; !owner; end | ||
def audience_window?; !admin_window?; end | ||
def audience_friendly_url?(url); $audience_visible_urls.any? { |re| url =~ re }; end | ||
end | ||
module ClassMethods | ||
def audience_friendly_urls(*urls) | ||
$audience_visible_urls ||= [] | ||
$audience_visible_urls += urls | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module ConfigHelper | ||
def upload(url, file, key, username, password) | ||
res = '' | ||
url = URI.parse(url) | ||
File.open(File.join(LIB_DIR,file)) do |conf| | ||
req = Net::HTTP::Post::Multipart.new(url.path, | ||
key => UploadIO.new(conf, "application/octet-stream", File.join(LIB_DIR,file))) | ||
req.basic_auth username, password | ||
res = Net::HTTP.start(url.host, url.port) do |http| | ||
http.request(req) | ||
end | ||
end | ||
res.body | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module DefaultStyles | ||
def custom_font | ||
nil | ||
end | ||
|
||
def text_color | ||
nil | ||
end | ||
|
||
def link_color | ||
nil | ||
end | ||
|
||
def link_hover | ||
nil | ||
end | ||
|
||
def link_hover_background | ||
nil | ||
end | ||
|
||
def container_background | ||
nil | ||
end | ||
|
||
def container_border | ||
nil | ||
end | ||
|
||
def button_background | ||
nil | ||
end | ||
|
||
def button_border | ||
nil | ||
end | ||
|
||
def divider_color | ||
nil | ||
end | ||
|
||
def right_bar_color | ||
nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
module MainHelper | ||
def button(text, styles={}, &callback) | ||
if admin_window? | ||
stack(:height => 32, :width => styles[:width]||(40+(text.length * 8)), :margin => [5,10,5,0], :padding_top => 0) do | ||
background(button_background||styles[:fill]||("#e5e6e6"..."#c1c2c4"), :curve => 1) | ||
border(button_border||styles[:border]||"#ffcf01") | ||
t = inscription(text, :align => styles[:align]||'center', :stroke => styles[:stroke]||black, :margin => styles[:margin]||[0]*4) | ||
click &callback | ||
hover { | ||
self.cursor = :hand | ||
} | ||
leave { | ||
self.cursor = :arrow | ||
} | ||
end | ||
end | ||
end | ||
|
||
def left_button(text, styles={}, &callback) | ||
button(text, styles.merge({:width => 1.0, :align => 'left', :margin => [10,0,0,0]}), &callback) | ||
end | ||
|
||
def light_button(text, styles={}, &callback) | ||
button(text, styles.merge({}), &callback) | ||
end | ||
|
||
def image_button(path,styles={}, &callback) | ||
if admin_window? | ||
stack(:margin_top => 8, :width => 20) do | ||
click &callback | ||
b = background(link_hover_background||"#ffcf01") | ||
image path | ||
b.hide | ||
hover { | ||
b.show | ||
self.cursor = :hand | ||
} | ||
leave { | ||
b.hide | ||
self.cursor = :arrow | ||
} | ||
end | ||
end | ||
end | ||
|
||
def delete_button(styles={}, &callback) | ||
image_button("media/cross.png", styles, &callback) | ||
end | ||
def edit_button(styles={}, &callback) | ||
image_button("media/application_form_edit.png", styles, &callback) | ||
end | ||
|
||
def container | ||
background(container_background||("#e5e6e6"..."#babcbe"), :curve => 1) | ||
border(container_border||"#ffcf01") | ||
end | ||
|
||
def session | ||
if(defined?(@@session) && @@session) | ||
@@session | ||
else | ||
@@session = {:referrer => []} | ||
end | ||
end | ||
|
||
def separator_line(n=45) | ||
flow(:height => 18, :scroll => false) do | ||
inscription '_'*n, :margin => [0]*4, :stroke => divider_color||"#ffcf01" | ||
end | ||
end | ||
|
||
def small_logo | ||
if(defined?(SKIN)&&File.exist?("media/skins/#{SKIN}/logo_text.png")) | ||
image("media/skins/#{SKIN}/logo_text.png", :attach => Window, :top => 30, :left => WIDTH-110) | ||
else | ||
image("media/logo_text.png", :attach => Window, :top => 30, :left => WIDTH-110) | ||
end | ||
end | ||
end |
Oops, something went wrong.