-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathopensprints.rb
128 lines (115 loc) · 4.8 KB
/
opensprints.rb
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
$LOAD_PATH.insert(-1,'./lib/sequel/lib')
Shoes.setup do
gem "activesupport 2.3.8"
gem "r18n-desktop"
# gem "sequel 3.5.0"
source "http://gemcutter.org"
gem "opensprints-core 0.6.2"
gem "multipart-post"
end
require 'lib/shoes_extensions'
Dir.glob('lib/helpers/*.rb').each do |helper|
require helper
end
class Main < Shoes
url '/', :index
include DefaultStyles
extend AudienceAdminSeperation::ClassMethods
include AudienceAdminSeperation::InstanceMethods
include MainHelper
def custom_styles
if Shoes::FONTS.grep(/Avenir/).any?
default_font = "Avenir Black"
else
default_font = "Delicious Heavy"
end
style(Banner, :size => 48, :stroke => text_color||black, :font => custom_font||default_font)
style(Title, :size => 34, :stroke => text_color||black, :font => custom_font||default_font)
style(Subtitle, :size => 26, :stroke => text_color||black, :font => custom_font||default_font)
style(Tagline, :size => 18, :stroke => text_color||black, :font => custom_font||default_font)
style(Caption, :size => 14, :stroke => text_color||black, :font => custom_font||default_font)
style(Para, :size => 12, :margin => [0]*4, :weight => "Bold", :stroke => text_color||black, :font => custom_font||default_font)
style(Inscription,:size => 10, :stroke => text_color||black, :margin => [0]*4, :font => custom_font||default_font)
style(Code, :family => 'monospace')
style(Del, :strikethrough => 'single')
style(Em, :emphasis => 'italic')
style(Ins, :underline => 'single')
style(Link, :underline => 'none', :stroke => link_color||"#ffcf01")
style(LinkHover, :underline => 'none', :stroke => link_hover||black, :fill => link_hover_background||"#ffcf01")
style(Strong, :weight => 'bold')
style(Sup, :rise => 10, :size => 'x-small')
style(Sub, :rise => -10, :size => 'x-small')
end
def index
layout(:main)
if(defined?(SKIN)&&File.exist?("media/skins/#{SKIN}/logo_with_text.png"))
logoimage = "media/skins/#{SKIN}/logo_with_text.png"
else
logoimage = "media/logo_with_text.png"
end
@header.clear
@nav.clear
@center.clear {
stack {
flow(:attach => Window, :top => (@center.height * 0.2).to_i, :left => (WIDTH / 2)-350) { image(logoimage) }
if admin_window?
flow(:attach => Window, :top => (@center.height * 0.6).to_i, :left => (WIDTH / 2)-350) {
caption(link($i18n.categories, :click => "/categories"))
caption(" / ", :stroke => link_color)
caption(link($i18n.events, :click => "/tournaments"))
caption(" / ", :stroke => link_color)
caption(link($i18n.configuration, :click => "/configuration"))
}
flow(:attach => Window, :top => (@center.height * 0.65).to_i, :left => (WIDTH / 2)-250) {
caption(link("AUDIENCE WINDOW", :click => lambda{
if !$child && !owner # if we are the parent, and we haven't yet created the child
$child = window(:height => HEIGHT_AUDIENCE, :width => WIDTH_AUDIENCE, :scroll => false, :title => TITLE)
end
} ))
}
end
}
}
end
def nav
@nav = flow(:attach => Window, :top => 0, :left => 20) {
button($i18n.return_to_main_menu) { visit "/" }
}
end
def layout(background_type=:race)
if audience_window?
animate(20) do
if owner.location != app.location && audience_friendly_url?(owner.location)
visit owner.location
end
end
end
self.cursor = :arrow
custom_styles
background BACKGROUND_COLOR if(defined?(BACKGROUND_COLOR))
if(background_type==:menu)
background MENU_BACKGROUND_IMAGE if(defined?(MENU_BACKGROUND_IMAGE))
background "media/skins/#{SKIN}/background_menus.png" if(defined?(SKIN)&&File.exist?("media/skins/#{SKIN}/background_menus.png"))
elsif(background_type==:race)
background BACKGROUND_IMAGE if(defined?(BACKGROUND_IMAGE))
background "media/skins/#{SKIN}/background_race.png" if(defined?(SKIN)&&File.exist?("media/skins/#{SKIN}/background_race.png"))
elsif(background_type==:main)
background BACKGROUND_IMAGE if(defined?(BACKGROUND_IMAGE))
background "media/skins/#{SKIN}/background_main.png" if(defined?(SKIN)&&File.exist?("media/skins/#{SKIN}/background_main.png"))
end
nav
@header = flow do
title @title||TITLE
end
@left = stack(:width => 150) do
end
@center = flow(:width => width - (300), :height => ((USABLE_HEIGHT||HEIGHT)[email protected])) do
end
@right = flow(:width => 150) do
end
end
end
#YAY HAPPY FUN TIME UN-NAMESPACING
Kernel::Main = Main
require 'lib/setup.rb'
Shoes.app(:height => HEIGHT, :width => WIDTH, :scroll => false, :title => TITLE)