Add rake task for layout with nokogiri

This commit is contained in:
Christophe Vilayphiou 2012-03-27 18:28:09 +08:00
parent c5f6dbc1c4
commit 717e50a25e
2 changed files with 197 additions and 0 deletions

184
lib/noko/layout.html Executable file
View File

@ -0,0 +1,184 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>RulingSite</title>
<link rel="stylesheet" type="text/css" href="themes/ini.css" media="all" style=""/>
<link rel="stylesheet" type="text/css" href="themes/comp.css" media="all" style=""/>
<link rel="stylesheet" type="text/css" href="default.css" media="all" style=""/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="javascript/jquery.tinyscrollbar.min.js"></script>
<script type="text/javascript" src="javascript/rc.js"></script>
<script type="text/javascript" src="javascript/ccu.js"></script>
</head>
<body>
<div id="wrapper">
<div id="header" class="header">
<h1 id="logo" class="ini_heading"><a href="">國立政治大學</a><span>National Chengchi University</span></h1>
<div id="nav" class="header_nav">
<ul class="nav_1">
<li><a href="#" class="nav1">在校學生</a></li><span class="line">&nbsp;|&nbsp;</span>
<li><a href="#" class="nav2">校友</a></li><span class="line">&nbsp;|&nbsp;</span>
<li><a href="#" class="nav3">教職員工</a></li><span class="line">&nbsp;|&nbsp;</span>
<li><a href="#" class="nav4">訪客</a></li>
</ul>
<ul class="nav_2">
<li><a href="#">網站地圖</a></li><span class="line">&nbsp;|&nbsp;</span>
<li><a href="#">iNCCU 愛政大</a></li><span class="line">&nbsp;|&nbsp;</span>
<li>
<a href="#" class="mail">郵件信箱</a>
<ul class="nav_menu2">
<li class="mail">郵件信箱</li>
<li><a href="">教職員生</a></li>
<li><a href="">校友</a></li>
</ul>
</li>
</ul>
</div>
<nav id="nav2" class="site_menu menu">
<ul class="nav ini_list page_menu" level='1' id='nav' class='nav ini_list' home='true' li_class='nav' li_incremental='true'>
<li><a href=""><span>關於政大</span></a></li>
<li>
<a href=""><span>學術單位</span></a>
<span class="dot"></span>
<ul class="site_menu2 page_menu" level='2' id='navi' li_class='navi'>
<li><a href=""><span>文學院</span></a></li>
<li><a href=""><span>理學院</span></a></li>
<li><a href=""><span>社會科學學院</span></a></li>
<li><a href=""><span>法學院</span></a></li>
<li><a href=""><span>商學院</span></a></li>
<li><a href=""><span>外國語文學院</span></a></li>
<li><a href=""><span>傳播學院</span></a></li>
<li><a href=""><span>國際事務學院</span></a></li>
<li><a href=""><span>教育學院</span></a></li>
</ul>
</li>
<li>
<a href=""><span>研究單位</span></a>
<span class="dot"></span>
<ul class="site_menu2 ini_list">
<li><a href=""><span>國際關係研究中心</span></a></li>
<li><a href=""><span>選舉研究中心</span></a></li>
<li><a href=""><span>第三部門研究中心</span></a></li>
<li><a href=""><span>創新與創造力研究中心</span></a></li>
<li><a href=""><span>台灣研究中心</span></a></li>
<li><a href=""><span>中國大陸研究中心</span></a></li>
<li><a href=""><span>人文研究中心</span></a></li>
<li><a href=""><span>心智、大腦與學習研究中心</span></a></li>
<li><a href=""><span>原住民族研究中心</span></a></li>
<li><a href=""><span>附屬研究中心</span></a></li>
</ul>
</li>
<li>
<a href=""><span>行政組織</span></a>
<span class="dot"></span>
<ul class="site_menu2">
<li><a href=""><span>教務處</span></a></li>
<li><a href=""><span>學生事務處</span></a></li>
<li><a href=""><span>總務處</span></a></li>
<li><a href=""><span>研究發展處</span></a></li>
<li><a href=""><span>國際合作事務處</span></a></li>
<li><a href=""><span>秘書處</span></a></li>
<li><a href=""><span>會計室</span></a></li>
<li><a href=""><span>人事室</span></a></li>
<li><a href=""><span>圖書館</span></a></li>
<li><a href=""><span>體育室</span></a></li>
<li><a href=""><span>公共行政及企業管理教育中心</span></a></li>
<li><a href=""><span>社會科學資料中心</span></a></li>
<li><a href=""><span>電子計算機中心</span></a></li>
<li><a href=""><span>附設公務人員教育中心</span></a></li>
<li><a href=""><span>教學發展中心</span></a></li>
<li><a href=""><span>華語文教學中心</span></a></li>
<li><a href=""><span>創新育成中心</span></a></li>
<li><a href=""><span>附設實驗國民小學</span></a></li>
<li><a href=""><span>附屬高級中學</span></a></li>
<li><a href=""><span>性別平等教育委員會</span></a></li>
</ul>
</li>
<li><a href=""><span>招生入學</span></a></li>
<li>
<a href=""><span>資訊服務</span></a>
<ul class="site_menu2">
<li><a href=""><span>校務系統</span></a></li>
<li><a href=""><span>校園授權軟體</span></a></li>
<li><a href=""><span>校園網路</span></a></li>
<li><a href=""><span>校園資訊服務</span></a></li>
<li><a href=""><span>教學軟硬體資源</span></a></li>
</ul>
</li>
<li><a href=""><span>聯絡我們</span></a></li>
</ul>
</nav>
<div id="banner_box">
<div id="banner" name='content_1' class="banner page_content">
</div>
</div>
</div>
<div id="main_content" class="content">
<div class="content2">
<div class="topic_news">
<div class="topic_news2">
<div class="main_content page_content" name='content_2'>
</div>
<div class="news_content page_content" name='content_2' main='true'>
</div>
<div class="sidebar page_content" name='content_7'>
</div>
</div>
</div>
<div class="clear"></div>
<div class="post_panel">
<div class="post_panel2">
<div class="announcements page_content" name='content_3'>
</div>
<div class="events page_content" name='content_4'>
</div>
</div>
</div>
<div class="clear"></div>
<div class="links_panel">
<div class="links_panel2">
<div class="adbanner1 page_content" name='content_5'>
</div>
<div class="quicklinks page_content" name='content_6'>
</div>
</div>
</div>
</div>
</div>
<div id="footer" class="footer">
<div class="copyright">
<p>
本網站著作權屬於國立政治大學,請詳見使用規則。
</p>
<p>
總機電話02-29393091<br/>
傳真02-29379611<br/>
地址11605 台北市文山區指南路二段64號<br/>
</p>
</div>
<div class="notice">
校園安全緊急通報&nbsp;|&nbsp;著作權&nbsp;|&nbsp;個人資料保護宣告&nbsp;|&nbsp;資訊安全宣告&nbsp;|&nbsp;聯絡我們
</div>
<div class="ruling">
<a href="">
<img src="images/ruling.png" alt="Rulingdigital" name="ruling_pic" id="ruling_pic" class="ruling_pic page_image" />
</a>
</div>
</div>
</div>
</body>
</html>

13
lib/tasks/noko.rake Normal file
View File

@ -0,0 +1,13 @@
# encoding: utf-8
namespace :nokogiri do
task :layout => :environment do
l = Design.first(:conditions => {:title => 'CCU'}).layout
l.layout_parts.destroy rescue nil
l.menu.destroy rescue nil
l.design.save
l = Design.first(:conditions => {:title => 'CCU'}).layout
l.file = File.open("#{Rails.root}/lib/noko/layout.html")
l.design.save
end
end