diff --git a/Gemfile b/Gemfile index b77a2cd..0694f18 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,8 @@ gem 'foundation-rails', '~> 5.4' gem 'foundation-icons-sass-rails' gem 'font-awesome-sass' +gem 'jbuilder' + gem 'mongoid' gem 'mongoid-pagination' gem 'redcarpet' diff --git a/Gemfile.lock b/Gemfile.lock index c3f6d99..6d0ca94 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -101,6 +101,9 @@ GEM html_truncator (0.4.0) nokogiri (~> 1.5) i18n (0.6.11) + jbuilder (2.2.6) + activesupport (>= 3.0.0, < 5) + multi_json (~> 1.2) jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) @@ -288,6 +291,7 @@ DEPENDENCIES guard-rails guard-rspec html_truncator + jbuilder jquery-rails mini_magick mongoid diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 79f30d4..175138c 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -4,6 +4,10 @@ class BlogsController < ApplicationController def index @newest = Post.desc(:created_at).first @recent = Post.desc(:created_at).to_a[1..3] + respond_to do |format| + format.html + format.json + end end def rss @@ -18,6 +22,10 @@ class BlogsController < ApplicationController @prev = Post.where(:created_at.lt => @post.created_at).desc(:created_at).where(:id.ne => @post.id).first @next = Post.where(:created_at.gt => @post.created_at).asc(:created_at).where(:id.ne => @post.id).first @comments = @post.comments + respond_to do |format| + format.html + format.json + end end def edit diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 95f2992..3f6027c 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,4 +1,8 @@ class HomeController < ApplicationController def index end + + def mobile + render layout: false + end end diff --git a/app/views/blogs/index.json.jbuilder b/app/views/blogs/index.json.jbuilder new file mode 100644 index 0000000..c90cd4b --- /dev/null +++ b/app/views/blogs/index.json.jbuilder @@ -0,0 +1,6 @@ +if @newest.present? + json.id @newest.id.to_s + json.extract! @newest, :title, :sub_content, :type, :labels_content, :created_at +else + json.null! +end diff --git a/app/views/blogs/show.json.jbuilder b/app/views/blogs/show.json.jbuilder new file mode 100644 index 0000000..843b3eb --- /dev/null +++ b/app/views/blogs/show.json.jbuilder @@ -0,0 +1 @@ +json.extract! @post, :title, :type, :labels_content, :content_html, :created_at diff --git a/app/views/home/mobile.html.slim b/app/views/home/mobile.html.slim new file mode 100644 index 0000000..0d41fa6 --- /dev/null +++ b/app/views/home/mobile.html.slim @@ -0,0 +1,54 @@ +.card + .item.item-divider + | 个人介绍 + .item.item-text-wrap + p + | Hi, 我是技术达人李亚飞. + p + | 你看到的是我的个人博客 APP 版. + p + | 这是一个拥有独立思想的技术达人的交流分享的地方. + p + | 我曾经在深信服工作大约 5 年. 在那里, 从一个菜鸟成长为一个资深工程师, 还有幸带领一个很酷的团队帮助公司进行自动化测试方向的研究与推进. + p + | 在 2014 年 3 月份, 为了那份创业梦, 开发了 http://cywin.cn, 这是一个股权众筹平台, 帮助创业团队更好的融资. 借此, 也将自己的 Ruby on Rails 技术全部注入在内. + p + | 现在, 想先休息一段时间, 接下来做一个自由职业者, 接手一些关于 Web 开发的外包工作. + +.card + .item.item-divider + | 技术栈 + .item.item-text-wrap + ul + li Ruby on Rails + li Linux / OSX + li Git / Svn + li Angularjs + li Bootstrap / Foundation5 + li jQuery + li HTML5 + li CSS3 + li Testing Automation + li Deploying Automation + li PostgreSQL / Mysql / Mongodb + +.card + .item.item-divider + | 联系我 + .item.item-text-wrap + p + | 我目前处于自由职业状态, 如果你想咨询一些创业的项目建议, 甚至期望得到开发方面的帮助, 欢迎联系我. + + p + | 不要紧张, 请随时联系我. + + p + a href="mailto:lyfi2003@gmail.com" lyfi2003@gmail.com + +.card + .item.item-divider + | 版权说明 + .item.item-text-wrap + p + | WBlog 是我亲手一行行写出来的, 开源可复用, 采用协议 MIT, 你可以在 Github 上找到它: + a href='https://github.com/windy/wblog' https://github.com/windy/wblog diff --git a/config/routes.rb b/config/routes.rb index df55ccf..cb6b082 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,5 +37,6 @@ WBlog::Application.routes.draw do end get '/about' => 'home#index' + get '/mobile' => 'home#mobile' get '/:type' => 'archives#index', constraints: { type: /tech|life|creator/ } end