練功房推薦書單

  • Google!Android 3手機應用程式設計入門(第四版)
  • 賈伯斯傳(軟皮精裝版)
  • 猛虎出閘制霸版:最新OCP Java SE 6 Programmer專業認證(附原始程式碼及範例檔)
  • SCWCD 5 猛虎出閘:Java Web 應用程式專業認證
[v2.1.8]升級SyntaxHighlighter至2.0  XML
Forum Index » JForum中文社群 JForum Chinese Users Community
Author Message
andowson

六段學員
[Avatar]

Joined: 2007-01-02 22:20:40
Messages: 652
Location: 台北
Offline

以下是升級的步驟
1.修改WEB-INF/config/bb_cinfig.xml
	<match name="code">
		<regex>(?s)\[code\](.*?)\[/code\]</regex>		
		<replace>
		<![CDATA[
        <textarea name="code" class="java" cols="60" rows="10">$1</textarea>
		]]>
		</replace>
	</match>

	<match name="code-highlight">
		<regex>(?s)(?i)\[code=['"]?(.*?[^'"])['"]?\](.*?)\[/code\]</regex>
		<replace>
		<![CDATA[
        <textarea name="code" class="$1" cols="60" rows="10">$2</textarea>
		]]>
		</replace>
	</match>

替換為
	<match name="code">
		<regex>(?s)\[code\](.*?)\[/code\]</regex>		
		<replace>
		<![CDATA[
        <pre name="code" class="brush: java">$1</pre>
		]]>
		</replace>
	</match>

	<match name="code-highlight">
		<regex>(?s)(?i)\[code=['"]?(.*?[^'"])['"]?\](.*?)\[/code\]</regex>
		<replace>
		<![CDATA[
        <pre name="code" class="brush: $1">$2</pre>
		]]>
		</replace>
	</match>


2.修改templates/default/ajax_preview_post.js
dp.sh.ClipboardSwf = '${contextPath}/templates/${templateName}/js/clipboard.swf';
dp.sh.HighlightAll('code');

替換為
SyntaxHighlighter.config.clipboardSwf = '${contextPath}/templates/${templateName}/js/clipboard.swf';
SyntaxHighlighter.all();
dp.SyntaxHighlighter.HighlightAll('code');


3.修改templates/default/header.htm
<#if hasCodeBlock>
	<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/SyntaxHighlighter.css?${startupTime} );</style>
</#if>

替換為
<#if hasCodeBlock?default(false)>
	<#include "highlighter_css.htm"/>
</#if>


4.新增templates/default/highlighter_css.htm
<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/shCore.css?${startupTime} );</style>
<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/shThemeDefault.css?${startupTime} );</style>


5.修改templates/default/highlighter_js.htm
全部檔案內容替換為
<!-- SyntaxHighlighter 2.0.320 -->
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shCore.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shLegacy.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushBash.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushBat.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushCpp.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushCSharp.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushCss.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushDelphi.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushDiff.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushGroovy.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushJava.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushJScript.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushPhp.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushPlain.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushPython.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushRuby.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushPerl.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushScala.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushSql.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushVb.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushXml.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushAS3.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushJavaFX.js?${startupTime}"></script>
<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/shBrushPowerShell.js?${startupTime}"></script>
<script type="text/javascript">
<!--
  SyntaxHighlighter.config.clipboardSwf = '${contextPath}/templates/${templateName}/js/clipboard.swf';
  SyntaxHighlighter.all();
  dp.SyntaxHighlighter.HighlightAll('code');
-->
</script>


6.修改templates/default/pm_review_message.htm
<#if hasCodeBlock?default(false)>
	<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/SyntaxHighlighter.css?${startupTime} );</style>
</#if>

替換為
<#if hasCodeBlock?default(false)>
	<#include "highlighter_css.htm"/>
</#if>


7.修改templates/default/post_form.htm:
<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/SyntaxHighlighter.css?${startupTime} );</style>

替換為
<#include "highlighter_css.htm"/>


8.修改template/default/post_show.htm:
                dp.sh.HighlightAll('code');

替換為
                SyntaxHighlighter.all();
                dp.SyntaxHighlighter.HighlightAll('code');

9.修改templates/default/topic_review.htm
<#if hasCodeBlock?default(false)>
	<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/SyntaxHighlighter.css?${startupTime} );</style>
</#if>

替換為
<#if hasCodeBlock?default(false)>
	<#include "highlighter_css.htm"/>
</#if>


10.下載SyntaxHighlighter 2.0並解壓縮

11.由http://www.undermyhat.org/blog/2009/09/list-of-brushes-syntaxhighligher/下載shBrushBat.js,並存到scripts目錄下

12.複製scripts目錄下的所有檔案到templates/default/js目錄

13.複製styles目錄下的所有檔案到templates/default/styles目錄

14.刪除templates/default/styles/SyntaxHighlighter.css

15.重新載入JForum

This message was edited 5 times. Last update was at 2009-11-06 07:18:05


分享經驗 累積智慧
[WWW] [MSN]
 
Forum Index » JForum中文社群 JForum Chinese Users Community
Go to: