Wednesday, 30 October 2013

Eclipse IDE by default does not come with a Subversion client plugin. There are the plugins "subclipse" and "subversive". You can try both and choose which one you like more. Feature wise they are comparable.
In this tutorial you will install the subclipse plugin for Eclipse.

Specification

  • Homepage: http://subclipse.tigris.org/
  • Version: 1.10.3, 1.8.22
  • Download: http://subclipse.tigris.org/update_1.10.x

Installation

Newer versions of Eclipse do have the Marketplace functionality.
  • Help - Eclipse Marketplace... - Search - Find: subclipse
  • Click "Install"
  • Choose features to install
  • Accept licenses
  • Restart Eclipse
Older versions of Eclipse do not have the Marketplace. Installation is done like this:
  • Help - Software Updates… – Available Software – Add Site…
  • Install dialog: "Add...":
    Name: http://subclipse.tigris.org/update_1.10.x
    Location: "http://subclipse.tigris.org/update_1.10.x" - OK
    Select all (if you are not sure what to select) - Next > - Next >* Accept license - Finish
    Restart Eclipse

Configuration

SVN Perspective

Menu: "Window - Open Perspective - Other... - SVN Repository Exploring" - OK

SVN Client Library

By default the JavaHL (JNI) library is chosen as subversion client library. If you do not have it installed you will get an error (see below).
But you can also select the SVNKit (Pure Java) library like this:
  • Window - Preferences - Team - SVN
  • SVN Interface - Client - SVNKit (Pure Java) SVNKit v1.7.9.9659

Usage

Add a new repository location

Example:
Adding Wicket repository: "SVN Repositories" view: right click - New - Repository location... - Location Url (example): http://svn.apache.org/repos/asf/wicket/

Import an existing project into repository

  • Project context menu – Team – Share project...
  • "SVN" – Next >
  • "Use existing repository location": "svn://<SUBVERSION_SERVER>/repos" or http://<SUBVERSION_SERVER>/svn/repos (if HTTP-access is installed) – Next >
  • "Use specified folder name": "<PROJECT_NAME>/trunk" – Next >
  • Comment: "Initial import." – Finish
  • Input your SVN-username / -password
  • Add files and directories to "svn:ignore" (context menu), which should not be checked in at all (e.g. "target" or "bin")
  • Commit all

Checkout a project

Example:
Checking out Wicket "trunk": Right click "http://svn.apache.org/repos/asf/wicket/ - trunk" in "SVN Repositories" - Checkout... - Checkout as project in the workspace, Project Name: "wicket-trunk" - Finish

Troubleshooting

Ubuntu Linux

  • "Failed to load JavaHL Library"
    • Solution 1
      Install libsvn-java
      Edit eclipse.ini and add java.library.path:
      -vmargs
      -Djava.library.path=/usr/lib/jni
    • Solution 2
      Eclipse is installed in a directory, where the user has not sufficient permissions (e.g. under /usr/local/bin).
      Change permissions (recursively) of the Eclipse directory OR Install Eclipse per user with the user as owner in the user's home-directory (e.g. /home//Programs/Eclipse_Galileo)
For a professional Java Development Environment you need an IDE (Integrated Development Environment):
An IDE ... is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of a source code editor, build automation tools and a debugger.
Eclipse, IntelliJ and NetBeans are the most used IDEs.
In this tutorial you will install Eclipse for JEE developers (version focused on webapp developers).

Specification

Installation

Windows

  • Unzip ZIP-file to an appropriate folder (C:\Program Files)
  • Rename unpacked folder "eclipse" to "Eclipse_Kepler"
  • Create a desktop shortcut or quick launch icon to the executable "eclipse.exe" in the unpacked folder

Linux

It is recommended to install it not system wide (e.g. in "/usr/local/bin"), but per user in the user's home. Otherwise problems with some plugins may appear (e.g. after installing m2eclipse other plugins disappeared...):
$ cd /home/ralf/
$ mkdir Programs
$ cd Programs
$ tar xvfz /home/ralf/Downloads/eclipse-jee-kepler-SR1-linux-gtk.tar.gz
$ mv eclipse/ Eclipse_Kepler

Configuration

Startup Parameters

Change start parameters in "C:\Program Files\Eclipse_Kepler\eclipse.ini" or "/home/<user>/Programs/Eclipse_Kepler/eclipse.ini".
Note: Xmx and XX params must be appropriate to your available memory. If Eclipse does not start, down tune them.

Windows

-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256M
-vm
C:\Program Files\Java\jdk1.6.0_13\bin\javaw.exe
-framework
plugins\org.eclipse.osgi_3.4.3.R34x_v20081215-1030.jar
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xmx700m
-XX:MaxPermSize=690M

Linux

-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_1.0.200.v20090520
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vmargs
-Dosgi.requiredJavaVersion=1.5
-XX:MaxPermSize=690m
-Xms40m
-Xmx700m

Workspaces

  • Start Eclipse
  • In Workspace Launcher
    point the "Workspace:" field to a new Workspace-folder like "C:\Documents and Settings\<username>\My Documents\DEV\<companyname>" (Windows) or "/home/<username>/DEV/<companyname>" (Linux).
    Better would be a very short path for the workspace directory (to avoid later problems if your project has a very deep folder hierarchy/packages), e.g. "D:\WORKSPACES\<companyname>" (Windows).
    Don't check "Use this as default..." (so it will be easier to switch between different workspaces later)
  • Close "Welcome" tab.

Basic Preference Settings

Window - Preferences:
  General: Show heap status
  General - Editors - Text Editors: Show line numbers
  General - Editors - Text Editors - Spelling - Dictionaries: Encoding: UTF-8
  General - Network Connections: Manual proxy configuration
    HTTP proxy: <company_proxy_address>, Port: <company_proxy_port>
    Use this proxy server for SSL
    No proxy for: add internal addresses
    Enable proxy authentication: <username>/<password>
  General - Workspace: Text file encoding: Other: UTF-8
    Java - Code Style - Formatter - Java Conventions [built-in] -> Use Sun Java Code Conventions
    

Proxy Settings

Problem: Eclipse 3.5 (Galileo) has problems using authenticated NTML proxy.
Solution: The Apache httpclient implementation should be disabled because it doesn’t work well with NTMLv2 proxies. For NTLMv2 Proxies, that require user name and password for access the workaround is to Disable the ECF httpclient provider. Provide the NTLMv2 proxy authentication info (proxyhost, domain, username, and password)

