Adding Create and removing Import method for Transliteration

This commit is contained in:
Nicholas Mayne
2014-08-25 19:14:06 +01:00
parent 0c4a7793cf
commit 03296493f5
7 changed files with 89 additions and 70 deletions

View File

@@ -31,8 +31,8 @@ namespace Orchard.Localization.Controllers {
return View(viewModel);
}
public ActionResult Import() {
var viewModel = new ImportTransliterationViewModel();
public ActionResult Create() {
var viewModel = new CreateTransliterationViewModel();
return View(viewModel);
}

View File

@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Orchard.Localization {
public static class Constants {
public static string TransliterationDefaultValue = @"
[Input]
// Insert a several-word description of the modules input.
// For example:
// Romanization
[Output]
// Insert a several-word description of the modules output.
// For example:
// Cyrillic
[Description]
// Give a several-sentence description of the module.
[Preprocess]
// If you need to preprocess your input before applying
// rules specify the procedure here.
// For example:
// ToLower
// ToUpper(tr-TR)
[States]
// If you need any states other than the two predefined ones
// (START and DEFAULT) then declare their names here.
// For example:
// CONSONANT
// VOWEL
[FollowingContextMacros]
// Insert any following context macro definitions here.
// For example:
// Cons b c d f g h j k l m n p q r s t v w x y z
// ConsOrEnd <END> :Cons:
// Vowel a e i o u
// VowelAtEnd a<END> e<END> i<END> o<END> u<END>
[EscapeSpanDelimiters]
// If you need to be able to prevent spans of the input
// from being processed you can specify one pair of strings
// to indicate the beginning and end of such escaped spans.
// For example:
// { }
// /* */
[Rules]
// List your rules here. For example:
// a > x
// a(<END>) > y
// [START] fa > z [VOWEL]
";
}
}

View File

@@ -69,6 +69,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AdminMenu.cs" />
<Compile Include="Extensions\Constants.cs" />
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Controllers\TransliterationAdminController.cs" />
<Compile Include="Controllers\CutlureSelectorController.cs" />
@@ -96,7 +97,7 @@
<Compile Include="ViewModels\AddLocalizationViewModel.cs" />
<Compile Include="ViewModels\ContentLocalizationsViewModel.cs" />
<Compile Include="ViewModels\EditLocalizationViewModel.cs" />
<Compile Include="ViewModels\ImportTransliterationViewModel.cs" />
<Compile Include="ViewModels\CreateTransliterationViewModel.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="Module.txt" />
@@ -149,7 +150,7 @@
<Content Include="Views\TransliterationAdmin\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\TransliterationAdmin\Import.cshtml" />
<Content Include="Views\TransliterationAdmin\Create.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>

View File

@@ -1,5 +1,5 @@
namespace Orchard.Localization.ViewModels {
public class ImportTransliterationViewModel {
public class CreateTransliterationViewModel {
public string Rules { get; set; }
}
}

View File

@@ -0,0 +1,21 @@
@model Orchard.Localization.ViewModels.CreateTransliterationViewModel
@{
Layout.Title = T("Create Transliteration").Text;
var value = Model.Rules;
if (string.IsNullOrWhiteSpace(value)) {
value = Orchard.Localization.Constants.TransliterationDefaultValue;
}
}
@using(Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
<fieldset>
<textarea rows="25" cols="80" name="Rules">@value</textarea>
</fieldset>
<input class="button" type="submit" value="@T("Create")" />
}

View File

@@ -1,63 +0,0 @@
@model Orchard.Localization.ViewModels.ImportTransliterationViewModel
@{
Layout.Title = T("Import Transliteration").Text;
}
@using(Html.BeginFormAntiForgeryPost()) {
@Html.ValidationSummary()
<fieldset>
<textarea rows="25" cols="80" name="Rules">@Model.Rules</textarea>
<span class="hint">@T("[Input]")</span>
<span class="hint">@T("// Insert a several-word description of the modules input.")</span>
<span class="hint">@T("// For example:")</span>
<span class="hint">@T("// Romanization")</span>
<span class="hint">@T("[Output]")</span>
<span class="hint">@T("// Insert a several-word description of the modules output.")</span>
<span class="hint">@T("// For example:")</span>
<span class="hint">@T("// Cyrillic")</span>
<span class="hint">@T("[Description]")</span>
<span class="hint">@T("// Give a several-sentence description of the module.")</span>
<span class="hint">@T("[Preprocess]")</span>
<span class="hint">@T("// If you need to preprocess your input before applying")</span>
<span class="hint">@T("// rules specify the procedure here.")</span>
<span class="hint">@T("// For example:")</span>
<span class="hint">@T("// ToLower")</span>
<span class="hint">@T("// ToUpper(tr-TR)")</span>
<span class="hint">@T("[States]")</span>
<span class="hint">@T("// If you need any states other than the two predefined ones")</span>
<span class="hint">@T("// (START and DEFAULT) then declare their names here.")</span>
<span class="hint">@T("// For example:")</span>
<span class="hint">@T("// CONSONANT")</span>
<span class="hint">@T("// VOWEL")</span>
<span class="hint">@T("[FollowingContextMacros]")</span>
<span class="hint">@T("// Insert any following context macro definitions here.")</span>
<span class="hint">@T("// For example:")</span>
<span class="hint">@T("// Cons b c d f g h j k l m n p q r s t v w x y z")</span>
<span class="hint">@T("// ConsOrEnd <END> :Cons:")</span>
<span class="hint">@T("// Vowel a e i o u")</span>
<span class="hint">@T("// VowelAtEnd a<END> e<END> i<END> o<END> u<END>")</span>
<span class="hint">@T("[EscapeSpanDelimiters]")</span>
<span class="hint">@T("// If you need to be able to prevent spans of the input")</span>
<span class="hint">@T("// from being processed you can specify one pair of strings")</span>
<span class="hint">@T("// to indicate the beginning and end of such escaped spans.")</span>
<span class="hint">@T("// For example:")</span>
<span class="hint">@T("// { }")</span>
<span class="hint">@T("// /* */")</span>
<span class="hint">@T("[Rules]")</span>
<span class="hint">@T("// List your rules here. For example:")</span>
<span class="hint">@T("// a > x")</span>
<span class="hint">@T("// a(<END>) > y")</span>
<span class="hint">@T("// [START] fa > z [VOWEL]")</span>
</fieldset>
<input class="button" type="submit" value="@T("Import")" />
}

View File

@@ -10,7 +10,7 @@
@Html.ValidationSummary()
if (currentSpecifications.Any()) {
<div class="actions" style="margin-bottom: 15px;"><a class="add button primaryAction" href="#">@T("Register a new specification")</a></div>
<div class="actions" style="margin-bottom: 15px;"><a class="add button primaryAction" href="#">@T("Create a new specification")</a></div>
<table class="items">
<thead>
<tr>
@@ -36,6 +36,6 @@
<span class="hint">@T("A provider identifier may not be shown if not supplied by an internal library. Also A key and secret are not required for every mechanism")</span>
}
else {
<p class="nospecifications">@T("There are no specifications registered. Why not <a href=\"{0}\">register one</a>?", "#")</p>
<p class="nospecifications">@T("There are no specifications registered. Why not <a href=\"{0}\">Create one</a>?", Url.Action("Create"))</p>
}
}