Saturday, January 7, 2012


My first test with SyntaxHighlighter:


<pre class="brush:html">
  <a href="http://www.modelibra.org/">Modelibra Modeler</a>
</pre>

<pre class="brush:html">
  &lt;a href=&quot;http://www.modelibra.org/&quot;&gt;Modelibra Modeler&lt;/a&gt;
</pre>


&lt;pre class=&quot;brush:html&quot;&gt;
  &lt;a href=&quot;http://www.modelibra.org/&quot;&gt;Modelibra Modeler&lt;/a&gt;
&lt;/pre&gt;





<pre class="brush:sql">
SELECT *
FROM users
WHERE user_id = 1212;
</pre>


&lt;pre class=&quot;brush:sql&quot;&gt;
SELECT *
FROM users
WHERE user_id = 1212;
&lt;/pre&gt;


SyntaxHighlighter

http://alexgorbatchev.com/SyntaxHighlighter/integration.html


I have used the following in the template:


<!--SYNTAX HIGHLIGHTER BEGINS-->
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js' type='text/javascript'/>
<!-- add brushes here -->
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'/>
<script type='text/javascript'>
 SyntaxHighlighter.config.bloggerMode = true;
 SyntaxHighlighter.all();
</script>
<!--SYNTAX HIGHLIGHTER ENDS-->

 </head>





Wednesday, November 30, 2011

Started Learning Dart



I have started learning Dart. First, I read Why Dart Excites Me. Second, I installed Dart Editor. Third, I developed a small, model-driven web application called WebLink.

The WebLink application has a model with only one concept called Url (Url.dart). The Url class has two properties: link and description. A url is a part of the model.


<pre class="brush:java">
class Url {
 LinkModel linkModel;I am Dzenan.
 String link;
 String description;
 
 Url(LinkModel this.linkModel) {
 }
}
</pre>






A collection of web links is represented by the Urls class (Urls.dart).



class Urls {
 LinkModel linkModel;
 
 List<Url> list;
 
 Urls(LinkModel this.linkModel) {
   list = new List();
 }
 
 void add(Url url) {
   list.add(url);
 }
 
 Iterator<Url> iterator() {
   return list.iterator();
 }
}


The model (LinkModel.dart) has one entry point that is a collection of urls.



class LinkModel {
 Urls urls;



 LinkModel() {
   urls = new Urls(this);
 }
 
 void createUrls() {
   Url modelibra = new Url(this);
   modelibra.link = "http://www.modelibra.org/";
   modelibra.description = "Domain model framework";
   urls.add(modelibra);
   
   Url dart = new Url(this);
   dart.link = "http://www.dartlang.org/";
   dart.description =
"Dart is a programming language for creating web applications.";
   urls.add(dart);
 }
}


The web application (WebLink.dart) creates the empty model, fills the model with two urls and displays them in the web page.



#import('dart:html');
#source('Url.dart');
#source('Urls.dart');
#source('LinkModel.dart');



class WebLink {
 LinkModel linkModel;



 WebLink() {
   linkModel = new LinkModel();
 }
 
 void displayUrls() {
   String r = "";
   for (Url url in linkModel.urls) {
     r = r + url.link + "<br/>" + url.description + "<br/><br/>";
   }
   write(r);
 }
 
 void write(String message) {
   document.query('#status').innerHTML = message;
 }
}



void main() {
 WebLink webApp = new WebLink();
 webApp.linkModel.createUrls();
 webApp.displayUrls();
}


The web page (WebLink.html) has a title (html) and a list of web links with their descriptions (js).



<html>
 <head>
   <title>WebLink</title>
 </head>
 <body>
   <h1>Web Links</h1>
   <h2 id="status">dart is not running</h2>
   <script type="text/javascript" src="WebLink.dart.app.js"></script>
 </body>
</html>


The application is created and run in the Dart Editor.


The following is the content of the web page in Chrome:

Web Links

http://www.modelibra.org/
Domain model framework

http://www.dartlang.org/
Dart is a progra
mming language for creating web applications.