Edit eclipse.ini and append the following properties:
-Dorg.eclipse.ecf.provider.filetransfer.excludeContributors=org.eclipse.ecf.provider.filetransfer.httpclient
-Dhttp.proxyPort=8080
-Dhttp.proxyHost=myproxy
-Dhttp.proxyUser=mydomain\myusername
-Dhttp.proxyPassword=mypassword
-Dhttp.nonProxyHosts=localhost|127.0.0.1
After installing the Java Development Kit (JDK) you will need a build tool for comfortable compiling and packaging Java software: Apache Maven.
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.

Specification

Installation

Windows

Unzip ZIP-file to an appropriate folder (C:\Program Files).
New folder is "C:\Program Files\apache-maven-2.2.1"

Linux

Unzip tar.gz-package to an appropriate folder (/usr/local/bin).
# cd /usr/local/bin/
# tar xvfz /home/ralf/Downloads/apache-maven-3.1.1-bin.tar.gz
New folder is "/usr/local/bin/apache-maven-3.1.1".

Configuration

System Settings

Add "bin" directory to PATH variable

Windows

Start - Settings - Control Panel - System - Advanced - Environment Variables - System variables "Path" - Edit: (add at the beginning of the line): C:\Program Files\apache-maven-2.2.1\bin;...

Ubuntu

# nano /etc/environment
...
PATH="/usr/local/bin/apache-maven-3.1.1/bin:$PATH"
...
# source /etc/environment
# which mvn
/usr/local/bin/apache-maven-3.1.1/bin/mvn

User Settings

Create User's base configuration

  • Create user's directory .m2 (located at "${user.home}/).
  • Copy the default settings.xml coming with maven to this location
    • Windows
      C:\> mkdir c:\Documents and Settings\.m2
      C:\> copy "c:\Program Files\apache-maven-2.2.1\conf\settings.xml" "c:\Documents and Settings\<your_username>\.m2\"
      1 file(s) copied.
    • Linux
      As user:
      $ cd
      $ mkdir .m2
      $ cp /usr/local/bin/apache-maven-3.1.1/conf/settings.xml .m2/

Local Repository

The location of your local repository can be changed in your user configuration ("${user.home}/.m2/settings.xml").
The default value is "${user.home}/.m2/repository/" (= "~/.m2/repository").
File ${user.home}/.m2/settings.xml
<settings>
  ...
  <localRepository>C:/Documents and Settings/<your_username>/.m2/repository</localRepository>
  ...
</settings>
Note: The local repository must be an absolute path.

HTTP Proxy

You can configure a proxy to use for some or all of your HTTP requests in Maven 2.0.
The username and password are only required if your proxy requires basic authentication (note that later releases may support storing your passwords in a secured keystore - in the mean time, please ensure your settings.xml file (usually ${user.home}/.m2/settings.xml) is secured with permissions appropriate for your operating system).

The nonProxyHosts setting accepts wild cards, and each host not to proxy is separated by the | character. This matches the JDK configuration equivalent.

File ${user.home}/.m2/settings.xml
<settings>
  ...
  <proxies>
    <proxy>
      <id>_location name_</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>_internal proxy address_</host>
      <port>_proxy port_</port>
      <username>{your_proxyuser}</username>
      <password>{your_proxypassword}</password>
      <nonProxyHosts>localhost</nonProxyHosts>
    </proxy>
  </proxies>
  ...
</settings>

Using an intranet mirror repository

Behind the firewall of a company's network it is useful to set up a central repository mirror server (e.g. opensource product "Archiva" or "Nexus").
Configure this central server in your maven settings file (e.g. "C:\Documents and Settings\\.m2\settings.xml"):

File ${user.home}/.m2/settings.xml
...
<mirrors>
  ...
  <mirror>
    <id>archiva.central</id>
    <mirrorOf>central</mirrorOf>
    <name>Archiva mirror of central Maven repository.</name>
    <url>http://_server_address_and_port_/archiva/repository/internal/</url>
  </mirror>
  ...
</mirrors>
...
Remove the configuration sections for local repository and for the http proxy to be sure that only the intranet maven mirror is used!
To assure that all dependencies are in the proxy repository, clean your local repository (.m2/repository) and choose "Update Dependencies" in the maven plugin for your project.

Further Configuration

Maven configuration occurs at 3 levels:
  • Project - most static configuration occurs in pom.xml, should inherit from a company-wide parent pom.xml
  • Installation - this is configuration added once for a Maven installation
  • User - this is configuration specific to a particular user (located at "${user.home}/.m2/settings.xml").
Configuration at a "Global Level" (for all users on a machine) can be done in "${maven.home}/conf/settings.xml"

Test

First Execution

Windows Command Prompt
C:\>mvn
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO]
 
You must specify at least one goal or lifecycle phase to perform build steps.
The following list illustrates some commonly used build commands:
 
 mvn clean
    Deletes any build output (e.g. class files or JARs).
 mvn test
    Runs the unit tests for the project.
 mvn install
    Copies the project artifacts into your local repository.
 mvn deploy
    Copies the project artifacts into the remote repository.
 mvn site
    Creates project documentation (e.g. reports or Javadoc).
 
Please see
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html for a complete description of available lifecycle phases.
 
Use "mvn --help" to show general usage information about Maven's command line.
 
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed May 06 12:37:24 CEST 2009
[INFO] Final Memory: 1M/4M
[INFO] ------------------------------------------------------------------------
C:\>
The output is the same under Linux:
Linux Terminal
$ mvn
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
...
This behaviour is ok, because maven does not find a pom.xml file to process and you didn't specify a goal.

Version Output

Windows Command Prompt
C:\>mvn -version
Apache Maven 2.1.0 (r755702; 2009-03-18 20:10:27+0100)
Java version: 1.6.0_13
Java home: C:\Program Files\Java\jdk1.6.0_13\jre
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows xp" version: "5.1" arch: "x86" Family: "windows"
C:\>
The platform encoding is not "UTF-8". TODO ??? (set to UTF-8)

Linux Terminal
Version 3.0.1:
$ mvn -version
Apache Maven 3.0.1 (r1038046; 2010-11-23 11:58:32+0100)
Java version: 1.6.0_22
Java home: /usr/lib/jvm/java-6-sun-1.6.0.22/jre
Default locale: de_DE, platform encoding: UTF-8
OS name: "linux" version: "2.6.35-23-generic-pae" arch: "i386" Family: "unix"
Version 3.1.1:
$ mvn -version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 17:22:22+0200)
Maven home: /usr/local/bin/apache-maven-3.1.1
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk1.7.0_45/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.8.0-19-generic", arch: "i386", family: "unix"

Documentation

Before you can start to develop Java applications or webapps you have to install the JDK (the Java SE Development Kit).

