syntax highlighting

This commit is contained in:
Keith Donald
2009-03-23 17:52:14 +00:00
parent 4fbd8ad290
commit 382d8863a8
10 changed files with 614 additions and 16 deletions

View File

@@ -5,6 +5,8 @@
<title>Getting Started with Spring Web Flow: Creating Your First Web Flow</title>
<link rel="stylesheet" href="<c:url value="/resources/dijit/themes/tundra/tundra.css"/>" type="text/css" />
<link rel="stylesheet" href="<c:url value="/resources/styles/tutorial.css"/>" type="text/css" />
<link rel="stylesheet" href="<c:url value="/resources/dojox/highlight/resources/highlight.css"/>" type="text/css" />
<link rel="stylesheet" href="<c:url value="/resources/dojox/highlight/resources/pygments/ide.css"/>" type="text/css" />
<script type="text/javascript" src="<c:url value="/resources/dojo/dojo.js"/>"></script>
<script type="text/javascript" src="<c:url value="/resources/spring/Spring.js"/>"></script>
<script type="text/javascript" src="<c:url value="/resources/spring/Spring-Dojo.js"/>"></script>
@@ -68,12 +70,14 @@
<li>
Go ahead and create a <span class="file">start.jsp</span> in your flow directory and paste in the following:
<pre>
<code>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Hello world!&lt;/title&gt;
&lt;/head&gt;
&lt;h1&gt;Hello world!&lt;/h1&gt;
&lt;/html&gt;
</code>
</pre>
</li>
<li>
@@ -89,27 +93,35 @@
<li>
Next, try transitioning your flow from one state to another to implement a navigation rule. In your helloworld flow, add the following transition to your start view-state:
<pre>
<code>
&lt;transition on="submit" to="page2" /&gt;
</code>
</pre>
Then define your page2 view-state:
<pre>
<code>
&lt;view-state id="page2"&gt;
&lt;/view-state&gt;
</code>
</pre>
And the corresponding page2.jsp:
<pre>
<code>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Hello world!&lt;/title&gt;
&lt;/head&gt;
&lt;h1&gt;This is page 2!&lt;/h1&gt;
&lt;/html&gt;
</code>
</pre>
Finally, create a button on your <span class="file">start.jsp</span> that raises the submit event to trigger the state transition:
<pre>
<code>
&lt;form method="post"&gt;
&lt;input type="submit" name="_eventId_submit" value="Submit" /&gt;
&lt;/form&gt;
</code>
</pre>
Click the button and you should be taken to page 2.
</li>
@@ -125,6 +137,7 @@
Try implementing a dynamic navigation rule by first adding a bound checkbox to your <span class="file">start.jsp</span>.
Do this by replacing its contents with the following snippet:
<pre>
<code>
&lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %&gt;
&lt;html&gt;
&lt;head&gt;
@@ -136,11 +149,13 @@
&lt;input type="submit" name="_eventId_submit" value="Submit" /&gt;
&lt;/form:form&gt;
&lt;/html&gt;
</code>
</pre>
</li>
<li>
Next, create a <span class="file">HelloWorldForm</span> class in the <span class="file">org.springframework.webflow.samples.helloworld</span> package with the following code:
<pre>
<code>
package org.springframework.webflow.samples.helloworld;
import java.io.Serializable;
@@ -156,16 +171,21 @@
this.selected = selected;
}
}
</code>
</pre>
</li>
<li>
At the top of your helloworld-flow, declare the HelloWorldForm as a flow variable:
<pre>
<code>
&lt;var name="helloWorldForm" class="org.springframework.webflow.samples.helloworld.HelloWorldForm" /&gt;
</code>
</pre>
Then update your start view-state to use this variable as its data model, enabling automatic model binding and validation:
<pre>
&lt;view-state id="start" model="helloWorldForm"&gt; ...
<code>
&lt;view-state id="start" model="helloWorldForm"&gt; ...
</code>
</pre>
<p>
Refresh your flow and the checkbox should render checked since the default value for the HelloWorldForm selected property is true.
@@ -174,7 +194,8 @@
</li>
<li>
Now insert a decision state that says if the checkbox is selected goto page2, else goto a new page3:
<pre>
<pre>
<code>
&lt;decision-state id="isSelected"&gt;
&lt;if test="helloWorldForm.selected" then="page2" else="page3" /&gt;
&lt;/decision-state&gt;
@@ -183,13 +204,16 @@
&lt;/view-state&gt;
&lt;view-state id="page3"&gt;
&lt;/view-state&gt;
&lt;/view-state&gt;
</code>
</pre>
Be sure to update your start view-state to transition to the isSelected decision state instead of page2 directly:
<pre>
<code>
&lt;view-state id="start"&gt;
&lt;transition on="submit" to="isSelected" /&gt;
&lt;/view-state&gt;
&lt;/view-state&gt;
</code>
</pre>
Click the Submit button with the checkbox selected and you should be taken to page2.
Click the button with the checkbox de-selected and you should be taken to page3 (you'll need to create a JSP or you'll get a 404).
@@ -202,15 +226,21 @@
<li>
Finish up your helloworld flow by adding another button on the <span class="file">start.jsp</span> that ends the flow:
<pre>
<code>
&lt;input type="submit" name="_eventId_finish" value="Finish" /&gt;
</code>
</pre>
In your start view-state, declare the finish transition:
<pre>
<code>
&lt;transition on="finish" to="finished" /&gt;
</code>
</pre>
And finally define the end-state:
<pre>
<code>
&lt;end-state id="finished" view="externalRedirect:welcome" /&gt;
</code>
</pre>
Click the Finish button and you should be taken back to the application welcome screen.
</li>
@@ -233,5 +263,11 @@
}
}));
}).style('display','none');
dojo.require("dojox.highlight.languages.xml");
dojo.addOnLoad(function(){
dojo.query("code").forEach(dojox.highlight.init);
});
</script>
</html>

View File

@@ -5,6 +5,8 @@
<title>Getting Started with Spring Web Flow: Setting up Web Flow in a Spring Web Application</title>
<link rel="stylesheet" href="<c:url value="/resources/dijit/themes/tundra/tundra.css"/>" type="text/css" />
<link rel="stylesheet" href="<c:url value="/resources/styles/tutorial.css"/>" type="text/css" />
<link rel="stylesheet" href="<c:url value="/resources/dojox/highlight/resources/highlight.css"/>" type="text/css" />
<link rel="stylesheet" href="<c:url value="/resources/dojox/highlight/resources/pygments/ide.css"/>" type="text/css" />
<script type="text/javascript" src="<c:url value="/resources/dojo/dojo.js"/>"></script>
<script type="text/javascript" src="<c:url value="/resources/spring/Spring.js"/>"></script>
<script type="text/javascript" src="<c:url value="/resources/spring/Spring-Dojo.js"/>"></script>
@@ -28,7 +30,8 @@ If you prefer to go right to implementing your first flow, you can <a href="tuto
It is responsible for routing web requests to the proper application controllers, such as your Spring MVC @Controllers and web flows.
A typical DispatcherServlet declaration is shown below:
</p>
<pre class="code">
<pre>
<code>
&lt;!-- The front controller of this Spring MVC application, responsible for handling all application requests --&gt;
&lt;servlet&gt;
&lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt;
@@ -47,6 +50,7 @@ If you prefer to go right to implementing your first flow, you can <a href="tuto
&lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt;
&lt;url-pattern&gt;/app/*&lt;/url-pattern&gt;
&lt;/servlet-mapping&gt;
</code>
</pre>
<p>
This DispatcherServlet is configured to process requests into /app/*.
@@ -61,7 +65,8 @@ If you prefer to go right to implementing your first flow, you can <a href="tuto
Inside /WEB-INF/spring, we generally recommend defining a configuration file for your application logic,
and separate configuration files for framework infrastructure. For example:
</p>
<pre class="code">
<pre>
<code>
/webapp
/WEB-INF
/spring
@@ -69,6 +74,7 @@ If you prefer to go right to implementing your first flow, you can <a href="tuto
mvc-config.xml
webflow-config.xml
web.xml
</code>
</pre>
<p>
The example above shows the configuration for a Spring web application spread across three files.
@@ -80,9 +86,11 @@ If you prefer to go right to implementing your first flow, you can <a href="tuto
We also generally recommend using annotations to configure your application components, and externalized XML to configure infrastructure.
This is illustrated in app-config.xml by use of the component-scan directive to scan your classpath for application components to deploy:
</p>
<pre class="code">
<pre>
<code>
&lt;!-- Scans within the base package of the application for @Components to configure as beans --&gt;
&lt;context:component-scan base-package="org.springframework.webflow.samples.gettingstarted" /&gt;
</code>
</pre>
<p>
With this technique, your Spring configuration is setup once and you generally never have to update your configuration files again as new components are added to your application.
@@ -95,11 +103,13 @@ If you prefer to go right to implementing your first flow, you can <a href="tuto
<p>
In webflow-config.xml, first define a flow-registry to register the flows you have defined in your application:
</p>
<pre class="code">
<pre>
<code>
&lt;!-- Registers the web flows that can be executed --&gt;
&lt;webflow:flow-registry id="flowRegistry" base-path="/WEB-INF/"&gt;
&lt;webflow:flow-location-pattern value="**/*-flow.xml" /&gt;
&lt;/webflow:flow-registry&gt;
</code>
</pre>
<p>
The example above scans /WEB-INF looking for -flow.xml files and registers them.
@@ -107,14 +117,17 @@ If you prefer to go right to implementing your first flow, you can <a href="tuto
<p>
Then, define a flow-executor that uses this registry to execute your flows:
</p>
<pre class="code">
<pre>
<code>
&lt;!-- Configures the engine that executes web flows in this application --&gt;
&lt;webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry" /&gt;
</code>
</pre>
<p>
Finally, in mvc-config.xml plug in adapters to hook the flow-executor into the Spring MVC DispatcherServlet request processing pipeline:
</p>
<pre class="code">
<pre>
<code>
&lt;!-- Maps requests to flows in the flowRegistry --&gt;
&lt;bean id="flowMappings" class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"&gt;
&lt;property name="order" value="0" /&gt;
@@ -125,12 +138,15 @@ If you prefer to go right to implementing your first flow, you can <a href="tuto
&lt;bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"&gt;
&lt;property name="flowExecutor" ref="flowExecutor" /&gt;
&lt;/bean&gt;
</code>
</pre>
<p>
We also recommend you turn on development mode while developing so you never have to redeploy your application to test changes:
</p>
<pre class="code">
<pre>
<code>
&lt;webflow:flow-builder-services id="flowBuilderServices" development="true" /&gt;
</code>
</pre>
</div>
<div id="question4" class="question">
@@ -149,7 +165,8 @@ If you prefer to go right to implementing your first flow, you can <a href="tuto
Setting up the HandlerMapping chain is a one-time configuration step, and makes it easy to plug in different types of handlers and mapping strategies.
A typical HandlerMapping chain for Spring web applications looks like:
</p>
<pre class="code">
<pre>
<code>
&lt;!-- Maps requests to flows in the flowRegistry; for example, a request for resource /hotels/booking maps to a flow with id "hotels/booking"
If no flow is found with that id, Spring MVC proceeds to the next HandlerMapping (order=1 below). --&gt;
&lt;bean id="flowMappings" class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping"&gt;
@@ -161,21 +178,24 @@ If you prefer to go right to implementing your first flow, you can <a href="tuto
If no annotation-based path mapping is found, Spring MVC proceeds to the next HandlerMapping (order=2 below). --&gt;
&lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"&gt;
&lt;property name="order" value="1" /&gt;
&lt;/bean&gt;
&lt;/bean&gt;
</code>
</pre>
<p>
Once a request has been mapped to a handler object such as a @Controller of web flow, the DispatcherServlet uses the HandlerAdapter registered for that kind of handler to invoke it.
This decouples the DispatcherServlet from specific handler implementations, which allows Spring MVC to support different controller technologies in an extensible manner.
As a one-time configuration step, a typical Spring web application registers HandlerAdapters that know how to invoke @Controllers and web flows when they are mapped:
</p>
<pre class="code">
<pre>
<code>
&lt;!-- Enables annotated @Controllers; responsible for invoking an annotated POJO @Controller when one is mapped. --&gt;
&lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" /&gt;
&lt;!-- Enables web flows; responsible for calling the Spring Web Flow system to execute a flow when one is mapped. --&gt;
&lt;bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter"&gt;
&lt;property name="flowExecutor" ref="flowExecutor" /&gt;
&lt;/bean&gt;
&lt;/bean&gt;
</code>
</pre>
<p>
To illustrate a typical DispatcherServlet pipeline, the following graphic illustrates the sequence of events that happen in this application when the /tutorial resource is requested, which is handled by the web flow you are interacting with right now:<br>
@@ -215,5 +235,10 @@ If you prefer to go right to implementing your first flow, you can <a href="tuto
}
}));
}).style('display','none');
dojo.require("dojox.highlight.languages.xml");
dojo.addOnLoad(function(){
dojo.query("code").forEach(dojox.highlight.init);
});
</script>
</html>

View File

@@ -83,7 +83,13 @@
<p>
<a href="http://www.springsource.org/spring-security">Spring Security</a> is a comprehensive and portable Java security framework, and Web Flow provides native support for securing flows with this technology.
</p>
</li>
</li>
<li>
<h3>Spring BlazeDS Integration</h3>
<p>
The <a href="http://www.springsource.org/spring-flex">Spring BlazeDS Integration</a> project makes it easy to connect a Flex client to a Spring-powered server using Adobe's BlazeDS and LiveCycle DS technologies.
</p>
</li>
</ul>
<p>
We sincerely hope you enjoyed this tutorial. We wish you great success and lots of fun getting results with Spring Web Flow on your development projects!

View File

@@ -0,0 +1,12 @@
/*
Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dojox.highlight"]){
dojo._hasResource["dojox.highlight"]=true;
dojo.provide("dojox.highlight");
dojo.require("dojox.highlight._base");
}

View File

@@ -0,0 +1,31 @@
-------------------------------------------------------------------------------
dojox.highlight
-------------------------------------------------------------------------------
Version 1.0
Release date: 11/25/2007
-------------------------------------------------------------------------------
Project state:
beta
-------------------------------------------------------------------------------
Credits
Ivan Sagalaev (softwaremaniacs.org) Author
Peter Higgins (dante) Dojo port
-------------------------------------------------------------------------------
Project description
A syntax highlighting engine for the Dojo Toolkit
-------------------------------------------------------------------------------
Dependencies:
dojo base only.
-------------------------------------------------------------------------------
Documentation
-------------------------------------------------------------------------------
Installation instructions
simply get the dojox/highlight folder (and dojox/highlight.js) from the
dojox SVN repository, and include in your page via
dojo.require("dojox.highlight");

View File

@@ -0,0 +1,326 @@
/*
Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dojox.highlight._base"]){
dojo._hasResource["dojox.highlight._base"]=true;
dojo.provide("dojox.highlight._base");
(function(){
var dh=dojox.highlight,_2="\\b(0x[A-Za-z0-9]+|\\d+(\\.\\d+)?)";
dh.constants={IDENT_RE:"[a-zA-Z][a-zA-Z0-9_]*",UNDERSCORE_IDENT_RE:"[a-zA-Z_][a-zA-Z0-9_]*",NUMBER_RE:"\\b\\d+(\\.\\d+)?",C_NUMBER_RE:_2,APOS_STRING_MODE:{className:"string",begin:"'",end:"'",illegal:"\\n",contains:["escape"],relevance:0},QUOTE_STRING_MODE:{className:"string",begin:"\"",end:"\"",illegal:"\\n",contains:["escape"],relevance:0},BACKSLASH_ESCAPE:{className:"escape",begin:"\\\\.",end:"^",relevance:0},C_LINE_COMMENT_MODE:{className:"comment",begin:"//",end:"$",relevance:0},C_BLOCK_COMMENT_MODE:{className:"comment",begin:"/\\*",end:"\\*/"},HASH_COMMENT_MODE:{className:"comment",begin:"#",end:"$"},C_NUMBER_MODE:{className:"number",begin:_2,end:"^",relevance:0}};
function esc(_3){
return _3.replace(/&/gm,"&amp;").replace(/</gm,"&lt;").replace(/>/gm,"&gt;");
};
function verifyText(_4){
return dojo.every(_4.childNodes,function(_5){
return _5.nodeType==3||String(_5.nodeName).toLowerCase()=="br";
});
};
function blockText(_6){
var _7=[];
dojo.forEach(_6.childNodes,function(_8){
if(_8.nodeType==3){
_7.push(_8.nodeValue);
}else{
if(String(_8.nodeName).toLowerCase()=="br"){
_7.push("\n");
}else{
throw "Complex markup";
}
}
});
return _7.join("");
};
function buildKeywordGroups(_9){
if(!_9.keywordGroups){
for(var _a in _9.keywords){
var kw=_9.keywords[_a];
if(kw instanceof Object){
_9.keywordGroups=_9.keywords;
}else{
_9.keywordGroups={keyword:_9.keywords};
}
break;
}
}
};
function buildKeywords(_c){
if(_c.defaultMode&&_c.modes){
buildKeywordGroups(_c.defaultMode);
dojo.forEach(_c.modes,buildKeywordGroups);
}
};
var _d=function(_e,_f){
this.langName=_e;
this.lang=dh.languages[_e];
this.modes=[this.lang.defaultMode];
this.relevance=0;
this.keywordCount=0;
this.result=[];
if(!this.lang.defaultMode.illegalRe){
this.buildRes();
buildKeywords(this.lang);
}
try{
this.highlight(_f);
this.result=this.result.join("");
}
catch(e){
if(e=="Illegal"){
this.relevance=0;
this.keywordCount=0;
this.partialResult=this.result.join("");
this.result=esc(_f);
}else{
throw e;
}
}
};
dojo.extend(_d,{buildRes:function(){
dojo.forEach(this.lang.modes,function(_10){
if(_10.begin){
_10.beginRe=this.langRe("^"+_10.begin);
}
if(_10.end){
_10.endRe=this.langRe("^"+_10.end);
}
if(_10.illegal){
_10.illegalRe=this.langRe("^(?:"+_10.illegal+")");
}
},this);
this.lang.defaultMode.illegalRe=this.langRe("^(?:"+this.lang.defaultMode.illegal+")");
},subMode:function(_11){
var _12=this.modes[this.modes.length-1].contains;
if(_12){
var _13=this.lang.modes;
for(var i=0;i<_12.length;++i){
var _15=_12[i];
for(var j=0;j<_13.length;++j){
var _17=_13[j];
if(_17.className==_15&&_17.beginRe.test(_11)){
return _17;
}
}
}
}
return null;
},endOfMode:function(_18){
for(var i=this.modes.length-1;i>=0;--i){
var _1a=this.modes[i];
if(_1a.end&&_1a.endRe.test(_18)){
return this.modes.length-i;
}
if(!_1a.endsWithParent){
break;
}
}
return 0;
},isIllegal:function(_1b){
var _1c=this.modes[this.modes.length-1].illegalRe;
return _1c&&_1c.test(_1b);
},langRe:function(_1d,_1e){
var _1f="m"+(this.lang.case_insensitive?"i":"")+(_1e?"g":"");
return new RegExp(_1d,_1f);
},buildTerminators:function(){
var _20=this.modes[this.modes.length-1],_21={};
if(_20.contains){
dojo.forEach(this.lang.modes,function(_22){
if(dojo.indexOf(_20.contains,_22.className)>=0){
_21[_22.begin]=1;
}
});
}
for(var i=this.modes.length-1;i>=0;--i){
var m=this.modes[i];
if(m.end){
_21[m.end]=1;
}
if(!m.endsWithParent){
break;
}
}
if(_20.illegal){
_21[_20.illegal]=1;
}
var t=[];
for(i in _21){
t.push(i);
}
_20.terminatorsRe=this.langRe("("+t.join("|")+")");
},eatModeChunk:function(_26,_27){
var _28=this.modes[this.modes.length-1];
if(!_28.terminatorsRe){
this.buildTerminators();
}
_26=_26.substr(_27);
var _29=_28.terminatorsRe.exec(_26);
if(!_29){
return {buffer:_26,lexeme:"",end:true};
}
return {buffer:_29.index?_26.substr(0,_29.index):"",lexeme:_29[0],end:false};
},keywordMatch:function(_2a,_2b){
var _2c=_2b[0];
if(this.lang.case_insensitive){
_2c=_2c.toLowerCase();
}
for(var _2d in _2a.keywordGroups){
if(_2c in _2a.keywordGroups[_2d]){
return _2d;
}
}
return "";
},buildLexemes:function(_2e){
var _2f={};
dojo.forEach(_2e.lexems,function(_30){
_2f[_30]=1;
});
var t=[];
for(var i in _2f){
t.push(i);
}
_2e.lexemsRe=this.langRe("("+t.join("|")+")",true);
},processKeywords:function(_33){
var _34=this.modes[this.modes.length-1];
if(!_34.keywords||!_34.lexems){
return esc(_33);
}
if(!_34.lexemsRe){
this.buildLexemes(_34);
}
_34.lexemsRe.lastIndex=0;
var _35=[],_36=0,_37=_34.lexemsRe.exec(_33);
while(_37){
_35.push(esc(_33.substr(_36,_37.index-_36)));
var _38=this.keywordMatch(_34,_37);
if(_38){
++this.keywordCount;
_35.push("<span class=\""+_38+"\">"+esc(_37[0])+"</span>");
}else{
_35.push(esc(_37[0]));
}
_36=_34.lexemsRe.lastIndex;
_37=_34.lexemsRe.exec(_33);
}
_35.push(esc(_33.substr(_36,_33.length-_36)));
return _35.join("");
},processModeInfo:function(_39,_3a,end){
var _3c=this.modes[this.modes.length-1];
if(end){
this.result.push(this.processKeywords(_3c.buffer+_39));
return;
}
if(this.isIllegal(_3a)){
throw "Illegal";
}
var _3d=this.subMode(_3a);
if(_3d){
_3c.buffer+=_39;
this.result.push(this.processKeywords(_3c.buffer));
if(_3d.excludeBegin){
this.result.push(_3a+"<span class=\""+_3d.className+"\">");
_3d.buffer="";
}else{
this.result.push("<span class=\""+_3d.className+"\">");
_3d.buffer=_3a;
}
this.modes.push(_3d);
this.relevance+=typeof _3d.relevance=="number"?_3d.relevance:1;
return;
}
var _3e=this.endOfMode(_3a);
if(_3e){
_3c.buffer+=_39;
if(_3c.excludeEnd){
this.result.push(this.processKeywords(_3c.buffer)+"</span>"+_3a);
}else{
this.result.push(this.processKeywords(_3c.buffer+_3a)+"</span>");
}
while(_3e>1){
this.result.push("</span>");
--_3e;
this.modes.pop();
}
this.modes.pop();
this.modes[this.modes.length-1].buffer="";
return;
}
},highlight:function(_3f){
var _40=0;
this.lang.defaultMode.buffer="";
do{
var _41=this.eatModeChunk(_3f,_40);
this.processModeInfo(_41.buffer,_41.lexeme,_41.end);
_40+=_41.buffer.length+_41.lexeme.length;
}while(!_41.end);
if(this.modes.length>1){
throw "Illegal";
}
}});
function replaceText(_42,_43,_44){
if(String(_42.tagName).toLowerCase()=="code"&&String(_42.parentNode.tagName).toLowerCase()=="pre"){
var _45=document.createElement("div"),_46=_42.parentNode.parentNode;
_45.innerHTML="<pre><code class=\""+_43+"\">"+_44+"</code></pre>";
_46.replaceChild(_45.firstChild,_42.parentNode);
}else{
_42.className=_43;
_42.innerHTML=_44;
}
};
function highlightStringLanguage(_47,str){
var _49=new _d(_47,str);
return {result:_49.result,langName:_47,partialResult:_49.partialResult};
};
function highlightLanguage(_4a,_4b){
var _4c=highlightStringLanguage(_4b,blockText(_4a));
replaceText(_4a,_4a.className,_4c.result);
};
function highlightStringAuto(str){
var _4e="",_4f="",_50=2,_51=str;
for(var key in dh.languages){
if(!dh.languages[key].defaultMode){
continue;
}
var _53=new _d(key,_51),_54=_53.keywordCount+_53.relevance,_55=0;
if(!_4e||_54>_55){
_55=_54;
_4e=_53.result;
_4f=_53.langName;
}
}
return {result:_4e,langName:_4f};
};
function highlightAuto(_56){
var _57=highlightStringAuto(blockText(_56));
if(_57.result){
replaceText(_56,_57.langName,_57.result);
}
};
dh.processString=function(str,_59){
return _59?highlightStringLanguage(_59,str):highlightStringAuto(str);
};
dh.init=function(_5a){
if(dojo.hasClass(_5a,"no-highlight")){
return;
}
if(!verifyText(_5a)){
return;
}
var _5b=_5a.className.split(/\s+/),_5c=dojo.some(_5b,function(_5d){
if(_5d.charAt(0)!="_"&&dh.languages[_5d]){
highlightLanguage(_5a,_5d);
return true;
}
return false;
});
if(!_5c){
highlightAuto(_5a);
}
};
dh.Code=function(_5e,_5f){
dh.init(_5f);
};
})();
}

View File

@@ -0,0 +1,14 @@
/*
Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dojox.highlight.languages.pygments.xml"]){
dojo._hasResource["dojox.highlight.languages.pygments.xml"]=true;
dojo.provide("dojox.highlight.languages.pygments.xml");
dojo.require("dojox.highlight._base");
dojox.highlight.languages.pygments.xml={a:1};
dojox.highlight.languages.xml={defaultMode:{contains:["name entity","comment","comment preproc","_tag"]},modes:[{className:"comment",begin:"<!--",end:"-->"},{className:"comment preproc",begin:"\\<\\!\\[CDATA\\[",end:"\\]\\]\\>"},{className:"comment preproc",begin:"\\<\\!",end:"\\>"},{className:"comment preproc",begin:"\\<\\?",end:"\\?\\>",relevance:5},{className:"string",begin:"'",end:"'",illegal:"\\n",relevance:0},{className:"string",begin:"\"",end:"\"",illegal:"\\n",relevance:0},{className:"name entity",begin:"\\&[a-z]+;",end:"^"},{className:"name tag",begin:"\\b[a-z0-9_\\:\\-]+\\b",end:"^"},{className:"name attribute",begin:"\\b[a-z0-9_\\:\\-]+=",end:"^",relevance:0},{className:"_tag",begin:"\\<",end:"\\>",contains:["name tag","name attribute","string"]},{className:"_tag",begin:"\\</",end:"\\>",contains:["name tag"]}]};
}

View File

@@ -0,0 +1,19 @@
/*
Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
*/
if(!dojo._hasResource["dojox.highlight.languages.xml"]){
dojo._hasResource["dojox.highlight.languages.xml"]=true;
dojo.provide("dojox.highlight.languages.xml");
dojo.require("dojox.highlight._base");
(function(){
var _1={className:"comment",begin:"<!--",end:"-->"};
var _2={className:"attribute",begin:" [a-zA-Z-]+=",end:"^",contains:["value"]};
var _3={className:"value",begin:"\"",end:"\""};
var dh=dojox.highlight,_5=dh.constants;
dh.languages.xml={defaultMode:{contains:["pi","comment","cdata","tag"]},case_insensitive:true,modes:[{className:"pi",begin:"<\\?",end:"\\?>",relevance:10},_1,{className:"cdata",begin:"<\\!\\[CDATA\\[",end:"\\]\\]>"},{className:"tag",begin:"</?",end:">",contains:["title","tag_internal"],relevance:1.5},{className:"title",begin:"[A-Za-z:_][A-Za-z0-9\\._:-]+",end:"^",relevance:0},{className:"tag_internal",begin:"^",endsWithParent:true,contains:["attribute"],relevance:0,illegal:"[\\+\\.]"},_2,_3],XML_COMMENT:_1,XML_ATTR:_2,XML_VALUE:_3};
})();
}

