Skip to content

Commit

Permalink
update padrino to 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
robbin committed Mar 25, 2013
1 parent 612283b commit 5139cde
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 120 deletions.
7 changes: 3 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
source 'http://rubygems.org'
#source 'http://ruby.taobao.org'

# Project requirements
gem 'rake'
gem 'padrino-core', :git => 'git://github.com/padrino/padrino-framework.git'
gem 'padrino-helpers', :git => 'git://github.com/padrino/padrino-framework.git'
gem 'padrino-core', '~> 0.11'
gem 'padrino-helpers', '~> 0.11'

# Component requirements
gem 'bcrypt-ruby', :require => 'bcrypt'
Expand All @@ -31,7 +30,7 @@ end
group :development do
gem 'thin'
gem 'pry'
gem 'padrino-gen', :git => 'git://github.com/padrino/padrino-framework.git'
gem 'padrino-gen', '~> 0.11'
end

# Test requirements
Expand Down
82 changes: 39 additions & 43 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
GIT
remote: git://github.com/csdn-dev/second_level_cache.git
revision: 08f0b7b88de51883cf0bba9652435e2124e573a4
revision: 4ea270ded9b64e83f4b382b2ea884606603510a6
specs:
second_level_cache (1.6.0)
second_level_cache (1.6.1)
activesupport (~> 3.2.0)

GIT
remote: git://github.com/padrino/padrino-framework.git
revision: da0d53e6acc777b92460969c4d7c28b22e367588
specs:
padrino-core (0.10.7)
activesupport (>= 3.1.0)
http_router (~> 0.10.2)
sinatra (~> 1.3.1)
thor (~> 0.16.0)
tilt (~> 1.3.0)
padrino-gen (0.10.7)
bundler (~> 1.0)
padrino-core (= 0.10.7)
padrino-helpers (0.10.7)
i18n (~> 0.6)
padrino-core (= 0.10.7)

