搜尋此網誌

2007/12/25

將你拍的照片秀在GoogleEarth上

只要有心,人人都可以是攝影記錄者


Google Earth,一個由Google所推出的地圖軟體,可以看全世界的地圖,除了一般版本外,付費版本除了增強效率,也有可由其它的GPS裝置匯入的功能。不過Google Earth有趣的是,你可以把自己的照片放在Google Earth上,只要通過Google Earth的審核程序,過一段時間照片就會出現在Google Earth上。
我用的方式是在http://www.panoramio.com/註冊,然後將照片和經緯度輸入後,就會進入審核程序至於如何在Google Earth中看到你的照片,參考http://www.panoramio.com/help/#GE_1

2007/12/19

簡單的Rails 2.02例子

幾行指令就能產生一個簡單的具有CRUD (Create, Read, Update, Delete) 功能的網頁



要產生一個能有簡單功能的網頁,在Rails中是很簡單的:
  • 首先,自行建立一個目錄做為開發的目錄,例如E:\RoR\www
  • 再來,開啟命令提示字元,在此我們要建立一個簡單的書目資料。輸看以下指令:「rails -d mysql books」來建立基本架構。
  • 「cd books」切換到目錄
  • 輸入以下指令「ruby script/generate scaffold Book title:string price:integer description:text year:datetime published:boolean」,本指令告訴Rails產生scaffold,並在頁面中,有書名,價格,說明,出版日期和是否已出版。
  • 修改config目錄中的database.yml,找到development:下的資料,輸入正確的mysql連線資料。
  • 利用mysql工具產生books_development資料庫
  • 輸入以下指今產生資料表「rake db:migrate」
  • 如果沒有錯誤的話,基本上一個簡單的Rails網頁程式已經弄好了,要測試是否可以執行,輸入「ruby script/server」,開始執行後,打開Firefox或是其它的網頁瀏覽器,在URL中輸入「http://localhost:3000/books」,就會看到簡單的頁面出來,並且可以CRUD
mysql在建立的時候,必需使用utf-8編碼,如此一來,便可以直接存中文,Rails 2.02本身已經可以顯示和修改中文沒有問題,不用做任何的修改。


2007/12/18

Ruby on Rails 2.02 在Windows平台上的安裝筆記

最近看了一下Ruby on Rails的網頁開發技術,還蠻有趣的...也很可怕
RoR 2.02(2007/12/18會傳回403 Forbidden)剛剛出來,很難直接由網路安裝,相信過一陣子之後,應該可以直接安裝。以下是個人在Windows XP上的安裝。


actionmailer-2.0.2.gem
actionmailer-2.0.2.zip
actionpack-2.0.2.gem
actionpack-2.0.2.zip
activerecord-2.0.2.gem
activerecord-2.0.2.zip
activeresource-2.0.2.gem
activeresource-2.0.2.zip
activesupport-2.0.2.gem
activesupport-2.0.2.zip
rails-2.0.2.gem
rails-2.0.2.zip
win32-service-0.6.0-x86-mswin32-60.gem
win32-service-0.6.0.zip
  • 依序安裝Gems,以便裝好Rails,Mongrel和mysql相關的library:

E:\RoR>gem install activesupport-2.0.2.gem
Successfully installed activesupport, version 2.0.2
Installing ri documentation for activesupport-2.0.2-...
Installing RDoc documentation for activesupport-2.0.2-...

E:\RoR>gem install activerecord-2.0.2.gem
Successfully installed activerecord, version 2.0.2
Installing ri documentation for activerecord-2.0.2-...
Installing RDoc documentation for activerecord-2.0.2-...

E:\RoR>gem install actionpack-2.0.2.gem
Successfully installed actionpack, version 2.0.2
Installing ri documentation for actionpack-2.0.2...
Installing RDoc documentation for actionpack-2.0.2...

E:\RoR>gem install actionmailer-2.0.2.gem
Successfully installed actionmailer, version 2.0.2
Installing ri documentation for actionmailer-2.0.2...
Installing RDoc documentation for actionmailer-2.0.2...

E:\RoR>gem install activeresource-2.0.2.gem
Successfully installed activeresource, version 2.0.2
Installing ri documentation for activeresource-2.0.2-...
Installing RDoc documentation for activeresource-2.0.2-...

E:\RoR>gem install rails-2.0.2.gem
Successfully installed rails, version 2.0.2

E:\RoR>rails -v
Rails 2.0.2

E:\RoR>gem install win32-service
Select which gem to install for your platform (i386-mswin32)
1. win32-service 0.6.0 (ruby)
2. win32-service 0.5.2 (ruby)
3. win32-service 0.5.2 (mswin32)
4. Skip this gem
5. Cancel installation
> 3
Successfully installed win32-service-0.5.2-mswin32
Installing ri documentation for win32-service-0.5.2-mswin32...
Installing RDoc documentation for win32-service-0.5.2-mswin32...

E:\RoR>

