ads

Thursday, November 1, 2012

CARA MEMPOSTING SOURCE CODE DI BLOGGER

Kali ini saya akan membahas cara memposting source code diblogger, untuk menampilkan source code program pada blog dibutuhkan plugin Syntax Highlighter, Apa itu Syntax Higlighter ? Sintax Highligter merupakan sebuah fitur/ plugin yang digunakan untuk menampilkan source code suatu bahasa pemrograman dalam HTML. Selain untuk menampilkan source code program, alasan lain menggunakan Syntax Highlighter adalah tampilan teks kode akan terlihat lebih rapi, menarik, indah dipandang, serta menjadi pembeda antara bagian tulisan dan source code program. Ikuti langkah dibawah ini:


 Langkah - langkahnya:
  1. Pada Halaman Dasbor, Pilih Rancangan (Design)
  2. Pada tab Rancangan (Design), Pilih Edit HTML dan Klik Proses
  3. Terlebih dahulu Backup Template
  4. Centang | Expand Template Widget
  5. Cari kode </head> | Tekan Crtl+F
  6. Selipkan kode dibawah ini diatas </head>
 
<link href='http://alexgorbatchev.com/pub/sh/2.1.364/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/2.1.364/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
<!-- Add-in Script for syntax highlighting -->
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushAS3.js' type='text/javascript'/>

<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushBash.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushColdFusion.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushDiff.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushErlang.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushGroovy.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushJScript.js' type='text/javascript'/>

<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushJavaFX.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPerl.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPlain.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPowerShell.js'type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushPython.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushRuby.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushScala.js' type='text/javascript'/>

<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/2.1.364/scripts/shBrushXml.js' type='text/javascript'/>

<script language='javascript'>
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = &#39;http://alexgorbatchev.com/pub/sh/2.1.364/scripts/clipboard.swf&#39;;
SyntaxHighlighter.all();
</script>

 

     7. Simpan Template

Bagaimana cara menerapkannya ke Blog ?
Pengaktifan Syntax Higlighter bisa dilakukan dengan 2 cara :
Meggunakan kode Javascript
Contoh :
<script class="brush : Nama alias" type="syntaxhighlighter">
...Source kodemu disini....
</script>


Menggunakan kode HTML
Contoh :
<pre class="brush: Nama Alias">
...Source kodemu disini....
</pre>


<pre class="brush: css"> Kode CSS taruh disini </pre>
<pre class="brush: java"> Kode Javascript taruh disini </pre>
<pre class="brush: html"> Kode HTML taruh disini </pre>


Selengkapnya bisa dilihat pada tabel dibawah ini : 
Nama BrushAlias BrushNama File
ActionScript3as3, actionscript3shBrushAS3.js
Bash/shellbash, shellshBrushBash.js
ColdFusioncf, coldfusionshBrushColdFusion.js
C#c-sharp, csharpshBrushCSharp.js
C++cpp, cshBrushCpp.js
CSScssshBrushCss.js
Delphidelphi, pas, pascalshBrushDelphi.js
Diffdiff, patchshBrushDiff.js
Erlangerl, erlangshBrushErlang.js
GroovygroovyshBrushGroovy.js
JavaScriptjs, jscript, javascriptshBrushJScript.js
JavajavashBrushJava.js
JavaFXjfx, javafxshBrushJavaFX.js
Perlperl, plshBrushPerl.js
PHPphpshBrushPhp.js
Plain Textplain, textshBrushPlain.js
PowerShellps, powershellshBrushPowerShell.js
Pythonpy, pythonshBrushPython.js
Rubyrails, ror, rubyshBrushRuby.js
ScalascalashBrushScala.js
SQLsqlshBrushSql.js/td>
Visual Basicvb, vbnetshBrushVb.js
XMLxml, xhtml, xslt, html, xhtmlshBrushXml.js

Sumber :
1. http://mfairuzreza.blogspot.com/2011/07/cara-memposting-source-code-di-blog.html
2. http://sharedthisblog.blogspot.com/2012/06/menampilkan-source-code-program-di.html

No comments:

Post a Comment