The JDK is a development environment for building applications, applets, and components using the Java programming language.
The JDK includes tools useful for developing and testing programs written in the Java programming language and running on the Java platform.

On most systems Java is preinstalled, but only the Runtime Environment (JRE). The Runtime Environment lacks developer tools like the Java compiler "javac".
To see if and which Java environment is installed, execute "java -version" on the command line. Example (Linux Mint):
# java -version
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.13.04.2)
OpenJDK Server VM (build 23.7-b01, mixed mode)
This tells us, that the OpenJDK Runtime Environment is installed. OpenJDK is an open source implementation of Java. The original Java Company was Sun Microsystems and now Oracle. Oracle offers the market leader JDK, which we are going to install now.

Specification

Installation

The following installation guide may differ in JDK versions between different systems, but even if version is outdated the installation process should be still the same.

Windows

  • Execute EXE-File
  • Wizard:
    • Accept License Agreement
    • Install all components (Java DB not needed, but is only 25 MB...)
    • Target directories (defaults, don't change anything), e.g.:
      Development Tools: C:\Program Files\Java\jdk1.6.0_13\
      Demos and Samples: C:\Program Files\Java\jdk1.6.0_13\
      Source Code: C:\Program Files\Java\jdk1.6.0_13\
      Public JRE: C:\Program Files\Java\jre6\
      Java DB: C:\Program Files\Sun\JavaDB\
  • After installation a popup appears, which wants you to register. You don't need to do this.

Linux

Ubuntu

SUN JDK 6
  • Execute Synaptic package manager
  • Install "sun-java6-jdk"
  • Agree to license shown in dialog
Downloaded Oracle JDK
Unpack the downloaded TAR.GZ-package into a suitable directory (as root):
# mkdir -p /usr/lib/jvm
# cd /usr/lib/jvm/
# tar xvfz /home/ralf/Downloads/jdk-7u45-linux-i586.tar.gz
# ls -al
total 52
drwxr-xr-x   6 root root  4096 Okt 30 17:08 .
drwxr-xr-x 180 root root 28672 Okt 28 22:45 ..
lrwxrwxrwx   1 root root    23 Okt 28 22:15 default-java -> java-1.7.0-openjdk-i386
lrwxrwxrwx   1 root root    19 Okt 28 22:15 java-1.7.0-openjdk-i386 -> java-7-openjdk-i386
-rw-r--r--   1 root root  2396 Jul  3 21:59 .java-1.7.0-openjdk-i386.jinfo
drwxr-xr-x   5 root root  4096 Apr 25  2013 java-6-openjdk-i386
drwxr-xr-x   3 root root  4096 Apr 25  2013 java-7-openjdk-common
drwxr-xr-x   5 root root  4096 Apr 25  2013 java-7-openjdk-i386
drwxr-xr-x   8 uucp  143  4096 Okt  8 15:07 jdk1.7.0_45
Install the executables as default (with very high priority, e.g. 2000) (as root):
# sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0_45/bin/java" 2000
update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/java to provide /usr/bin/java (java) in auto mode
# sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0_45/bin/javac" 2000
update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/javac to provide /usr/bin/javac (javac) in auto mode
# sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0_45/bin/javaws" 2000
update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/javaws to provide /usr/bin/javaws (javaws) in auto mode
# sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/lib/jvm/jdk1.7.0_45/bin/jar" 2000
update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/jar to provide /usr/bin/jar (jar) in auto mode

Debian

(# apt-cache search jdk –n)
(# apt-get install sun-java6-jdk –s)
# apt-get install sun-java6-jdk

Slackware based Distros

$ su -
Password: 
# cd /opt/
# ls -al
total 4
drwxr-xr-x  2 root root    6 Jun 10  2007 ./
drwxr-xr-x 20 root root 4096 Oct 31 22:07 ../
# tar xvfz /home/ralf/Downloads/jdk-7u45-linux-i586.tar.gz
...
# ls -al
total 8
drwxr-xr-x  3 root root   24 Oct 31 22:11 ./
drwxr-xr-x 20 root root 4096 Oct 31 22:07 ../
drwxr-xr-x  8 uucp  143 4096 Oct  8 15:07 jdk1.7.0_45/

Configuration

Add JAVA_HOME environment variable

Windows

  • Start - Settings - Control Panel - System - Advanced - Environment Variables
  • System variables - New: JAVA_HOME = C:\Program Files\Java\jdk1.6.0_13

Ubuntu Linux

# nano /etc/environment
...
JAVA_HOME="/usr/lib/jvm/java-6-sun/"
...
# source /etc/environment

Other Linux Distro

Linux Mint:
# nano /etc/environment
...
JAVA_HOME="/usr/lib/jvm/jdk1.7.0_45"
...
# source /etc/environment

Slackware based Distros

# vi /etc/profile.d/jdk.csh
#!/bin/csh

setenv JAVA_HOME /opt/jdk1.7.0_45
setenv MANPATH ${MANPATH}:${JAVA_HOME}/man
setenv PATH ${PATH}:${JAVA_HOME}/bin
# vi /etc/profile.d/jdk.sh
#!/bin/sh

export JAVA_HOME=/opt/jdk1.7.0_45
export MANPATH="$MANPATH:$JAVA_HOME/man"
export PATH="$PATH:$JAVA_HOME/bin"
# chmod +x /etc/profile.d/jdk.sh
# chmod +x /etc/profile.d/jdk.csh
# chmod -x /etc/profile.d/openjre.sh
# chmod -x /etc/profile.d/openjre.csh

Test

Windows

Open a new command prompt window (Start - Programs - Accessoires - Command Prompt)
C:\>java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Client VM (build 11.3-b02, mixed mode, sharing)
C:\>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_13

Ubuntu

Open a new terminal
$ java -version
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode)
$ echo $JAVA_HOME
/usr/lib/jvm/java-6-sun/

Other Distro

# java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Server VM (build 24.45-b08, mixed mode)
$ echo $JAVA_HOME
/usr/lib/jvm/jdk1.7.0_45

Troubleshooting

Download timeout because of proxy

Problem: Timeouts caused by proxy (download takes too long).
Solution Debian Linux:
  • Download "sun-java6"-packages manually onto your desktop system with browser (e.g. from http://ftp.hosteurope.de/pub/linux/debian/)
  • Copy DEB-packages to server
  • Install the packages using "dpkg –i":
    # dpkg –i sun-java6-bin_6-13-1_i386.deb
    # dpkg –i sun-java6-jdk_6-13-1_i386.deb
    # dpkg –i sun-java6-jre_6-13-1_all.deb
    

Sunday, 27 October 2013

"svnautobackup" is a tool to backup subversion repositories.

Specification

Installation

# wget http://svnautobackup.googlecode.com/files/svnbackup-1.8.tar.gz
# tar xvfz svnbackup-1.8.tar.gz
svnbackup-1.8/
svnbackup-1.8/ChangeLog
svnbackup-1.8/README.txt
svnbackup-1.8/svnbackup.sh
svnbackup-1.8/test/
svnbackup-1.8/test/shunit2
svnbackup-1.8/test/test.sh
# cp svnbackup-1.8/svnbackup.sh /usr/local/bin/
# chmod 777 /usr/local/bin/svnbackup.sh

Configuration

The script works with command line arguments (no configuration needed).

Usage

This script dumps a subversion repository to a series of compressed files. It uses a local file to remember the last changeset dumped so the script can be used to generate files for backups.

Using the --scp option, the backup files can be generated on one machine and copied to a backup server once dumped.

Manual execution

Local backup

Example:
# svnbackup.sh -v -i 100 /home/svn-repositories/svn-datazuul/
-v
  set verbose mode on

-i 100
  100 revisions to be included in each dump file
Be prepared for a short break, it will take a while:
# svnbackup.sh -v -i 100 /home/svn-repositories/svn-datazuul/
Backing up: /home/svn-repositories/svn-datazuul/
      From: 0
        To: 1967
Hist. file: ./last_saved
Chunk size: 100
Dumping 0:100 ...
Created ./dumpfile-svn-datazuul-0-100.bzip2
Dumping 101:200 ...
Created ./dumpfile-svn-datazuul-101-200.bzip2
Dumping 201:300 ...
...
Created ./dumpfile-svn-datazuul-1901-1967.bzip2
#

Backup to remote server

Example:
server-2:~# svnbackup.sh -v -i 100 \
--scp sde@server-1:/var/backups/svn \
--identity ~sde/.ssh/sde\@server-1 /var/svn-repos/<project_name>/
Notes:
-v
  set verbose mode on

-i 100
  100 revisions to be included in each dump file

--scp sde@server-1:/var/backups/svn
  Move backup files to remote server into directory "/var/backups/svn" (permissions!)

--identity ~sde/.ssh/sde\@server-1
  Identity file (private key) for scp transfer

/var/svn-repos/<project_name>/
  Repository of "project_name" will be backuped.
    
Note: Make sure that remote backup directory exists. Example: Create remote backup directory (on server-1):
# mkdir -p /var/backups/svn
# chmod 777 /var/backups/svn/

Run as cronjob

Example: Run it every day at 6am
# crontab -e
MAILTO=xxx.yyy@zzz.com

2 1 * * * /etc/webmin/cron/tempdelete.pl
0 6 * * * /usr/local/bin/svnbackup.sh -v -i 100 \
--scp sde@server-1:/var/backups/svn \
--identity ~sde/.ssh/sde\@server-1 /var/svn-repos/<project_name>/
#
WARNING: Don't forget the empty last line!

The result is sent to the MAILTO-specified address.

Restore

Copy the dump files to the target system, unpack them and use "svnadmin load" to import into an existing empty target repository (read this article about how to create an empty repository):
server-2:~# scp sde@server-1:/var/backups/svn/dump* .
sde@server-1's password:
dumpfile-<project_name>-0-17.bzip2 100% 7160KB 7.0MB/s 00:01
# bunzip2 -c `ls -tr dump*.bzip2` | svnadmin load /var/svnrepos-NEW/<project_name>/
...
# rm dump*.bzip2
# svnlook tree /var/svnrepos-NEW/<project_name>/
svnadmin load: Reads a repository dump stream from stdin, committing new revisions into the repository's filesystem.

svnlook tree: Prints the tree, starting at the root of the tree, optionally showing node revision IDs.
If you experience uncomplete import/restore try to load dumpfiles one after the other.
Example:
# svnadmin load /DATA/SVN-Repositories/svn-datazuul/ < dumpfile-svn-datazuul-101-200.bzip2.out
Newer versions of Subversion have grown more strict regarding the format of the values of Subversion's own built-in properties. ...
if you'd rather not deal with the problem right now, use the --bypass-prop-validation option with svnadmin load.

Test

On "server-2":
server-2:~# svnbackup.sh -v -i 100 --scp sde@server-1:/var/backups/svn \
--identity ~sde/.ssh/sde\@server-1 /var/svn-repos/<project_name>/
 Backing up: /var/svn-repos/<project_name>/
    From: 0
    To: 17
    Dest: sde@server-1:/var/backups/svn
 Hist. file: ./last_saved
 Chunk size: 100
 Dumping 0:17 ...
 Created ./dumpfile-<project_name>-0-17.bzip2
 dumpfile-<project_name>-0-17.bzip2           100% 7160KB 7.0MB/s 00:01
#
On "server-1":
# ls -al /var/backups/svn/
insgesamt 7184
drwxrwxrwx 2 root root 4096 22. Jul 14:25 .
drwxr-xr-x 3 root root 4096 22. Jul 14:21 ..
-rw-r--r-- 1 sde sde 7331972 22. Jul 14:25 dumpfile-<project_name>-0-17.bzip2
#
inetd (internet service daemon) is a super-server daemon on many Unix systems that manages Internet services.

Installation

# apt-cache search inetd –n
...
openbsd-inetd - OpenBSD Internet Superserver
...
# apt-get install openbsd-inetd
...
Setting up openbsd-inetd (0.20091229-2ubuntu2) ...
 * Stopping internet superserver inetd                                        [ OK ] 
 * Not starting internet superserver: no services enabled
...
#

Configuration

In file /etc/inetd.conf.
Example: Subversion server (see this article)
...
svn stream tcp nowait www-data:subversion /usr/bin/svnserve svnserve -i -r /var/svn-repos
...

Usage

# /etc/init.d/openbsd-inetd stop
 * Stopping internet superserver inetd                                                                                 [ OK ] 
root@homeserver:~# /etc/init.d/openbsd-inetd start
 * Starting internet superserver inetd                                                                                 [ OK ]
# /etc/init.d/openbsd-inetd status
 * inetd is running
Subversion is a Source Code Management (SCM) System for storing files in a versioned manner (Version Control System, VCS).

Specification

  • Homepage: http://subversion.tigris.org/
  • Version: 1.7.5
  • Documentation: http://svnbook.red-bean.com/, http://www.howtoforge.com/debian_subversion_websvn

Installation

Check if Subversion server is installed by executing "which svnserve".

Debian GNU/Linux

The subversion server is installed by default (“svnserve”).

Ubuntu Linux

Search for package name to be installed:
# apt-cache search svnserve
subversion - Advanced version control system
subversion-tools - Assorted tools related to Apache Subversion
rssh - Restricted shell allowing scp, sftp, cvs, svn, rsync or rdist
Install package "subversion":
# apt-get install subversion
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libapr1 libaprutil1 libneon27-gnutls libserf1 libsvn1 libxml2 sgml-base xml-core
Suggested packages:
  sgml-base-doc subversion-tools db5.1-util debhelper
The following NEW packages will be installed:
  libapr1 libaprutil1 libneon27-gnutls libserf1 libsvn1 libxml2 sgml-base
  subversion xml-core
0 upgraded, 9 newly installed, 0 to remove and 97 not upgraded.
Need to get 2,383 kB of archives.
...
# which svnserve
/usr/bin/svnserve

Version

# svnserve --version
svnserve, version 1.7.5 (r1336830)
   compiled Jun 22 2013, 03:54:07

Copyright (C) 2012 The Apache Software Foundation.
This software consists of contributions made by many people; see the NOTICE
file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository back-end (FS) modules are available:

* fs_base : Module for working with a Berkeley DB repository.
* fs_fs : Module for working with a plain file (FSFS) repository.

Cyrus SASL authentication is available.

Configuration

Create repository

# mkdir /var/svn-repos/
# svnadmin create --fs-type fsfs /var/svn-repos/<project_name>
# svnlook tree /var/svn-repos/<project_name>
/
#

Repository directory permissions

The repository directory needs the proper permissions for the apache user ("www-data") (under which Apache is running) and the other users. The apache user won't be put in the subversion group.
# groupadd subversion
...
# chmod 777 /var/svn-repos
# chown -R www-data:subversion /var/svn-repos/*
# chmod -R 770 /var/svn-repos/*
# ls -al /var/svn-repos/
drwxrwx---  3 root     root       4096 Oct 27 09:16 .
drwxrwxrwx 25 smbpub   smbpub     4096 Oct 27 09:16 ..
drwxrwx---  6 www-data subversion 4096 Oct 27 09:16 svn-datazuul

Start/Stop as System Service

To start the Subversion server as system service, the inetd super server is used.
(Read this article about how to install inetd):
# nano /etc/inetd.conf
...
svn stream tcp nowait www-data:subversion /usr/bin/svnserve svnserve -i -r /var/svn-repos
# /etc/init.d/openbsd-inetd restart
The well known port for the “svn”-service (“3690”) is listed in /etc/services.

Authentication and Authorization

Basic setup

Allow read-access for anonymous users and write-access for authenticated users of a project:
# nano /var/svn-repos/<project_name>/conf/svnserve.conf
...
[general]
anon-access = read
auth-access = write
password-db = passwd
...

Add user to a project

# nano /var/svn-repos/<project_name>/conf/passwd
...
[users]
john = xxxxxx
sed = yyyyyy
# /etc/init.d/openbsd-inetd restart
Note: The user "sde" ("Software Development Environment") may be a technical user for Continuous Integration build access.

WebDAV access

For accessing the repository over HTTP (instead of svn://), an Apache HTTPd server with WebDAV functionality will be used in front of the SVN-repository. see module description for "dav" and "dav_svn" or this article.

Usage

Create project layout

# mkdir svntemp
# cd svntemp/
# mkdir -p <project_name>/trunk
# mkdir -p <project_name>/branches
# mkdir -p <project_name>/tags

Import project into repository

# cd <project_name>
# svn import . svn://localhost/<project_name>/ --message 'Initial project import.' --username xxx
Note: As this step was done in our case after creating user accounts for the project, the "username" param had to be given.

Backup

Backing up subversion data can be done with "svnadmin dump".

Another option is to use the Tool "svnautobackup".
After posting my first posts I realized that in the header of each post only the time of posting was shown.

First thinking that this is a problem in the template, especially the <data:post.timestamp/>-tag, I found out that it is a global setting in Blogger itself.

You can adjust your time settings under "Settings - Language and formatting" in the admin area of your blog:


After changing the "Timestamp Format", the post showed the desired format.

Wednesday, 23 October 2013

If you want to analyze what lines of your code are not covered by unit tests (to fix this with additional tests) or just want to see how many percentages are covered, several plugins for NetBeans exist.
For Ant based projects NetBeans provides code coverage functionality out of the box (see TutorialCodeCoveragePlugin), but for Maven based projects you need to install a plugin (see MavenCodeCoverage).
In short: you either install the Cobertura Plugin or the JaCoCo Plugin of the EclEmma team. Difference: JaCoCo supports Java 7 language constructs, Cobertura doesn't.
So we decided to install JaCoCo plugin. From NetBeans 7.2 up the plugin is already installed.
To activate report generation, this has been added to pom.xml:

<build>
  <plugins>
    <plugin>
      <groupId>org.jacoco</groupId>
      <artifactId>jacoco-maven-plugin</artifactId>
      <version>0.5.8.201207111220</version>
      <executions>
        <execution>
          <goals>
            <goal>prepare-agent</goal>
          </goals>
        </execution>
        <execution>
          <id>report</id>
          <phase>prepare-package</phase>
          <goals>
            <goal>report</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
Unfortunately, when executing "mvn clean install", reports are not generated...
I get this message:
[jacoco:report]
Skipping JaCoCo execution due to missing execution data file
So decided to use Cobertura plugin. Added this to pom.xml:
<reporting>
  <plugins>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>cobertura-maven-plugin</artifactId>
      <version>2.6</version>
    </plugin>
  </plugins>
</reporting>
After adding this "Code Coverage" appeared in the context menu of the project. Execute "Code Coverage - Show Report... - Run All Tests" to get an up to date code coverage report:
Code Coverage of a Wicket quickstart project

Saturday, 19 October 2013

If you made the decision to move an existing blog from Apache Roller to Google Blogger, you will ask yourself if there is another way to move the content to your new Google blog as copy and paste.
This tutorial explains step by step how to export and import all posts with their comments.

Export from Apache Roller

First login to your Apache Roller blog and navigate to "Weblog - Export".
Download Resources: Click on "Export Resources" and save the ZIP-file.
Note: when I downloaded resources the zip-file was 42 bytes and corrupted...

Download Entries: Click "Export Entries" (weblogExport.format.mtimport) and save the downloaded TXT-file.

Convert to Google Blogger format

You have to convert the Movable Type formatted export file to Blogger format.
There is an online converter available under http://movabletype2blogger.appspot.com/
Select your file from your computer and click "Convert". Save the converted file "blogger-export.xml" to your computer.

Import into Google Blogger

Log into Google Blogger and navigate to "Settings - other":
Click "Blog tools - Import blog":
  • Select the exported blog file
  • Uncheck "Automatically publish all imported posts" to get the chance to edit the imported posts.
  • Type the captcha text
  • Click "Import Blog"
After some moments you will see the imported posts.

Edit the imported posts

The imported posts are not perfect. So edit each of them to fix them
  • set the date to the date it was in the old blog
  • upload and insert the images again

Publish imported posts

When all posts to your liking, publish them.

After some days of Apache Roller experience I created my own first theme for it.

I picked the most popular theme from Wordpress (look here) called "LightWord".

As Wordpress themes are PHP based it is practically better to save a live preview of the theme (see here) and combine it with all resource folders (like images, scripts etc.) from the downloaded PHP theme.

The final result (running Apache Roller 5.0.0.RC2).

The new Apache Roller theme features:
  • categories as animated drop down main menu
  • subcategories navigation
  • archive
  • recent entries
  • ...

Please give it a try and post feedback (e.g. when you now how to make a categories-breadcrumb navigation -  see Weblog.vm...)

Enjoy!

theme-lightword-0.9.1.tar.gz

Updates:

2010-12-17: V0.9.1: added styles for comments and comment form

2011-01-21: You can find the latest version under http://svn.codespot.com/a/apache-extras.org/roller-extras/trunk/themes/lightword

Friday, 18 October 2013

During crafting my first blogger template from scratch I ran into the need for placing some images needed by my webdesign, that are referenced in the CSS-style. As Blogger just allows you to upload images to be embedded into posts, Blogger itself does not provide this possibility.

Choosing a file hosting provider

The next solution that came into my mind was my personal Google Drive of my Google account.
But it has a big disadvantage: when viewing a blog behind a company's proxy or firewall, it may happen that the files hosted on Google Drive can not be shown because the company prohibits this. I do not want a blog that looks destructed!
So I came over another Google product: Google Sites.
Some quotes from the Google Sites Help:
With Google Sites, you can easily create and update your own site. Google Sites allows you display a variety of information in one place—including videos, slideshows, calendars, presentations, attachments, and text—and share it for viewing or editing with a small group, an entire organization, or the world.
So I do not want to create a website (yet), but use the possibility of uploading / hosting files of any type. You get a storage of 100 MB in size.

Create a Google Site

After logging in with your google account, you can start creatingyour own site:

Click on "Create".
As we do not want to create a real website for now, choose "Blank template" and enter a site name (e.g. "datazuul"). The site location will then be:
https://sites.google.com/site/<your sitename>
After entering a captcha code, click "Create".
Your new website will be created immediately and is opened automatically:

Congratulation! Your website is up and running.

Uploading files to your Google site

To upload files, click "Manage site" menu item that is in the "More" dropdown menu on the upper right of the screen:
Files can be uploaded through "Attachments". Click on the menu link on the left:
You now see an empty list and the "Upload"-Button on the top:
After uploading a file the list is updated:
The file "dotty.png" is now accessible over the link (copy link location from the "View"-link):
https://sites.google.com/site/datazuul/dotty.png
That's it!
Now I can reference the image from my Google Blogger template like this:

background: #FFF url('https://sites.google.com/site/datazuul/dotty.png') 599px top repeat-y;

Thursday, 17 October 2013

Google will use public profile data of Google+ accounts on Google Maps and other channels to promote products. If you do not want to see your face side by side with product advertising because you "endorsed" (+1 ed) a product, you can deactivate this on the page https://plus.google.com/settings/endorsements.
Just check on the page if the checkbox "Based upon my activity, Google may show my name and profile photo in shared endorsements that appear in ads." is deactivated:


Monday, 14 October 2013

So you started your own blog on Google's blogger.com, you've posted your first posts but then do not feel comfortable anymore with the standard (dull?) look of your blog? You have a better more individual design in mind?
Then you've been come to the right place!

Designing a blogger template from scratch

First of all: even if you do not like your current template/design anymore: MAKE A BACKUP!
Here we go:
  1. Log into blogger.com
  2. Click "Template"
  3. Click on "Backup/Restore" on the top right
  4. In the popup click "Download full template"
  5. Save the "template....xml" file on your computer.
XML? Hmmm... Yes: A Google blogger template is just one XML-file containing HTML/CSS and Google specific markup/tags for dynamic content/widgets.
Woo ho ho... Stop! What a techie talk!
Maybe it will be to difficult you think?
Well that is what I am thinking too when writing just this line...

But hey, we will make it, together!
Google has some help on creating a custom template:
This is the new way (in opposite to "classic" templates howto).

First of all we have to understand how a "Layout" works and what it is.
  1. Log into blogger.com
  2. Click "Layout"
Dynamic Layout configuration
You can see the Layout of your template:
  • the header area/section, the sidebar section on the right and the main section on the left.
  • in the sections there are rectangles labelled "About", "Blogposts", "Labels", ... These are "Gadgets" (dynamic content) that have been added to the sections.
  • These gadgets can be arranged via Drag and Drop and can be customized via "Edit..." in option dialogs.

Layout Sections

In our static design HTML-template Google can not detect these areas/sections without some Blogger-specific markers. Only if Layout-sections are defined you can view your template in the Layout-Designer and add the gadgets to your liking.
Google's Blogger Help describes sections like this:
The <body> section of a Layouts template is made up primarily of sections and widgets. Sections mark out areas of your page, such as the sidebar, footer, etc. A widget is an individual page element such as a picture, a blogroll, or anything else you can add from the Page Elements tab. You can include any HTML you like around the sections in your template.
Each section in your template has an opening and a closing tag, looking something like this:
<b:section id='header' class='header' maxwidgets="1" showaddelement="no">
</b:section>

A <b:section> tag can have the following attributes:
  • id - (Required) A unique name, with letters and numbers only.
  • class - (Optional) Common class names are 'navbar,' 'header,' 'main,' 'sidebar,' and 'footer.' If you switch templates later, these names help Blogger determine how best to transfer over your content. However, you can use different names, if you like.
  • maxwidgets - (Optional) The maximum number of widgets to allow in this section. If you don't specify a limit, there won't be one.
  • showaddelement - (Optional) Can be 'yes' or 'no,' with 'yes' as the default. This determines whether the Page Elements tab will show the 'Add a Page Element' link in this section.
  • growth - (Optional) Can be 'horizontal' or 'vertical,' with 'vertical' as the default. This determines whether widgets within this section are arranged side-by-side or stacked.
A section can contain widgets; it can't contain other sections or other code. If you need to insert extra code between or around certain widgets within a section, you'll need to split the section into two or more new sections.
These sections are already in our template (as DIVs with unique ids, that are referenced by CSS):
  • #header
  • #mainNav
  • #main .content
  • #sidebar
  • #footer
As the above tag attributes are defined, we will add these <b:section>-tags inside the divs:
  • #header:
    <b:section id="header-section" class="header-section" maxwidgets="1" showaddelement="no"></b:section>
  • #mainNav:
    <b:section id="mainNav-section" class="mainNav-section" maxwidgets="1" showaddelement="no"></b:section>
  • #main .content:
    <b:section id="content-section" class="content-section" showaddelement="yes"></b:section>
  • #sidebar:
    <b:section id="sidebar-section" class="sidebar-section" showaddelement="yes">
    </b:section>
  • #footer:
    <b:section id="footer-section" class="footer-section" showaddelement="yes" growth="horizontal"></b:section>
Note: we added "-section" to the ids to get not in conflict with the DIV-ids that are used for CSS-styling. Blogger will replace all section-tags with <div> tags, which will have the specified ID. So, you will have the chance to style for example div#header-section in your CSS.

Before we can test our template, do this:
  • rename HTML-file to "template-xyz.xml"
  • add Doctype-definition:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html b:version='2' class='v2' expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>

Let's try it! Open the Template code and replace the existing template code with our "template-xyz.xml" code. Click on "Preview template":

Oh... we get an error message:
"Could not load template preview: There should be one and only one skin in the template, and we found: 0"
Seems that we are still some required things missing...
Ok, let's have a look how to define a "skin".

Skin (CSS)

Google Help explains this in Fonts and Colors Tags for Layouts article.
In the <head> section of your code, you'll need to have a pair of <b:skin> </b:skin> tags. The CSS style declarations will go in between those tags, along with the variable names that make your design work with the Fonts and Colors page.
Let us first ignore the "variable" thing and place our CSS-code between <b:skin>-tags:
<head>
  ...
<b:skin>
  <style type="text/css">
html, body {
  margin:0;
  padding:0;
  height:100%;
}
    ...
  </style> 
</b:skin>
</head>

We test the template again in the template preview. Uups, again an error:
Could not load template preview: A skin cannot contain the element: style. Only text and CDATA sections are accepted.
Ok, as it is a XML-document, it can not validate our code, because CSS-code is not valid XML. So we put CDATA around the CSS-code (outside style-tags) and remove the style-tags:
<head>
  ...
<b:skin>
  <![CDATA[
html, body {
  margin:0;
  padding:0;
  height:100%;
}
    ...
  ]]>
</b:skin>
</head>

After fixing this, we successfully can replace the current template code with our new template-skeleton. It really is just a skeleton without any widgets.
But in the "Layout"-Designer our page-layout is shown correctly:
You can see the content-section on the left, the sidebar-section on the right and the footer at the bottom: they all show a "Add a Gadget"-box. The header-section and the mainNav-section are not visible - they differ in having the attribute showaddelement="no" set...

Gadgets and Widgets

Ok, let's have some fun and add obvious gadgets (click "Add a Gadget" in the section you want to add a gadget):
  • content-section: hmmm... When scrolling through the list of gadgets, none seems to be the gadget for showing the latest posts... This popup just lists gadgets available additionally to the standard widgets, that have to be added to the template manually.
The Blogger help "Page Elements Tags for Layouts" lists all available standard widget types:
  • Blog
  • BlogArchive
  • BlogProfile
  • Feed
  • Header
  • HTML
  • LinkList
  • List
  • Logo
  • Navbar
  • NewsBar
  • SingleImage
  • VideoBar
They can be inserted with the XML-tag <b:widget>, e.g.:
<b:widget id=”BlogArchive1” locked=”false” mobile=”yes” title=”Blog Archive” type=”BlogArchive”/>

For our content-section we add:
<div class="content">
  <b:section id="content-section" class="content-section" showaddelement="yes">
    <b:widget id='Blog1' locked='false' mobile='yes' title='Blog' type='Blog'/>
  </b:section>
</div>

In our sidebar-section we add the BlogArchive-widget and from the Gadget-Dialog the "Search Box"-Gadget:
<div id='sidebar'>
  <div class='content'>
    <b:section class='sidebar-section' id='sidebar-section' showaddelement='yes'>
      <b:widget id='CustomSearch1' locked='false' title='Search This Blog' type='CustomSearch'>...</b:widget>
      <b:widget id='BlogArchive1' locked='false' mobile='yes' title='Archive' type='BlogArchive'/>
    </b:section>
  </div>
</div>

And in our header-section we add the Header-widget:
<div id='header'>
  <div class='wrap'>
    <b:section class='header-section' id='header-section' maxwidgets='1' showaddelement='no'>
      <b:widget id='Header1' locked='true' mobile='yes' title='datazuul.com' type='Header'/>
    </b:section>
  </div>
</div>

The Navbar-widget seems to be the right widget for the mainNav-section. But if you add it, you will see that it is not the links to the dedicated Blog-pages you can define, but the navigation bar with search box, login, logout, ... see this:
So let's "park" it in the footer-section.
<div id='footer'>
  <div class='wrap'>
    <div class='content'>
      <b:section class='footer-section' growth='horizontal' id='footer-section' showaddelement='yes'>
        <b:widget id='Navbar1' locked='true' mobile='no' title='Navbar' type='Navbar'/>
      </b:section>
    </div>
  </div>
</div>

The pages-navigation gadget can be added with the Gadget-dialog over the Layout-Designer after editing the template and change the section-attribute from
showaddelement='no'
to
showaddelement='yes'


By default the dialog states "Pages: Already added":
Who did this? No, it is not in the template, yet.
What the source of this statement is: Pages are not activated to be shown. So click in the menu on "Pages" and change "Show pages as" to "Top tabs":
Now you can add the pages navigation to the mainNav-section. It is already inserted into the layout, so drag and drop it to the mainNav-section. Edit the widget and remove the title.
The mainNav-section now contains the PageList widget:
<div id='mainNav'>
  <div class='wrap'>
    <b:section class='mainNav-section' id='mainNav-section' maxwidgets='1' showaddelement='yes'>
      <b:widget id='PageList1' locked='false' title='' type='PageList'>...</b:widget>
    </b:section>
  </div>
</div>

The raw-styled blog now looks like this:

Ok, the content is there... but still a lot to style...

What else?

Further steps should be taken by adding
For adding the title-tag in our HTML-head section it can be generated with some dynamic tags:
<b:if cond='data:blog.pageType == "index"'>
  <title><data:blog.pageTitle/></title>
<b:else/>
  <title><data:blog.pageName/> - <data:blog.title/></title>
</b:if>
That's it for now. Our static webdesign has been transformed to a blogger template. There are still things to discover...

P.S.: In this post I write about how to host files blogger (design-)files on Google Sites

Thursday, 10 October 2013

Static blog posts are sufficient for spreading information, but what if you want to provide some functionality or service?
Maybe a little application that needs some input from the user to provide him information dynamically?
What if this application does not need a big infrastructure with servers and databases?
You just want to provide a little thing: then Javascript would be sufficient.

But how to embed Javascript code in a blog post that provides the necessary static information around your little app?

Embed your javascript application into a blog post in 5 steps
  1. Start editing your blog post
  2. Write your static content in the comfortable "Compose" WYSIWYG-mode
  3. When you are ready to embed your Javascript/dynamic HTML code switch to "HTML"-mode
  4. Under "Post settings" (on the right) click on "Options", change "Compose mode" to "Show HTML literally" and click "Done"
  5. Embed your Javascript/dynamic HTML code and save the post
WARNING: after copying/pasting your code into the page do not switch back to "Compose"-mode! The editor will format the page AND your code! It may be unexecutable afterwords.

A little example:

date style 1:

date style 2:

date style 3:

date style 4:

The embedded code shows the current date in different formats and is directly placed after the static text "A little example:"

This the embedded code:

A little example:<br />
<script type="text/javascript" language="JavaScript">
 function displayDateTime(dateStyle) {
   var today = new Date();
   var dStr = "";
  
   switch (dateStyle) {
     case 1:
       dStr = today.toDateString();
       break;
     case 2:
       dStr = today.toLocaleString();
       break;
     case 3:
       dStr = today.toLocaleTimeString();
       break;
     case 4:
     default:
       dStr = today.toLocaleDateString();
       break;
     }
     document.write(dStr);
   }
</script>

<p><strong>date style 1:</strong> <script language=JavaScript>displayDateTime(1)</script></p>

<p><strong>date style 2:</strong> <script language=JavaScript>displayDateTime(2)</script></p>

<p><strong>date style 3:</strong> <script language=JavaScript>displayDateTime(3)</script></p>

<p><strong>date style 4:</strong> <script language=JavaScript>displayDateTime(4)</script></p>

Play around with some little "Hello World"-examples to get used to it!

We successfully embedded javascript code into the post.

Done.

Tuesday, 8 October 2013

When Designing websites you often will need HTML color codes (like #FFCCDD) for setting the color of text or background colors (CSS-styles: "color", "background-color").

Color Tester

Text in your color
Hexadecimal Code for Background Color (e.g.: #FFCC99): #
Hexadecimal Code for Text Color (e.g.: #EEE): #

Color Palette

And here we provide a color palette with 1331 colors:

Friday, 4 October 2013

Before choosing Google's blogging platform (blogger.com) as the solution for my needs I investigated into finding answers for these requirements:

Requirements

  • Can I customize the code of Google's templates? yes and yes
  • Can I code an own template? yes
  • Can I make a backup of the complete content of my blog? yes
  • Can I integrate a syntax highlighter for code-snippets? yes (see below)
  • Can I define a main navigation to get structured/categorized access to the content? yes
  • Can I add advertising to make some money? yes
  • Can I use an own top level domain (like www.datazuul.com)? yes

How to exchange the blog's template

Before pushing it too hard (by starting developing a new template from scratch, see Blogger Help: Page Elements Tags for Layouts), it is easier to spend some time in searching for a suitable (free) template. Here are some sites where you can download templates for your blog:
When you've found a template you like, download it (usually aZIP-file) and unpack it. Open www.blogger.com, login to your blog and click "Template - Edit HTML-button". The HTML-like (containing special blogger-tags) template code is shown. Replace the code with the code of the unpacked XML-file (e.g. MyTimeLine.xml) and preview the result. If you like it, save it. Done.

How to put your logo into the blog's header

Open www.blogger.com, login to your blog and click "Layout - Configure Header". In the edit dialog for the header content upload the logo's image from your computer and check the radio: Placement = Instead of title and description. Done.

How to link your blog to your Google+ profile

see https://support.google.com/blogger/answer/1375600
If you already have a public Google+ profile, click the gear icon at the top of your Dashboard and select "Connect to Google+," or visit this link to start the switching process. If you’re signing up for a Google Account for the first time through Blogger, you have the option of using your Google+ profile for your blog during the sign-up flow.
These leads to the following effects:
  • Your public Google+ profile will replace your Blogger profile
  • Your profile gadget will show information, including your common name , from your public Google+ profile instead of your Blogger profile
  • Your posts and comments will link to your public Google+ profile
  • This change will affect all your blogs
  • Information on your Blogger profile won't be transferred to your Google+ profile, so copy your Blogger profile information to your Google+ profile before switching
Done.

How to share published blog posts automatically on Google+

Open www.blogger.com, login to your blog and click "Google+", check "Automatically share after posting" to share your post publicly on Google+.

If you want to control to what circles or publicly a post is shared, check "Prompt to share after posting". When you publish a post, a pre-filled share box will be displayed. Select the circles that you wish to share with, add a custom message if you like, and click "Share".

Done.

How to add advertising

Open www.blogger.com, login to your blog and click "Earnings - Sign up for AdSense". As soon you have activated your AdSense account, ads are added to your blog. As long as your earnings haven't reached a specified threshold ($10 / €10) you can not specify your bank account. So no money, yet ;-). Done.

How to add Syntax Highlighter for code snippets

From time to time you want to show your blog guests code snippets. You could do this with plain <pre>-tag for formatting code.
But there is a better way by using Alex Gorbatchev' SyntaxHighlighter.

And here are the steps to integrate it into your blog. Unfortunately you can not upload the necessary scripts to your blog, so the scripts are linked to Alex Gorbatchev's site locations. (If you want to host files for your blog, you can read here about how to do it.)

Add this to your template's HEAD-section:

<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<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>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'></script>
<script language="javascript" type="text/javascript">
 SyntaxHighlighter.config.bloggerMode = true;
 SyntaxHighlighter.all();
</script>
Now you can use the SyntaxHighlighter by adding code wrapped in a PRE-tag with proper class-attribute for the highlighting brush, e.g.
<pre class="brush:java;">
public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello, World");
  }
}
</pre>
This results in the following highlighted code snippet:
public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello, World");
  }
}
Done.