Permalink
Browse files

Refactorings and updates

  • Loading branch information...
1 parent 7890606 commit 00f85bc3bb5ba710ae5adba6a6ffd5a615a24bb2 @jcnetdev jcnetdev committed Aug 8, 2008
Showing with 4,773 additions and 266 deletions.
  1. +1 −2 app/controllers/search_controller.rb
  2. +12 −1 app/helpers/application_helper.rb
  3. +20 −29 app/helpers/javascript_helper.rb
  4. +0 −6 app/helpers/stylesheet_helper.rb
  5. +3 −1 app/models/job.rb
  6. +3 −2 app/models/job_applicant.rb
  7. +1 −4 app/views/admin/jobs/show.html.haml
  8. +1 −1 app/views/job_requests/new.html.haml
  9. +1 −1 app/views/jobs/edit.html.haml
  10. +1 −1 app/views/jobs/new.html.haml
  11. +1 −1 app/views/jobs/parts/_apply_form.html.haml
  12. +5 −5 app/views/jobs/parts/_details.html.haml
  13. +7 −1 app/views/jobs/parts/_fields.html.haml
  14. +2 −2 app/views/jobs/parts/_textile_suggestions.html.erb
  15. +4 −10 app/views/layouts/_flash_boxes.html.haml
  16. +0 −2 app/views/layouts/_footer.html.haml
  17. +2 −0 app/views/layouts/application.html.haml
  18. +4 −3 app/views/search/_search_results.html.haml
  19. +1 −1 config/environments/development.rb
  20. +4 −0 lib/validation.rb
  21. BIN public/images/{logo.png → logo-trans.png}
  22. +0 −4 public/javascripts/application.js
  23. +0 −33 public/javascripts/common/jobber.js
  24. +2 −0 public/javascripts/ie7.js
  25. +0 −8 public/javascripts/jquery.ext/interface.js
  26. +0 −82 public/javascripts/jquery.ext/jquery.alphanumeric.js
  27. +162 −0 public/javascripts/min/common.js
  28. +126 −0 public/javascripts/min/components.js
  29. +2,740 −0 public/javascripts/min/jquery.ext.js
  30. +450 −0 public/javascripts/min/libraries.js
  31. +0 −64 public/javascripts/supersleight.js
  32. +1,151 −0 public/stylesheets/all_cache.css
  33. +4 −2 public/stylesheets/styles.css
  34. +65 −0 script/merge_assets
