Permalink
Browse files

Build application finished

  • Loading branch information...
1 parent 68ad595 commit f0dbb65121880cbf5818966f256429ffce17f76b Hallison Batista committed with Hallison Batista Nov 14, 2009
View
@@ -42,8 +42,8 @@ ARGV.options do |arguments|
arguments.parse!
end
rescue => error
- puts arguments
puts error
+ puts arguments
exit 1
end
@@ -5,8 +5,8 @@ class Postview::Application::Build < Sinatra::Base #:nodoc: all
configure do
set :root, Postview::ROOT
- set :public, root.join("lib/postview/application/shared/public")
- set :views, root.join("lib/postview/application/shared/views")
+ set :public, root.join("lib/postview/application/share")
+ set :views, root.join("lib/postview/application/views")
enable :static
@@ -15,14 +15,20 @@ class Postview::Application::Build < Sinatra::Base #:nodoc: all
end
helpers do
- attr_reader :page, :settings, :build_path, :errors
+ attr_reader :page, :settings, :postview_path, :errors, :builded
def site_settings_valid?
site_domain_errors
site_email_errors
site_author_erros
site_password_errors
- errors.values.compact.empty?
+ no_errors?
+ end
+
+ def no_errors?
+ ATTRIBUTES_REQUIRED.map do |invalid|
+ errors.send(invalid)
+ end.compact.empty?
end
end
@@ -36,28 +42,26 @@ def site_settings_valid?
# Show all information for site.
get root_path do
- page.title = "Settings"
- erb :setup
+ page.title = "Build blog settings"
+ erb :build
end
post build_path do
- page.title = "Build "
if site_settings_valid?
build!
- page.title += "successfuly"
- erb :build
- else
- page.title += "failure"
- erb :setup
+ page.title = "Build successfully"
end
+ erb :build
end
private
+ ATTRIBUTES_REQUIRED = [ :postview_path, :site_domain, :site_author, :site_email, :password ]
REGEX_DOMAIN = /((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$/
REGEX_EMAIL = /^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@#{REGEX_DOMAIN}/
def settings_initialize
+ @builded = false
@settings = Postview::Settings.new(settings_params)
@settings.site[:token] = Postview::Site.tokenize(@settings.site[:author], params[:password], @settings.site[:domain])
end
@@ -69,52 +73,54 @@ def settings_params
end
def page_initialize
- @page ||= OpenStruct.new(:name => "Build", :title => "", :keywords => "")
+ @page ||= OpenStruct.new(:title => "", :keywords => "")
end
- # All fields required
+ # Fields required
def errors_initialize
- @errors = [ :domain, :author, :email, :password ].inject({}) do |hash, attribute|
- hash[:attribute] = nil
- hash
- end
+ @errors = Struct.new(*ATTRIBUTES_REQUIRED).new
end
def build_path_initialize
- @build_path = params[:build_path] || Postview.path
+ @postview_path = params[:postview_path] || Postview.path
end
def site_domain_errors
return unless params[:site]
- errors[:domain] = "Domain is required" if params[:site][:domain].to_s.empty?
- errors[:domain] = "Domain must be an address" unless params[:site][:domain].match(REGEX_DOMAIN)
+ errors.site_domain = "Domain is required" if params[:site][:domain].to_s.empty?
+ errors.site_domain = "Domain must be an address" unless params[:site][:domain].match(REGEX_DOMAIN)
end
def site_email_errors
return unless params[:site]
- errors[:email] = "Email is required" if params[:site][:email].to_s.empty?
- errors[:email] = "Email must be an address" unless params[:site][:email].to_s.match(REGEX_EMAIL)
+ errors.site_email = "Email is required" if params[:site][:email].to_s.empty?
+ errors.site_email = "Email must be an address" unless params[:site][:email].to_s.match(REGEX_EMAIL)
end
def site_author_erros
return unless params[:site]
- errors[:author] = "Author name is required" if params[:site][:author].to_s.empty?
+ errors.site_author = "Author name is required" if params[:site][:author].to_s.empty?
end
def site_password_errors
- errors[:password] = "Password is required" if params[:password].to_s.empty?
+ errors.password = "Password is required" if params[:password].to_s.empty?
end
def settings_yaml
@settings.to_hash.to_yaml.gsub(/^--- /,'')
end
def build!
- ARGV.clear
- require 'ruby-debug'
- debugger
- ARGV << "#{build_path}" << "--yaml" << settings_yaml
- Postview::CLI.run :create, ARGV
+ begin
+ ARGV.clear
+ ARGV << "#{postview_path}" << "--yaml" << settings_yaml
+ Postview::CLI.run :create, ARGV
+ @builded = true
+ rescue RuntimeError => error
+ page.title = "Build failure"
+ errors.postview_path = error.to_s
+ throw(:halt, [401, erb(:build)])
+ end
end
end # class Postview::Application::Build
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -12,29 +12,33 @@ body {
}
fieldset {
- margin: 8pt 4pt;
+ margin: 4px 0;
padding: 4pt;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border: 1px solid #777;
}
fieldset legend {
- padding: 4pt;
- font-size: 10pt;
+ padding: 4px;
+ font-size: 14px;
}
label {
margin: 2px;
- font-size: 8pt;
- text-shadow: 0px 0px 2px #777;
+ font-size: 12px;
+ text-shadow: 0px 0px 1px #777;
}
a {
color: inherit;
text-decoration: none;
}
+img {
+ border: none;
+}
+
.field {
margin: 2px 4px;
}
@@ -61,18 +65,9 @@ a {
}
.field.error input {
- -moz-box-shadow: inset 0 0 4px #E33;
- -webkit-box-shadow: inset 0 0 4px #E33;
-}
-
-.field.large input {
- display: block;
-}
-
-.commandset {
- -moz-border-radius: 4px;
- -webkit-border-radius: 4px;
- border: 1px solid #AAA;
+ -moz-box-shadow: 0 0 4px #E03030;
+ -webkit-box-shadow: 0 0 4px #E03030;
+ border-color: #E03030;
}
.command {
@@ -84,86 +79,82 @@ a {
text-shadow: 0px 0px 2px #FFF;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
- border: 1px solid #777;
+ border: 1px solid #444;
-moz-box-shadow: 0 0 2px #000;
-webkit-box-shadow: 0 0 2px #000;
- background: #E0E0E0 url(../images/gradient-1x16bs.png) repeat-x bottom left;
+ background: #E0E0E0 url(../images/gradient-bottom-1x24.png) repeat-x bottom left;
}
.command:hover {
color: #FFF;
text-shadow: 0px 0px 2px #000;
- border: 1px solid #000;
- background: #A7A7A7 url(../images/gradient-1x16bs.png) repeat-x bottom left;
+ border-color: #000;
+ background-color: #A7A7A7;
}
#layout {
display: block;
clear: both;
- width: 100%;
-/*
+ width: 780px;
+ margin-top: 32px;
margin-left: auto;
margin-right: auto;
- -moz-border-radius: 8px;
- -webkit-border-radius: 8px;
- background-color: #DADAEB;
- border: 8px solid #5C5C9C;
- -moz-box-shadow: 0 0 6px #000;
- -webkit-box-shadow: 0 0 6px #000;/**/
+ padding: 6px;
+ -moz-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ -moz-box-shadow: 0 0 16px #000;
+ -webkit-box-shadow: 0 0 16px #000;
+ background-color: #F0F0FF;
+}
+
+#logo {
+}
+
+#title, #subtitle {
+ text-shadow: 2px 0 1px #7F7F7F;
+}
+
+#subtitle {
+ font-size: 10pt;
}
#header, #content, #footer {
- margin: 4pt;
padding: 4pt;;
- background-color: #FFF;
position: relative;
}
#header {
- height: 128px;
+ color: #3F3F3F;
+ border-bottom: 1px solid #7F7F7F;
}
-#header, #footer {
- float: left;
- width: inherit;
- margin: 0 0 4pt;
- padding: 0;
- color: #FFF;
- background-color: #1F3366;
- -moz-box-shadow: 0 0 14pt #000;
- -webkit-box-shadow: 0 0 14pt #000;
+#footer {
+ border-top: 1px solid #7F7F7F;
}
-#content {
+#header, #footer {
+ margin-left: auto;
+ margin-right: auto;
+ padding: 0;
}
#footer {
- margin: 4pt 0pt 0pt;
+ margin-bottom: 0;
text-align: center;
+ -moz-border-radius: 4px 4px 0 0;
+ -webkit-border-radius: 4px 4px 0 0;
}
-#header #version {
- float: right;
- font-size: 10pt;
-}
-
-#header * {
- margin: 0;
- padding: 0;
- font-family: serif;
+#header>*, #footer>* {
+ margin: 4px;
+ padding: 4px;
}
#content {
display: block;
clear: both;
- position: relative;
- top: -60pt;
- width: 600pt;
- margin-left: auto;
- margin-right: auto;
- background-color: #FFF;
- border: 8px solid #5C6E9A;
- -moz-box-shadow: 0 0 14pt #000;
- -webkit-box-shadow: 0 0 14pt #000;
- background: #FFF url(../images/gradient-1x256ts.png) repeat-x top left;
+}
+
+#postview_path {
+ width: 732px;
}
@@ -1,2 +0,0 @@
-<%=page.title%>
-builded
Oops, something went wrong.

0 comments on commit f0dbb65

Please sign in to comment.