diff --git a/src/Orchard/Mvc/Html/LayoutExtensions.cs b/src/Orchard/Mvc/Html/LayoutExtensions.cs
index a341a18da..45cd5a605 100644
--- a/src/Orchard/Mvc/Html/LayoutExtensions.cs
+++ b/src/Orchard/Mvc/Html/LayoutExtensions.cs
@@ -28,7 +28,7 @@ namespace Orchard.Mvc.Html {
pageTitleBuilder.AddTitleParts(titleParts);
- return MvcHtmlString.Create(pageTitleBuilder.GenerateTitle());
+ return MvcHtmlString.Create(html.Encode(pageTitleBuilder.GenerateTitle()));
}
public static void Zone(this HtmlHelper html, string zoneName, string partitions) where TModel : BaseViewModel {
@@ -51,6 +51,10 @@ namespace Orchard.Mvc.Html {
html.Zone(zoneName, () => html.RenderBody());
}
+ public static void RegisterMeta(this HtmlHelper html, string name, string content) {
+ html.Resolve().RegisterMeta(name, content);
+ }
+
public static void RegisterStyle(this HtmlHelper html, string fileName) {
html.Resolve().RegisterStyle(fileName);
}
@@ -58,5 +62,9 @@ namespace Orchard.Mvc.Html {
public static void RegisterScript(this HtmlHelper html, string fileName) {
html.Resolve().RegisterHeadScript(fileName);
}
+
+ public static void RegisterFootScript(this HtmlHelper html, string fileName) {
+ html.Resolve().RegisterFootScript(fileName);
+ }
}
}
\ No newline at end of file
diff --git a/src/Orchard/UI/Resources/IResourceManager.cs b/src/Orchard/UI/Resources/IResourceManager.cs
index 16067cb01..0b425119e 100644
--- a/src/Orchard/UI/Resources/IResourceManager.cs
+++ b/src/Orchard/UI/Resources/IResourceManager.cs
@@ -2,9 +2,11 @@ using System.Web.Mvc;
namespace Orchard.UI.Resources {
public interface IResourceManager : IDependency {
+ void RegisterMeta(string name, string content);
void RegisterStyle(string fileName);
void RegisterHeadScript(string fileName);
void RegisterFootScript(string fileName);
+ MvcHtmlString GetMetas();
MvcHtmlString GetStyles();
MvcHtmlString GetHeadScripts();
MvcHtmlString GetFootScripts();
diff --git a/src/Orchard/UI/Resources/ResourceFilter.cs b/src/Orchard/UI/Resources/ResourceFilter.cs
index fb278495c..11348f30b 100644
--- a/src/Orchard/UI/Resources/ResourceFilter.cs
+++ b/src/Orchard/UI/Resources/ResourceFilter.cs
@@ -14,6 +14,7 @@ namespace Orchard.UI.Resources {
BaseViewModel model = filterContext.Controller.ViewData.Model as BaseViewModel;
if (model != null) {
+ model.Zones.AddAction("head:metas", html => html.ViewContext.HttpContext.Response.Output.Write(_resourceManager.GetMetas()));
model.Zones.AddAction("head:styles", html => html.ViewContext.HttpContext.Response.Output.Write(_resourceManager.GetStyles()));
model.Zones.AddAction("head:scripts", html => html.ViewContext.HttpContext.Response.Output.Write(_resourceManager.GetHeadScripts()));
model.Zones.AddAction("body:after", html => html.ViewContext.HttpContext.Response.Output.Write(_resourceManager.GetFootScripts()));
diff --git a/src/Orchard/UI/Resources/ResourceManager.cs b/src/Orchard/UI/Resources/ResourceManager.cs
index f62945850..165a915d0 100644
--- a/src/Orchard/UI/Resources/ResourceManager.cs
+++ b/src/Orchard/UI/Resources/ResourceManager.cs
@@ -9,8 +9,10 @@ namespace Orchard.UI.Resources {
public class ResourceManager : IResourceManager {
private readonly IThemeService _themeService;
private readonly IExtensionManager _extensionManager;
+ private const string MetaFormat = "\r\n";
private const string StyleFormat = "\r\n";
private const string ScriptFormat = "\r\n";
+ private readonly Dictionary _metas;
private readonly List _styles;
private readonly List _headScripts;
private readonly List _footScripts;
@@ -19,29 +21,39 @@ namespace Orchard.UI.Resources {
IExtensionManager extensionManager) {
_themeService = themeService;
_extensionManager = extensionManager;
- _styles = new List();
- _headScripts = new List();
- _footScripts = new List();
+ //TODO: (erikpo) Not sure if generator should be initialized here or somewhere else
+ _metas = new Dictionary(20) {{"generator", "Orchard"}};
+ _styles = new List(10);
+ _headScripts = new List(10);
+ _footScripts = new List(5);
+ }
+
+ public void RegisterMeta(string name, string content) {
+ if (!string.IsNullOrEmpty(name) && !_metas.ContainsKey(name))
+ _metas.Add(name, content);
}
public void RegisterStyle(string fileName) {
- //TODO: (erikpo) Figure out best storage here
if (!string.IsNullOrEmpty(fileName) && !_styles.Contains(fileName))
_styles.Add(fileName);
}
public void RegisterHeadScript(string fileName) {
- //TODO: (erikpo) Figure out best storage here
if (!string.IsNullOrEmpty(fileName) && !_headScripts.Contains(fileName) && !_footScripts.Contains(fileName))
_headScripts.Add(fileName);
}
public void RegisterFootScript(string fileName) {
- //TODO: (erikpo) Figure out best storage here
if (!string.IsNullOrEmpty(fileName) && !_headScripts.Contains(fileName) && !_footScripts.Contains(fileName))
_footScripts.Add(fileName);
}
+ public MvcHtmlString GetMetas() {
+ return
+ MvcHtmlString.Create(string.Join("\r\n",
+ _metas.Select(m => string.Format(MetaFormat, m.Key, m.Value)).ToArray()));
+ }
+
public MvcHtmlString GetStyles() {
return GetFiles(_styles, StyleFormat, s => GetThemePath("/styles/" + s));
}