Skip to content

Commit

Permalink
2012-07-15 ServiceStack's Markdown Razor Engine http://www.ipreferjim…
Browse files Browse the repository at this point in the history
  • Loading branch information
jimschubert committed Jul 15, 2012
1 parent ef4a1dc commit 22eb52d
Show file tree
Hide file tree
Showing 16 changed files with 287 additions and 1 deletion.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,11 @@ Generated_Code #added for RIA/Silverlight projects
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.XML

# Ignore gedit templ files
*~

# Ignore others
*.userprefs
*.mdb
27 changes: 27 additions & 0 deletions 2012-07-15/RazorExample/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Reflection;
using System.Runtime.CompilerServices;

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle("RazorExample")]
[assembly: AssemblyDescription("Example using ServiceStack's Markdown Razor Engine")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("jim")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("1.0.*")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

54 changes: 54 additions & 0 deletions 2012-07-15/RazorExample/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using ServiceStack.WebHost.Endpoints.Formats;
using ServiceStack.WebHost.Endpoints.Support.Markdown;
using System.Reflection;
using System.IO;
using System.Collections.Generic;

namespace RazorExample
{
class MainClass
{
// Stub some example objects
static List<Example> examples = new List<Example>() {
new Example { Name="Phil", Number=1 },
new Example { Name="Frank", Number=2 },
new Example { Name="Sally", Number=3 },
new Example { Name="Ralph", Number=4 },
new Example { Name="Ginny", Number=5 },
new Example { Name="Gomer", Number=6 },
new Example { Name="Alicia", Number=7 },
};

public static void Main (string[] args)
{
// Get executing path and /example.md full path
string exeLocation = Assembly.GetExecutingAssembly().Location;
string path = Path.GetDirectoryName( exeLocation );
string template = Path.Combine(path, "example.md");

// Create the markdown-razor template compiler
MarkdownFormat format = new MarkdownFormat();
string contents = File.ReadAllText(template);
var page = new MarkdownPage(format, path, "example", contents );
format.AddPage(page);

// Create our view container (ViewBag)
var view = new Dictionary<string, object>()
{
{ "examples", examples }
};

// Compile and output.
// This can be redirected to html file
// e.g. RazorExample.exe > output.html
var html = format.RenderDynamicPageHtml("example", view);
Console.WriteLine(html);
}
}

class Example {
public string Name;
public int Number;
}
}
10 changes: 10 additions & 0 deletions 2012-07-15/RazorExample/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# RazorExample

This is quick example of using ServiceStack's Markdown Razor view engine.

# Licensing

ServiceStack is [licensed](https://raw.github.com/ServiceStack/ServiceStack/ff9860add162c48e786307a00d5902b53cd904f2/LICENSE)
separately from this project.

ASP.NET MVC3 [source](https://aspnet.codeplex.com/downloads/get/195410) is [licensed](https://aspnet.codeplex.com/license) under MS-PL.
80 changes: 80 additions & 0 deletions 2012-07-15/RazorExample/RazorExample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>10.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{084F83AA-B2BB-4C38-8425-6232116957E7}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>RazorExample</RootNamespace>
<AssemblyName>RazorExample</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>True</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>False</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<Externalconsole>True</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>none</DebugType>
<Optimize>True</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<Externalconsole>True</Externalconsole>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="ServiceStack.Common">
<HintPath>lib\ServiceStack.Common.dll</HintPath>
</Reference>
<Reference Include="ServiceStack">
<HintPath>lib\ServiceStack.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Interfaces">
<HintPath>lib\ServiceStack.Interfaces.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.RazorEngine">
<HintPath>lib\ServiceStack.RazorEngine.dll</HintPath>
</Reference>
<Reference Include="ServiceStack.Text">
<HintPath>lib\ServiceStack.Text.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor">
<HintPath>lib\System.Web.Razor.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Main.cs" />
<Compile Include="AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Folder Include="lib\" />
</ItemGroup>
<ItemGroup>
<None Include="lib\ServiceStack.Common.dll" />
<None Include="lib\ServiceStack.Interfaces.dll" />
<None Include="lib\ServiceStack.RazorEngine.dll" />
<None Include="lib\ServiceStack.RazorEngine.dll.config" />
<None Include="lib\ServiceStack.Text.dll" />
<None Include="lib\ServiceStack.dll" />
<None Include="lib\System.Web.Razor.dll" />
<None Include="README.md" />
</ItemGroup>
<ItemGroup>
<Content Include="example.md">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="lib\LICENSE.md">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions 2012-07-15/RazorExample/RazorExample.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RazorExample", "RazorExample.csproj", "{084F83AA-B2BB-4C38-8425-6232116957E7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{084F83AA-B2BB-4C38-8425-6232116957E7}.Debug|x86.ActiveCfg = Debug|x86
{084F83AA-B2BB-4C38-8425-6232116957E7}.Debug|x86.Build.0 = Debug|x86
{084F83AA-B2BB-4C38-8425-6232116957E7}.Release|x86.ActiveCfg = Release|x86
{084F83AA-B2BB-4C38-8425-6232116957E7}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = RazorExample.csproj
EndGlobalSection
EndGlobal
21 changes: 21 additions & 0 deletions 2012-07-15/RazorExample/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Example ServiceStack.Markdown

## Showing @examples.Count items

@foreach (var item in examples) {
- @item.Name: @item.Number
}


**Note: The template requires a space after the item.Number value**

For more information, check out
[the docs](http://www.servicestack.net/docs/markdown/markdown-razor).

Also, *don't forget* to check out the code at
[gh:ServiceStack/ServiceStack](https://github.com/ServiceStack/ServiceStack)

Here are some _other_ attempts to **break**
the markdown **generation_of_html**. **escaped\_underscore\_in\_tags**

A space after double-asterisk (&lt;strong&gt; tags) will ** break **
29 changes: 29 additions & 0 deletions 2012-07-15/RazorExample/lib/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Compiled from source [bdb299a659](https://github.com/ServiceStack/ServiceStack/tree/bdb299a6594a5f620735b6c3c20016b5b3ad5f5d/).

# Service Stack License

Copyright (c) 2007-2011, Demis Bellot, ServiceStack.
http://www.servicestack.net
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the ServiceStack nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions 2012-07-15/RazorExample/lib/ServiceStack.RazorEngine.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Binary file not shown.
Binary file added 2012-07-15/RazorExample/lib/ServiceStack.dll
Binary file not shown.
Binary file added 2012-07-15/RazorExample/lib/System.Web.Razor.dll
Binary file not shown.
27 changes: 27 additions & 0 deletions 2012-07-15/RazorExample/output.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<h1>Example ServiceStack.Markdown</h1>

<h2>Showing 7 items</h2>

<ul>
<li>Phil: 1 </li>
<li>Frank: 2 </li>
<li>Sally: 3 </li>
<li>Ralph: 4 </li>
<li>Ginny: 5 </li>
<li>Gomer: 6 </li>
<li>Alicia: 7 </li>
</ul>

<p><strong>Note: The template requires a space after the item.Number value</strong></p>

<p>For more information, check out
<a href="http://www.servicestack.net/docs/markdown/markdown-razor">the docs</a>.</p>

<p>Also, <em>don't forget</em> to check out the code at
<a href="https://github.com/ServiceStack/ServiceStack">gh:ServiceStack/ServiceStack</a></p>

<p>Here are some <em>other</em> attempts to <strong>break</strong>
the markdown <strong>generation<em>of</em>html</strong>. <strong>escaped_underscore_in_tags</strong></p>

<p>A space after double-asterisk (&lt;strong&gt; tags) will <em>* break *</em></p>

0 comments on commit 22eb52d

Please sign in to comment.