Skip to content

Commit

Permalink
implement issue ruby-china#123 requirement.
Browse files Browse the repository at this point in the history
  • Loading branch information
ichord committed Mar 7, 2012
1 parent 2b8f2f6 commit 66514fd
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.markdown
Expand Up @@ -18,6 +18,12 @@ This is the source code of [Ruby China Group](http://ruby-china.org)
easy_install pygments # 或者 pip install pygments easy_install pygments # 或者 pip install pygments
rake db:migrate rake db:migrate
``` ```
or you can just this issue
```
rake test:init
```
to prepare all the config files and start essential services.

## Deploy ## Deploy


$ cap deploy $ cap deploy
Expand Down
19 changes: 18 additions & 1 deletion Rakefile
Expand Up @@ -21,4 +21,21 @@ namespace :resque do


system("rm /var/run/god/resque-1.8.0*.pid") system("rm /var/run/god/resque-1.8.0*.pid")
end end
end end

namespace :test do
desc "preparing config files..."
task :prepare => :init do
["config","mongoid","redis"].each do |cfgfile|
system("cp config/#{cfgfile}.yml.default config/#{cfgfile}.yml") unless File.exist?("config/#{cfgfile}.yml")
end
end

desc "start essential services.."
task :init do
desc "starting resque..."
system("./script/resque start")
desc "starting sunspot..."
system("bundle exec rake sunspot:solr:start")
end
end
12 changes: 12 additions & 0 deletions app/assets/javascripts/topics.coffee
Expand Up @@ -85,6 +85,18 @@ window.Topics =
Topics.preview($(textarea).val()) Topics.preview($(textarea).val())
false false


onCloseWarning: (msg) ->
msg = "离开本页面将丢失未保存页面!" if !msg
$(window).bind("beforeunload", (e) ->
if $.browser.msie
e.returnValue = msg
else
return msg
)

offCloseWarning: () ->
$(window).unbind("beforeunload")

# pages ready # pages ready
$(document).ready -> $(document).ready ->
$("textarea").bind "keydown","ctrl+return",(el) -> $("textarea").bind "keydown","ctrl+return",(el) ->
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/will_paginate.js
Expand Up @@ -15,7 +15,6 @@
} }
} }
} }
end
} }


function prevPage() { function prevPage() {
Expand Down
16 changes: 16 additions & 0 deletions app/views/topics/_form.html.erb
Expand Up @@ -22,3 +22,19 @@
</div> </div>
</fieldset> </fieldset>
<% end %> <% end %>
<script type="text/javascript">
// not loaded jquery yet.
window.onload = function() {
// have loaed all js now.
Topics.onCloseWarning();
$('.actions>input[type=submit]').click(function(e){
Topics.offCloseWarning();
});
// onbeforeunload conflict with <a> element in IE!!!
// except a.href is not empty(such as #) or a.onclick return false
// "###" let <a> not be a anchor point
if ($.browser.msie) {
$('a[href^="javascript"]').attr('href','###');
}
}
</script>

0 comments on commit 66514fd

Please sign in to comment.