python 分析Google音乐下载地址(二)
2009-09-25 13:49
363 查看
Cells主页
http://cells.rubyforge.org/
Engine主页http://rails-engines.org/
我最先使用的是engine, 因为项目的需要, 接触这个东西, 整体感觉是根本不实用, 刚听起使用engine可以把rails项目当插件来使用, 确实是很吸引人的一个想法, 这样项目的可重用性很高, 可事实并不心如人意, 要知道模板项目并不总能尽如人意, 总会有跟实际需求不同之处, 遇到这样的问题, 个人觉得两种方式, 改模板项目(太不值得了, 可若是改动太大, 那不如直接全部重写controller), 或者扩展(小的冲突还可以这么做. 总之使用engine是一个两难的境地, 扩展进来相当的不愉悦.
之后, 发现cells 这么个东西, 说实话, 第一眼看起并不起眼, 当第一次兴趣使然去使用的时候发现, 这个正是我想要的东西, 扩展性相当的强. 而且不会破坏将有的controller, 使你的controller很简洁, 却又能很方便的引入其它的模块.
看个例子这里使用两个插件: cells, ym4r_gm(附件内有)ruby script/generate cell map google_map (generate生成cell, 附件里有这个插件)
map_cell.rbclass MapCell < Cell::Base
def google_map
@map = GMap.new("map_div_id")
@map.control_init(:large_map => true, :map_type => true)
@map.center_zoom_init([75.5,-42.56], 4)
marker = GMarker.new([75.6, -42.467], :title => "Where Am I?", :info_window => "Hello, Greenland")
@map.overlay_init(marker)
nil # returning nil says "render the view named newest.html.[erb|haml|...]".
end
end
google_map.html.erb<div id="joey">
<%= @map.to_html %>
<%= @map.div(:width => 600, :height => 400) %>
</div>
<% #= link_to_remote :url => { :action => "update", :controller => "home"} %>
<%= link_to "hello"%>
home_controller.rbclass HomeController < ApplicationController
def index
end
end
home/index.html.erb<div><%= render_cell(:map, :google_map, :message => "hello joey") %></div>
如果你按上面所做成功, 那么home页面上面你就可以成功的看到google map了, 而从中你可以看见, 整个过程home controller内很简洁, 假若你在很多个页面上都需要google map, 那个只要同样的一句<div><%= render_cell(:map, :google_map, :message => "hello joey") %></div>即可
这是我首先体会到cells的好处, 但说实话, 还没了解其精髓.本文出自 “建四狼” 博客,请务必保留此出处http://andyss.blog.51cto.com/315552/100946
http://cells.rubyforge.org/
Engine主页http://rails-engines.org/
我最先使用的是engine, 因为项目的需要, 接触这个东西, 整体感觉是根本不实用, 刚听起使用engine可以把rails项目当插件来使用, 确实是很吸引人的一个想法, 这样项目的可重用性很高, 可事实并不心如人意, 要知道模板项目并不总能尽如人意, 总会有跟实际需求不同之处, 遇到这样的问题, 个人觉得两种方式, 改模板项目(太不值得了, 可若是改动太大, 那不如直接全部重写controller), 或者扩展(小的冲突还可以这么做. 总之使用engine是一个两难的境地, 扩展进来相当的不愉悦.
之后, 发现cells 这么个东西, 说实话, 第一眼看起并不起眼, 当第一次兴趣使然去使用的时候发现, 这个正是我想要的东西, 扩展性相当的强. 而且不会破坏将有的controller, 使你的controller很简洁, 却又能很方便的引入其它的模块.
看个例子这里使用两个插件: cells, ym4r_gm(附件内有)ruby script/generate cell map google_map (generate生成cell, 附件里有这个插件)
map_cell.rbclass MapCell < Cell::Base
def google_map
@map = GMap.new("map_div_id")
@map.control_init(:large_map => true, :map_type => true)
@map.center_zoom_init([75.5,-42.56], 4)
marker = GMarker.new([75.6, -42.467], :title => "Where Am I?", :info_window => "Hello, Greenland")
@map.overlay_init(marker)
nil # returning nil says "render the view named newest.html.[erb|haml|...]".
end
end
google_map.html.erb<div id="joey">
<%= @map.to_html %>
<%= @map.div(:width => 600, :height => 400) %>
</div>
<% #= link_to_remote :url => { :action => "update", :controller => "home"} %>
<%= link_to "hello"%>
home_controller.rbclass HomeController < ApplicationController
def index
end
end
home/index.html.erb<div><%= render_cell(:map, :google_map, :message => "hello joey") %></div>
如果你按上面所做成功, 那么home页面上面你就可以成功的看到google map了, 而从中你可以看见, 整个过程home controller内很简洁, 假若你在很多个页面上都需要google map, 那个只要同样的一句<div><%= render_cell(:map, :google_map, :message => "hello joey") %></div>即可
这是我首先体会到cells的好处, 但说实话, 还没了解其精髓.本文出自 “建四狼” 博客,请务必保留此出处http://andyss.blog.51cto.com/315552/100946
相关文章推荐
- python 分析Google音乐下载地址(一)
- Python 分析youku sohu tudou视频各种清晰度的下载地址
- 一步步分析百度音乐的播放地址,利用Python爬虫批量下载
- 一步步分析百度音乐的播放地址,利用Python爬虫批量下载
- python-mysql软件下载地址
- 极限挑战2(林志玲特辑)分段视频下载地址及分析
- Android水面落叶动态壁纸源码及分析 附下载地址
- python 在线文档和下载地址
- TraceWatch等10个强大开源Web流量分析工具下载地址
- python---到指定https地址下载图片验证码,https,urllib2,urllib,time,os,ssl
- 抓取分析网页批量下载评书(2)之分析下载地址
- 各种python 包的exe安装包下载地址
- python将下载地址转换成迅雷和qq旋风的下载地址
- python获取Stanford AI课程的批量下载地址
- Python: 从 指定地址 下载文件 到 本地目录(附源码)
- python 视频教程大全下载地址
- visual studio中的python插件下载地址
- python下载地址 windows
- 普通下载url与迅雷快车旋风下载地址转换原理分析
- 各种Python库安装包下载地址与安装过程详细介绍(Windows版)