现在的位置: 首页 > 综合 > 正文

hpcasts.com 视频学习网站源代码分析–(1)

2013年10月25日 ⁄ 综合 ⁄ 共 953字 ⁄ 字号 评论关闭

本网站基于 ruby  on rails。

第一步: 查看配置

https://github.com/happypeter/onestep/blob/master/config/routes.rb

获取首页信息:

 root :to => 'info#marketing'

可以看出目前的首页是指向 info的marketing 函数

第二步:查看首页:

https://github.com/happypeter/onestep/blob/master/app/controllers/info_controller.rb

---------------------------------------------

 def marketing
    @recent_courses
=
Course.find(:all,
:order => "id desc",
:limit => 3)
    @user =
User.new
  end
-----------------------------------------------

获取了三门课程和登录的用户信息。

第三步:查看marketing对应的模板

https://github.com/happypeter/onestep/blob/master/app/views/info/marketing.html.erb

<%= render "shared/home_masthead" %>
<%= render "shared/marketing" %>

使用shared 的两个模板

shared/home_masthead

  <div class="masthead">
    <div class="container">
      <%= render 'shared/mini_player' %>
      <div class="home-signup">
        <%= render 'shared/home_signup_form' %>
      </div>
    </div>
  </div>

网页中间显示的播放部分。

https://github.com/happypeter/onestep/blob/master/app/views/shared/_marketing.html.erb

首页底下显示的3们课程。
 

抱歉!评论已关闭.