Added Blockquote element (#6773)

* Added Blockquote element.

Fixes #6772

* Added Citation property to Blockquote.
This commit is contained in:
Sipke Schoorstra
2016-04-15 16:27:01 +02:00
parent ef6c7b4d3f
commit 7d603684f0
8 changed files with 120 additions and 2 deletions

View File

@@ -0,0 +1,36 @@
using Orchard.Layouts.Elements;
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Layouts.Helpers;
using Orchard.Layouts.Services;
using Orchard.Layouts.ViewModels;
namespace Orchard.Layouts.Drivers {
public class BlockquoteElementDriver : ElementDriver<Blockquote> {
private readonly IElementFilterProcessor _processor;
public BlockquoteElementDriver(IElementFilterProcessor processor) {
_processor = processor;
}
protected override EditorResult OnBuildEditor(Blockquote element, ElementEditorContext context) {
var viewModel = new BlockquoteEditorViewModel {
Text = element.Content,
Citation = element.Citation
};
var editor = context.ShapeFactory.EditorTemplate(TemplateName: "Elements.Blockquote", Model: viewModel);
if (context.Updater != null) {
context.Updater.TryUpdateModel(viewModel, context.Prefix, null, null);
element.Content = viewModel.Text;
element.Citation = viewModel.Citation;
}
return Editor(context, editor);
}
protected override void OnDisplaying(Blockquote element, ElementDisplayingContext context) {
context.ElementShape.ProcessedContent = _processor.ProcessContent(element.Content, "html", context.GetTokenData());
}
}
}

View File

@@ -0,0 +1,24 @@
using Orchard.Layouts.Helpers;
using Orchard.Localization;
namespace Orchard.Layouts.Elements {
public class Blockquote : ContentElement {
public override string Category {
get { return "Content"; }
}
public override LocalizedString DisplayText {
get { return T("Blockquote"); }
}
public override string ToolboxIcon {
get { return "\uf10d"; }
}
public string Citation {
get { return this.Retrieve(x => x.Citation); }
set { this.Store(x => x.Citation, value); }
}
}
}

View File

@@ -312,6 +312,7 @@
<Compile Include="Controllers\TemplateController.cs" />
<Compile Include="Drivers\BreadcrumbsElementDriver.cs" />
<Compile Include="Drivers\CanvasElementDriver.cs" />
<Compile Include="Drivers\BlockquoteElementDriver.cs" />
<Compile Include="Drivers\MenuElementDriver.cs" />
<Compile Include="Drivers\NotificationsElementDriver.cs" />
<Compile Include="Drivers\HeadingElementDriver.cs" />
@@ -320,6 +321,7 @@
<Compile Include="Elements\Breadcrumbs.cs" />
<Compile Include="Elements\Canvas.cs" />
<Compile Include="Elements\ContentElement.cs" />
<Compile Include="Elements\Blockquote.cs" />
<Compile Include="Elements\Menu.cs" />
<Compile Include="Elements\Notifications.cs" />
<Compile Include="Elements\Heading.cs" />
@@ -368,6 +370,7 @@
<Compile Include="Models\SnippetDescriptor.cs" />
<Compile Include="Models\SnippetFieldDescriptor.cs" />
<Compile Include="Services\IFormElementServices.cs" />
<Compile Include="ViewModels\BlockquoteEditorViewModel.cs" />
<Compile Include="ViewModels\SnippetViewModel.cs" />
<Compile Include="ViewModels\SnippetFieldViewModel.cs" />
<Compile Include="ViewModels\PlaceableContentItemViewModel.cs" />
@@ -593,6 +596,15 @@
<ItemGroup>
<Content Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Elements\Blockquote.Design.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Elements\Blockquote.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\EditorTemplates\Elements.Blockquote.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@@ -0,0 +1,6 @@
namespace Orchard.Layouts.ViewModels {
public class BlockquoteEditorViewModel {
public string Text { get; set; }
public string Citation { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
@model Orchard.Layouts.ViewModels.BlockquoteEditorViewModel
@{
Script.Include("AutoFocus.js");
}
<fieldset>
<div class="form-group autofocus">
@Html.LabelFor(m => m.Text, T("Text"))
@Html.TextAreaFor(m => m.Text, new { @class = "text large tokenized", autofocus = "autofocus" })
@Html.Hint(T("Note: HTML markup will be rendered unencoded."))
</div>
<div class="form-group">
@Html.LabelFor(m => m.Citation, T("Cite"))
@Html.TextBoxFor(m => m.Citation, new { @class = "text large" })
@Html.Hint(T("The source URL of the quotation, if any."))
</div>
</fieldset>

View File

@@ -0,0 +1,12 @@
@using Orchard.Layouts.Helpers
@using Orchard.Layouts.Elements
@{
var element = (Blockquote)Model.Element;
var tagBuilder = TagBuilderExtensions.CreateElementTagBuilder(Model, "blockquote");
tagBuilder.InnerHtml = element.Content;
if (!String.IsNullOrWhiteSpace(element.Citation)) {
tagBuilder.Attributes["cite"] = element.Citation.Trim();
}
}
@tagBuilder.ToHtmlString()

View File

@@ -0,0 +1,12 @@
@using Orchard.Layouts.Helpers
@using Orchard.Layouts.Elements
@{
var element = (Blockquote)Model.Element;
var tagBuilder = TagBuilderExtensions.CreateElementTagBuilder(Model, "blockquote");
tagBuilder.InnerHtml = Model.ProcessedContent;
if (!String.IsNullOrWhiteSpace(element.Citation)) {
tagBuilder.Attributes["cite"] = element.Citation.Trim();
}
}
@tagBuilder.ToHtmlString()

View File

@@ -242,11 +242,11 @@
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<UseIIS>True</UseIIS>
<AutoAssignPort>False</AutoAssignPort>
<DevelopmentServerPort>30321</DevelopmentServerPort>
<DevelopmentServerVPath>/OrchardLocal</DevelopmentServerVPath>
<IISUrl>http://localhost:30322/OrchardLocal</IISUrl>
<IISUrl>http://localhost:30321/OrchardLocal</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>