GIT
remote: git://github.com/robbin/acts-as-taggable-on.git
revision: f52d2b9347a30ce2bdbf4c2d8ad1a7ced7e50d86
Expand Down Expand Up @@ -49,61 +32,74 @@ GEM
carrierwave (0.8.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
coderay (1.0.8)
coderay (1.0.9)
daemons (1.1.9)
dalli (2.6.2)
database_cleaner (0.9.1)
erubis (2.7.0)
eventmachine (1.0.0)
eventmachine (1.0.3)
factory_girl (4.2.0)
activesupport (>= 3.0.0)
github-markdown (0.5.3)
http_router (0.10.2)
http_router (0.11.0)
rack (>= 1.0.0)
url_mount (~> 0.2.1)
i18n (0.6.1)
i18n (0.6.4)
kgio (2.8.0)
method_source (0.8.1)
mime-types (1.21)
mini_magick (3.4)
mini_magick (3.5.0)
subexec (~> 0.2.1)
minitest (2.6.2)
multi_json (1.5.1)
multi_json (1.7.2)
mysql2 (0.3.11)
nokogiri (1.5.6)
pry (0.9.11.4)
nokogiri (1.5.9)
padrino-core (0.11.0)
activesupport (>= 3.1.0)
http_router (~> 0.11.0)
rack-protection (>= 1.5.0)
sinatra (~> 1.4.2)
thor (~> 0.17.0)
tilt (~> 1.3.0)
padrino-gen (0.11.0)
bundler (~> 1.0)
padrino-core (= 0.11.0)
padrino-helpers (0.11.0)
i18n (~> 0.6)
padrino-core (= 0.11.0)
pry (0.9.12)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
rack (1.5.2)
rack-protection (1.3.2)
rack-protection (1.5.0)
rack
rack-test (0.6.2)
rack (>= 1.0)
rainbows (4.4.3)
rainbows (4.5.0)
kgio (~> 2.5)
rack (~> 1.1)
unicorn (~> 4.1)
unicorn (~> 4.6, >= 4.6.2)
raindrops (0.10.0)
rake (10.0.3)
rest-client (1.6.7)
mime-types (>= 1.16)
sanitize (2.0.3)
nokogiri (>= 1.4.4, < 1.6)
sinatra (1.3.4)
rack (~> 1.4)
rack-protection (~> 1.3)
tilt (~> 1.3, >= 1.3.3)
slop (3.4.3)
sinatra (1.4.2)
rack (~> 1.5, >= 1.5.2)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
slop (3.4.4)
subexec (0.2.2)
thin (1.5.0)
thin (1.5.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.16.0)
tilt (1.3.3)
tzinfo (0.3.35)
unicorn (4.6.0)
thor (0.17.0)
tilt (1.3.6)
tzinfo (0.3.37)
unicorn (4.6.2)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
Expand All @@ -128,9 +124,9 @@ DEPENDENCIES
mini_magick
minitest (~> 2.6.0)
mysql2
padrino-core!
padrino-gen!
padrino-helpers!
padrino-core (~> 0.11)
padrino-gen (~> 0.11)
padrino-helpers (~> 0.11)
pry
rack-test
rainbows
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ This is my personal website project.
2. copy `config/app_config.example.yml` to `config/app_config.yml` and copy `config/database.example.yml` to `config/database.yml`
3. modify database config for your need.
4. create database match your database.yml and start your database.
5. run `rake secret` to generate session secret key and fill it in app_config.
6. run `rake ar:migrate` to setup database schema.
7. run `rake seed` to generate admin user.
5. run `bundle exec rake secret` to generate session secret key and fill it in app_config.
6. run `bundle exec rake ar:migrate` to setup database schema.
7. run `bundle exec rake seed` to generate admin user.
8. start memcached with `memcached -d`.
9. run `thin start` for development environment and run `./servicectl start` for production environment.
9. run `bundle exec thin start` for development environment and run `./servicectl start` for production environment.

## Run on Windows

remove such lines in `Gemfile` and run with thin.

gem 'kgio'
gem 'rainbows'

## MIT License
5 changes: 2 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require File.expand_path('../config/boot.rb', __FILE__)
require 'padrino-core/cli/rake'
# PadrinoTasks.use(:activerecord)
# PadrinoTasks.use(:seed)
PadrinoTasks.use(:activerecord)
PadrinoTasks.use(:seed)
PadrinoTasks.init

namespace :metric do
Expand Down
65 changes: 1 addition & 64 deletions app/views/admin/_form.erb
Original file line number Diff line number Diff line change
Expand Up @@ -86,67 +86,4 @@
<%= form.submit '', :class => 'submit' %>
</td>
</tr>
</table>

<% content_for :javascripts do %>
<%= javascript_include_tag 'highlight.min' %>
<script type="text/javascript">
$(function(){
// form validation
$('form#editor input[type=submit]').click(function(){
var error_info = '';
$('div#form-error-info').html('');
if ($('input#blog_title').val().length < 3) {
error_info += '<span>文章标题太短了;</span>';
}
if ($('textarea#blog_content').val().length < 10) {
error_info += '<span>文章内容太少了;</span>';
}
var slugUrl = $('input#blog_slug_url').val();
if (slugUrl.length > 0) {
var re = /^[a-zA-Z0-9\-]{1,}$/;
if (!re.test(slugUrl)) {
error_info += '<span>URL格式错了:只允许字母数字横线</span>';
}
}
if (error_info.length > 0) {
$('div#form-error-info').html(error_info);
return false;
}
});

// toggle add/remove tag to and from input box
$('form#editor div.tag a.tag').click(function(){
var tagName = $.trim($(this).find('span').html());
var tagList = filterTags($('input#blog_user_tags').val());
var index = $.inArray(tagName, tagList)
if (index === -1) {
tagList.push(tagName);
} else {
tagList.splice(index, 1);
}
$('input#blog_user_tags').val(tagList.join(" , ")).focus();
return false;
});

// toggle blog content editor and preview
$('a#show_blog_content_editor').click(function(){
$('a#show_blog_content_editor').addClass('current');
$('a#show_blog_content_preview').removeClass('current');
$('div#blog_content_preview').hide();
$('textarea#blog_content').show();
return false;
});
$('a#show_blog_content_preview').click(function(){
$.post('<%= url(:admin, :blog_preview) %>', {term: $('textarea#blog_content').val()}, function(data){
$('a#show_blog_content_editor').removeClass('current');
$('a#show_blog_content_preview').addClass('current');
$('div#blog_content_preview').html(data).show();
$('textarea#blog_content').hide();
});
return false;
});

});
</script>
<% end %>
</table>
62 changes: 62 additions & 0 deletions app/views/admin/_form_js.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<% content_for :javascripts do %>
<%= javascript_include_tag 'highlight.min' %>
<script type="text/javascript">
$(function(){
// form validation
$('form#editor input[type=submit]').click(function(){
var error_info = '';
$('div#form-error-info').html('');
if ($('input#blog_title').val().length < 3) {
error_info += '<span>文章标题太短了;</span>';
}
if ($('textarea#blog_content').val().length < 10) {
error_info += '<span>文章内容太少了;</span>';
}
var slugUrl = $('input#blog_slug_url').val();
if (slugUrl.length > 0) {
var re = /^[a-zA-Z0-9\-]{1,}$/;
if (!re.test(slugUrl)) {
error_info += '<span>URL格式错了:只允许字母数字横线</span>';
}
}
if (error_info.length > 0) {
$('div#form-error-info').html(error_info);
return false;
}
});

// toggle add/remove tag to and from input box
$('form#editor div.tag a.tag').click(function(){
var tagName = $.trim($(this).find('span').html());
var tagList = filterTags($('input#blog_user_tags').val());
var index = $.inArray(tagName, tagList)
if (index === -1) {
tagList.push(tagName);
} else {
tagList.splice(index, 1);
}
$('input#blog_user_tags').val(tagList.join(" , ")).focus();
return false;
});

// toggle blog content editor and preview
$('a#show_blog_content_editor').click(function(){
$('a#show_blog_content_editor').addClass('current');
$('a#show_blog_content_preview').removeClass('current');
$('div#blog_content_preview').hide();
$('textarea#blog_content').show();
return false;
});
$('a#show_blog_content_preview').click(function(){
$.post('<%= url(:admin, :blog_preview) %>', {term: $('textarea#blog_content').val()}, function(data){
$('a#show_blog_content_editor').removeClass('current');
$('a#show_blog_content_preview').addClass('current');
$('div#blog_content_preview').html(data).show();
$('textarea#blog_content').hide();
});
return false;
});

});
</script>
<% end %>
4 changes: 3 additions & 1 deletion app/views/admin/edit_blog.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
<%= partial 'admin/form', :object => f %>

This comment has been minimized.

Copy link
@hooopo

hooopo Mar 26, 2013

The double render issue with form_for has been fixed: padrino/padrino-framework#1177

<% end %>
</div>
</div>
</div>

<%= partial 'admin/form_js' %>
4 changes: 3 additions & 1 deletion app/views/admin/new_blog.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
<%= partial 'admin/form', :object => f %>
<% end %>
</div>
</div>
</div>

<%= partial 'admin/form_js' %>

0 comments on commit 5139cde

Please sign in to comment.