E:\RoR>gem install mongrel_service -y
Select which gem to install for your platform (i386-mswin32)
1. mongrel_service 0.3.3 (mswin32)
2. mongrel_service 0.3.2 (mswin32)
3. mongrel_service 0.3.1 (mswin32)
4. mongrel_service 0.1 (ruby)
5. Skip this gem
6. Cancel installation
> 1
Select which gem to install for your platform (i386-mswin32)
1. mongrel 1.1.2 (ruby)
2. mongrel 1.1.2 (mswin32)
3. mongrel 1.1.1 (jruby)
4. mongrel 1.1.1 (ruby)
5. mongrel 1.1.1 (mswin32)
6. Skip this gem
7. Cancel installation
> 2
Successfully installed mongrel_service-0.3.3-mswin32
Successfully installed gem_plugin-0.2.3
Successfully installed mongrel-1.1.2-mswin32
Successfully installed cgi_multipart_eof_fix-2.5.0
Installing ri documentation for mongrel_service-0.3.3-mswin32...
Installing ri documentation for gem_plugin-0.2.3...
Installing ri documentation for mongrel-1.1.2-mswin32...
Installing ri documentation for cgi_multipart_eof_fix-2.5.0...
Installing RDoc documentation for mongrel_service-0.3.3-mswin32...
Installing RDoc documentation for gem_plugin-0.2.3...
Installing RDoc documentation for mongrel-1.1.2-mswin32...
Installing RDoc documentation for cgi_multipart_eof_fix-2.5.0...

E:\RoR>mongrel_rails help
Usage: mongrel_rails [options]
Available commands are:

- restart
- start
- stop
- service::install
- service::remove

Each command takes -h as an option to get help.

E:\RoR>gem install win32-service-0.6.0-x86-mswin32-60.gem
Successfully installed win32-service, version 0.6.0
Installing ri documentation for win32-service-0.6.0-current...
Installing RDoc documentation for win32-service-0.6.0-current...

E:\RoR>gem list --local

*** LOCAL GEMS ***

actionmailer (2.0.2, 1.3.6)
Service layer for easy email delivery and testing.

actionpack (2.0.2, 1.13.6)
Web-flow and rendering framework putting the VC in MVC.

actionwebservice (1.2.6)
Web service support for Action Pack.

activerecord (2.0.2, 1.15.6)
Implements the ActiveRecord pattern for ORM.

activeresource (2.0.2)
Think Active Record for web resources.

activesupport (2.0.2, 1.4.4)
Support and utility classes used by the Rails framework.

cgi_multipart_eof_fix (2.5.0)
Fix an exploitable bug in CGI multipart parsing.

fxri (0.3.6)
Graphical interface to the RI documentation, with search engine.

fxruby (1.6.13, 1.6.12)
FXRuby is the Ruby binding to the FOX GUI toolkit.

gem_plugin (0.2.3)
A plugin system based on rubygems that uses dependencies only

hpricot (0.6)
a swift, liberal HTML parser with a fantastic library

log4r (1.0.5)
Log4r is a comprehensive and flexible logging library for Ruby.

mongrel (1.1.2)
A small fast HTTP library and server that runs Rails, Camping, Nitro
and Iowa apps.

mongrel_service (0.3.3)
Mongrel Native Win32 Service Plugin for Rails (debug build)

rails (2.0.2, 1.2.6)
Web-application framework with template engine, control-flow layer,
and ORM.

rake (0.7.3)
Ruby based make-like utility.

sources (0.0.1)
This package provides download sources for remote gem installation

win32-api (1.0.4)
A superior replacement for Win32API

win32-clipboard (0.4.3)
A package for interacting with the Windows clipboard

win32-dir (0.3.2)
Extra constants and methods for the Dir class on Windows.

win32-eventlog (0.4.7, 0.4.6)
Interface for the MS Windows Event Log.

win32-file (0.5.4, 0.5.2)
Extra or redefined methods for the File class on Windows.

win32-file-stat (1.2.7)
A File::Stat class tailored to MS Windows

win32-process (0.5.5, 0.5.3)
Adds create, fork, wait, wait2, waitpid, and a special kill method

win32-sapi (0.1.4)
An interface to the MS SAPI (Sound API) library.

win32-service (0.6.0, 0.5.2)
An library for controlling and creating MS Windows services

win32-sound (0.4.1)
A library for playing with sound on MS Windows.

windows-api (0.2.0)
An easier way to create methods using Win32API

windows-pr (0.7.4, 0.7.2)
Windows functions and constants bundled via Win32::API

E:\RoR>gem install mysql
Select which gem to install for your platform (i386-mswin32)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. Skip this gem
6. Cancel installation
> 1
Successfully installed mysql-2.7.3-mswin32
Installing ri documentation for mysql-2.7.3-mswin32...
Installing RDoc documentation for mysql-2.7.3-mswin32...
While generating documentation for mysql-2.7.3-mswin32
... MESSAGE: Unhandled special: Special: type=17, text=""
... RDOC args: --op E:/ruby/lib/ruby/gems/1.8/doc/mysql-2.7.3-mswin32/rdoc --exc
lude ext --main README --quiet ext README docs/README.html
(continuing with the rest of the installation)
  • 最後,下載MySQL 4,1或5.0以上的版本並安裝就大功告成


正常的Rail裝法應該是...
gem install rails -y
就行了!
不過2.02
(2007/12/18)才剛剛出來,在source server找不到,這樣裝會有問題。