View File

@@ -0,0 +1,51 @@
.string,
.function .title,
.class .title,
.tag .attribute .value,
.css .rules .value,
.preprocessor,
.ruby .symbol,
.ruby .instancevar,
.ruby .class .parent,
.built_in,
.sql .aggregate,
.django .template_tag,
.django .variable,
.smalltalk .class {
color: #800;
}
.comment,
.java .annotation,
.template_comment {
color: #888;
}
.number,
.regexp,
.javascript .literal,
.smalltalk .symbol,
.smalltalk .char {
color: #080;
}
.javadoc,
.ruby .string,
.python .decorator,
.django .filter .argument,
.smalltalk .localvars,
.smalltalk .array,
.css .attr_selector,
.xml .pi {
color: #88F;
}
.keyword,
.css .id,
.phpdoc,
.function .title,
.class .title,
.vbscript .built_in,
.sql .aggregate,
.rsl .built_in,
.smalltalk .class,
.xml .tag .title {
font-weight: bold;
}

View File

@@ -0,0 +1,78 @@
/*
Intellij Idea-like styling (c) Vasily Polovnyov <vast@whiteants.net>
*/
pre code {
display: block;
border:1px dashed #aaaaaa;
overflow:auto;
background-color: #f4f4f4;
color:#444444;
padding:3px;
whitespace:pre;
}
.subst, .title {
font-weight: normal;
color: #000;
}
.comment, .template_comment, .javadoc, .diff .header {
color: #808080;
font-style: italic;
}
.annotation, .decorator, .preprocessor, .doctype, .pi, .chunk, .shebang, .apache .cbracket {
color: #808000;
}
.tag, .pi {
background: #f4f4f4;
}
.tag .title, .id, .attr_selector, .literal, .keyword, .hexcolor, .css .function, .ini .title, .css .class, .list .title {
font-weight: bold;
color: #000080;
}
.attribute, .rules .keyword, .number, .date, .regexp {
font-weight: bold;
color: #0000ff;
}
.number, .regexp {
font-weight: normal;
}
.string, .value, .filter .argument, .css .function .params, .apache .tag {
color: #008000;
font-weight: bold;
}
.symbol, .char {
color: #000;
background: #d0eded;
font-style: italic;
}
.phpdoc, .javadoctag {
text-decoration: underline;
}
.variable, .envvar, .apache .sqbracket {
color: #660e7a;
}
.addition {
background: #baeeba;
}
.deletion {
background: #ffc8bd;
}
.diff .change {
background: #bccff9;
}