0 Comments

Few years back I released and wrote about the NSQLFormatter. NSQLFormatter is an open-source SQL Beautifier / Formatter library written with C#.

The library is now available as a portable class library.You can get either the source code through GitHub or the PCL-compatible DLL through NuGet.

Source code: https://github.com/mikoskinen/NSQLFormatter-dotnet

Nuget: https://www.nuget.org/packages/NSQLFormatter/

5 Comments


Windows Azure supports Wordpress out of the box. But what is little-known are the limitations of this solution:

  • The maximum size of the Wordpress database is 20MB.
  • The MySQL database is provided by ClearDB, not Microsoft. In order to raise the limit, one must purchase a plan (starting from $9.99/mo) through ClearDB.

Fortunately, it’s possible to skip the MySQL altogether and to run Wordpress with SQL Azure.

Tools

Officially Wordpress supports only MySQL. But it has a rich set of different plugins and one of those plugins is WP Db Abstraction. The plugin makes it possible to run the site using a different database platform, in this case SQL Azure. On the Microsoft forums a forum member mouradl provided instructions on how to install and use the plugin. I took those instructions and built a GitHub repository which make the process of deploying a Wordpress with SQL Azure a little easier.

The repository contains the following versions:

  • Wordpress 3.4.2
  • WP Db Abstraction 1.1.4

The following tutorial shows how to run the Wordpress using SQL Azure and Azure Web Sites.

Tutorial

Setting up a Wordpress with SQL Azure requires only few steps:

  1. Creation of a SQL Azure database
  2. Creation of an empty Azure Web Site
  3. Deployment of the Wordpress using Git
  4. The configuration

1. Creating the SQL Azure database

We start by creating an empty SQL Azure database using the Azure management portal. In this tutorial we use the following configuration:

  • Name: WordpressSqlAzure
  • Max size: 1GB
  • Collation: SQL_Latin1_General_CP1_CI_AS
  • Login name: wordpressuser
  • Login password: Password32
  • Region: West Europe
  • Allow Windows Azure Services To Access The Server: Yes

 

It usually takes less than a minute before the SQL Azure database is ready. Open the database details and make note of the connection string:

  • Server: co4h26putx.database.windows.net

2. Creating the empty Azure Web Site

Next thing required is an empty Azure Web Site. It’s best to create it to the same region as the database is created. In this tutorial the following definitions are used:

  • URL: WordpressSiteSqlAzure
  • Region: West Europe

At this point we have the empty Web site and the empty database ready.

3. The deployment of a Wordpress site

Next step is to add the Wordpress site into our web server. First, using the Azure Management Portal, enable the Git publishing for our newly created site. The required function is “Set up Git publishing”.

Take note of the web site’s Git URL:

The next part is little tricky as we have to first clone the Wordpress-SQL-Azure repository from GitHub and then deploy it to the Azure.

Clone the repository from GitHub:

git clone https://github.com/mikoskinen/wordpress-sql-azure.git

Add the Azure web site’s Git URL to the cloned repository:

git remote add azure https://miksu@wordpresssitesqlazure.scm.azurewebsites.net/WordpressSiteSqlAzure.git

Push the files to Azure Web Site:

git push azure master

Now we have the required files on Azure. Only thing left is to configure our Wordpress installation to work with the SQL Azure database.

4. The configuration

To configure the Wordpress to work with SQL Azure, we must navigate to WP Db Abstraction plugins configuration page. The URL is http://url.azurewebsites.net/wp-content/mu-plugins/wp-db-abstraction/setup-config.php, so in this tutorial: http://wordpresssitesqlazure.azurewebsites.net/wp-content/mu-plugins/wp-db-abstraction/setup-config.php

From the welcome page select “Let’s go” to set the configuration. On this step we must set the details of our SQL Azure database:

  • Database Name: WordpressSqlAzure
  • User Name: wordpressuser
  • Password: Password32
  • Database Host: co4h26putx.database.windows.net
  • Database Type: PDO SqlSrv
  • Table Prefix: wp_

Make sure to select PDO SqlSrv as database type, not “SQL Server using MS PHP Driver”:

The configuration wizard makes sure that the connection works and gives the notification that everything is set up from the SQL Azure ‘s point of view:

Now everything is ready and the install wizard will automatically continue from the Wordpress’ default installation. Give the site a name, enter a password and email and you’re all set!

Note about the plugins

Most of the Wordpress plugins should work with SQL Azure but there are some which override the db.phpfile from wp-content –folder. This happens for example with the W3 Total Cache plugin. The easiest solution is to avoid these plugins (for example WP Super Cache works without modifications) but if the db.php gets replaces by some plugin, the fix is to use a FTP Client and to upload the db.php from wordpress-sql-azure repository to the site’s wp-content –folder.

9 Comments

screenshot_smallGrazeWP7 is a Windows Phone 7 app marketing site generator. It uses the Graze templating engine with Twitter Bootstrap to create static web sites.

GrazeWP7 uses a simple configuration file to generate a static web site for your application. The generated sited is pure HTML / CSS / JavaScript and can be hosted on any web server.

More details

More details about WP7Graze, including the quick start, are available from the project’s home.

Inspiration

The GrazeWP7 was inspired from the following projects:

It uses Windows Phone image assets from those projects.

369 Comments

Grazeis a simple static site generator. It takes a template and a configuration file and generates a static web site. The generated sited is pure HTML / CSS / JavaScript and can be hosted on any web server. The Graze templates are created using the Razor Syntax.

Getting started

  1. Download and extract the Graze. It comes with an example.
  2. Run graze.exe.

The static site (index.html) is generated into the “output” folder.

Graze templates

The Graze templates are created using the Razor.

<html>
<head>
    <title>@Model.Title</title>
</head>
<body>
    <h1>@Model.Description</h1>
</body>
</html>

Graze configuration

The configuration for Graze is done in XML.

<?xml version="1.0" encoding="utf-8" ?>
<site>
  <Title>Graze</Title>
  <Description>Graze: Static site generator using Razor</Description>
</site>

The configuration file represents the data which is injected to the generated static site.

Generating the static site

Once the Graze template and the configuration file are in place, the static site can be generated running the graze.exe. The static site is outputted to the output-folder.

Examples

The GrazeWP7 uses Graze to generate marketing sites for Windows Phone 7 applications.

screenshot_small

Features

Lists

Lists can be created in XML and accessed in the Graze template. Example XML:

  <Features>
    <Feature>Layouts defined using Razor syntax.</Feature>
    <Feature>Dynamic data models created in XML.</Feature>
    <Feature>Supports complex data models and arrays.</Feature>
    <Feature>Fast static site generation.</Feature>
    <Feature>Pure HTML / CSS / Javascript output. Host in Apache, IIS etc.</Feature>
  </Features>

Example template for accessing the list:

    <h2>Features:</h2>
    <ul>
        @foreach (var feature in Model.Features)
        {
            <li>@feature</li>
        }
    </ul>

Complex types

By default all the data in the XML is of type string when accessed from the template. But complex types can be created also:

<Link Url="https://github.com/mikoskinen/graze">Source code hosted in GitHub</Link>
<a href="@Model.Link.Url">@Model.Link.Link</a>

Case sensitive

The configuration is case sensitive.

Folder structure

Graze expects the following folder structure:

graze.exe
--template/
----configuration.xml
----index.cshtml
----assets

The assets folder is copied wholly to the output folder. The assets folder can include the CSS / JSS / image files required by the template.

License

Graze is available with the MIT-license. It uses the RazorEngine to generate the output.

Source code

Graze is hosted at GitHub.