@@ -14,8 +14,7 @@ def show
# hide layout for ajax requests
- if params[:ajax] == "true"
- @ajax = true
+ if request.xhr?
render :partial => "search/search_results", :layout => false
else
params[:q] = ""
@@ -1,6 +1,10 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
+ def stylesheets
+ stylesheet "styles", "util", "application", :cache => "all_cache"
+ end
+
def feed_links
links_html = []
@@ -23,6 +27,14 @@ def error_message_for(record, attribute, error_msg = nil)
end
end
+ # display a flash box
+ def flash_box(text, options = {})
+ content_tag :div, :class => "flash #{options[:class]}" do
+ flash[:notice] +
+ link_to("Hide Message...", "#", :class => "close-text")
+ end
+ end
+
def display_notice
page.insert_html :after, 'footer', :partial => 'layouts/admin_flash_boxes'
end
@@ -45,7 +57,6 @@ def add_class_if(condition, css_class)
end
end
-
def link_to_image(image_path, label, url, options={})
link_to(image_tag(image_path, :class => "vert-middle"), url, options) +
nbsp +
@@ -3,44 +3,35 @@ module JavascriptHelper
# Add javascripts to page
def javascripts(options = {})
[
- javascript("prototype"),
- javascript("scriptaculous/scriptaculous"),
-
- javascript("jquery"),
- javascript_tag("$j = jQuery.noConflict();"),
- javascript(include_javascripts("jquery.ext")),
- javascript(include_javascripts("libraries")),
- javascript(include_javascripts("common")),
- javascript(include_javascripts("components")),
+ framework_js,
+
+ # recursively add javascript files from these folders
+ javascript_folder("jquery.ext"),
+ javascript_folder("libraries"),
+ javascript_folder("common"),
+ javascript_folder("components"),
page_javascripts(options),
javascript("application"),
-
+
ie6_js
].flatten.join("\n")
end
- # returns a list of *css file paths* for a sass directory
- def include_javascripts(path)
- if AppConfig.minimize
- "min/#{path}.js"
- else
- javascript_list = Dir["#{RAILS_ROOT}/public/javascripts/#{path}/*.js"]
-
- result = []
- javascript_list.each do |javascript|
- result << javascript.gsub("#{RAILS_ROOT}/public/javascripts/", "")
- end
-
- return result
- end
- end
+ def framework_js
+ [
+ javascript("prototype"),
+ javascript("scriptaculous/scriptaculous"),
+
+ javascript("jquery"),
+ javascript_tag("$j = jQuery.noConflict();")
+ ].flatten.join("\n")
+ end
def ie6_js
- if browser_is? :ie6
- javascript("supersleight")
- end
+ "<!--[if lt IE 7]>
+ <script src='/javascripts/ie7.js' type='text/javascript></script>
+ <![endif]-->"
end
-
end
@@ -1,6 +0,0 @@
-module StylesheetHelper
- # include stylesheets
- def stylesheets(options = {})
- stylesheet "styles", "util", "application"
- end
-end
View
@@ -22,6 +22,8 @@ class Job < ActiveRecord::Base
validates_presence_of :company
validates_presence_of :poster_email
+ validates_format_of :title, :company, :outside_location, :with => Validation::NO_HTML, :message => Validation::NO_HTML_MESSAGE
+
validates_as_email_address :poster_email
before_save :format_fields
@@ -61,7 +63,7 @@ def located_at
# return location if applicable
if self.location
- @located_at = self.location.name
+ @located_at = self.g.name
return @located_at
end
@@ -8,8 +8,9 @@ class JobApplicant < ActiveRecord::Base
has_attached_file :resume
+ attr_protected :job_id
+
def self.new_default(init_values = {})
self.new(init_values)
end
-
-end
+end
@@ -11,10 +11,7 @@
.applied-to-job
= @job.job_applicants.size
%p
- - if @job.job_applicants.size != 1
- applicants
- - else
- applicant
+ = pluralize(@job.job_applicants.size, "applicant")
-# show job title
%h2
@@ -5,7 +5,7 @@
- if @job_hunter.errors.size > 0
.validation-failure
- = image_tag "exclamation.png", :style => "vertical-align: -3px"
+ = image_tag "exclamation.png"
There were a few problems. Please correct the fields labeled in <strong>red</strong>.
= br
@@ -6,7 +6,7 @@
- unless @job.errors.empty?
.validation-failure
- = image_tag "exclamation.png", :style => "vertical-align: -3px"
+ = image_tag "exclamation.png"
Please revise the form...
- form_for @job, :html => {:id => "publish_form", :class => "job-form"} do |f|
@@ -3,7 +3,7 @@
- unless @job.errors.empty?
.validation-failure
- = image_tag "exclamation.png", :style => "vertical-align: -3px"
+ = image_tag "exclamation.png"
Please revise the form...
- form_for @job, :html => {:id => "publish_form", :class => "job-form"} do |f|
@@ -5,7 +5,7 @@
- if job_applicant.errors.size > 0
.validation-failure
- = image_tag "exclamation.png", :style => "vertical-align: -3px"
+ = image_tag "exclamation.png"
Unfortunately, your application could not be sent. Please check the form for missing information and resubmit.
= br
@@ -27,21 +27,21 @@
-# show job title
%h2
= job_type_image(job.job_type)
- = job.title
+ =h job.title
-# show job location
%p
%span.fading at
- unless job.url.blank? or job.url == "http://"
- = link_to job.company, job.url
+ = link_to h(job.company), job.url
- else
- %strong= job.company
+ %strong=h job.company
- if job.located_at == "Anywhere"
- %strong== (#{job.located_at})
+ %strong== (#{h(job.located_at)})
- else
%span.fading in
- %strong= job.located_at
+ %strong=h job.located_at
-# show job description
.job-description
@@ -18,6 +18,8 @@
%td.publish-label{:valign => "top"} Title:
%td
= f.text_field :title, :size => 50
+ = error_message_for(@job, :title)
+
.suggestion e.g. 'PHP Developer', 'UI designer'
-# location field
@@ -29,6 +31,7 @@
#outside_location{hide_if(@job.outside_location.blank?)}
where ?
= f.text_field :outside_location, :size => 50, :maxlength => 140
+ = error_message_for(@job, :outside_location)
.suggestion
e.g. 'London, UK'
@@ -37,6 +40,7 @@
%td{:valign => "top"} Description:
%td
= f.text_area :description, :size => "80x15"
+ = error_message_for(@job, :description)
.suggestion
= link_to "Format text with Textile", "http://www.textism.com/tools/textile/", |
:target => "_blank", :onclick => "$j('#textile-suggestions').toggle();return false;" |
@@ -51,7 +55,8 @@
%td.publish-label Name:
%td
= f.text_field :company, :size => 40
-
+ = error_message_for(@job, :company)
+
-# website field
%tr
%td{:valign => "top"} Website:
@@ -67,6 +72,7 @@
%strong (not published)
%td
= f.text_field :poster_email
+ = error_message_for(@job, :poster_email)
.suggestion
Online applications will be sent to this address.
@@ -2,8 +2,8 @@
<table>
<thead>
<tr class="odd">
- <th>{$translations.publish.syntax}</th>
- <th>{$translations.publish.result}</th>
+ <th>Textile syntax</th>
+ <th>Final result</th>
</tr>
</thead>
<tbody>
@@ -1,17 +1,11 @@
- unless @flash_shown
-
+
-# Set flash[:notice] to display a notice panel
- if flash[:notice]
- .flash.notice
- = flash[:notice]
- = link_to "Hide Message...", "#", :class => "close-text"
+ = flash_box(flash[:notice], :class => "notice")
- elsif flash[:success]
- .flash.success
- = flash[:success]
- = link_to "Hide Message...", "#", :class => "close-text"
+ = flash_box(flash[:success], :class => "success")
- elsif flash[:error]
- .flash.error
- = flash[:error]
- = link_to "Hide Message...", "#", :class => "close-text"
+ = flash_box(flash[:error], :class => "error")
- @flash_shown = true
@@ -41,5 +41,3 @@
.footer-copyright.text-right
Powered by
= link_to "jobberRails", "http://www.jobberrails.com"
- = br
- == port of #{link_to "jobberBase", "http://www.jobberbase.com"}
@@ -5,6 +5,8 @@
= title :site => AppConfig.site_name
= stylesheets
+
+ -# defined in javascript_helper
= javascripts
= feed_links
@@ -1,21 +1,22 @@
%h3
Search Results for
== "#{h(@query)}"
- - if @ajax
+ - if request.xhr?
= link_to "Clear Search", "#", :class => "clear-search"
+
- if @jobs.empty?
%p.empty
No jobs found matching
%strong== #{h(@query)}
- if @category
in
- %strong= @category.name
+ %strong=h @category.name
= br
= link_to "Search Entire Site", search_url(:keywords => @query, :ajax => nil)
- else
= partial "jobs/parts/post_table", :jobs => @jobs, :show_applicants => false
-- if @ajax and !@jobs.empty?
+- if request.xhr? and !@jobs.empty?
= br
= link_to "View Search Results...", search_url(:keywords => @query, :cat_id => params[:cat_id], :ajax => nil)
@@ -11,7 +11,7 @@
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs = true
-config.action_controller.perform_caching = false
+config.action_controller.perform_caching = true
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
View
@@ -0,0 +1,4 @@
+class Validation
+ NO_HTML = /^[^<>]*$/
+ NO_HTML_MESSAGE = 'HTML Tags not Allowed in Titles'
+end
File renamed without changes
@@ -4,8 +4,4 @@ $j(document).ready(function() {
$j(this).example(this.title);
});
-
-
- // fix pngs
- Jobber.FixPng();
});
Oops, something went wrong.

0 comments on commit 00f85bc

Please sign in to comment.