Skip to content
This repository has been archived by the owner on Oct 18, 2018. It is now read-only.

Fix for issue #26 - To hide the Host Admin link #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/Subtext.Framework/Configuration/BlogConfigurationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class BlogConfigurationSettings
{
private Tracking _tracking;
private NameValueCollection _allowedHtmlTags;
private NameValueCollection _nonBlogPages;

public BlogConfigurationSettings()
{
Expand Down Expand Up @@ -97,6 +98,24 @@ public Tracking Tracking
public int GalleryImageThumbnailWidth { get; set; }
public int GalleryImageThumbnailHeight { get; set; }

public bool HostAdminLinkEnabled
{
get
{
if (String.IsNullOrEmpty(ConfigurationManager.AppSettings["ShowHostAdminLink"]))
{
return true;
}

bool enabled;
if (bool.TryParse(ConfigurationManager.AppSettings["ShowHostAdminLink"], out enabled))
{
return enabled;
}
return true;
}
}

/// <summary>
/// Gets a value indicating whether invisible captcha enabled. This is
/// configured within the "InvisibleCaptchaEnabled" app setting. It is not
Expand Down Expand Up @@ -142,5 +161,24 @@ public NameValueCollection AllowedHtmlTags
return _allowedHtmlTags;
}
}

/// <summary>
/// Returns a <see cref="NameValueCollection"/> containing a list
/// of page names that are not to be parsed as a request for a blog entry.
/// The key contains the file name and the value contains a short description about the page
/// </summary>
/// <value>The static file names.</value>
[XmlIgnore]
public NameValueCollection NonBlogPages
{
get
{
if (_nonBlogPages == null)
{
_nonBlogPages = ((NameValueCollection)(ConfigurationManager.GetSection("NonBlogPages")));
}
return _nonBlogPages;
}
}
}
}
3 changes: 2 additions & 1 deletion src/Subtext.Framework/Web/HttpModules/BlogRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ private static bool IsStaticFileRequest(HttpRequestBase request)
|| filePath.EndsWith(".txt", StringComparison.OrdinalIgnoreCase)
|| filePath.EndsWith(".html", StringComparison.OrdinalIgnoreCase)
|| filePath.EndsWith(".htm", StringComparison.OrdinalIgnoreCase)
|| filePath.Contains("/images/", StringComparison.OrdinalIgnoreCase);
|| filePath.Contains("/images/", StringComparison.OrdinalIgnoreCase)
|| Config.Settings.NonBlogPages.Get(request.FilePath.Substring(1))!=null;
}

private static bool IsEmbeddedResource(HttpRequestBase request)
Expand Down
18 changes: 16 additions & 2 deletions src/Subtext.Web/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<section name="Email" type="Subtext.Extensibility.Providers.ProviderSectionHandler, Subtext.Extensibility" requirePermission="false" />
<section name="BlogEntryEditor" type="Subtext.Extensibility.Providers.ProviderSectionHandler, Subtext.Extensibility" requirePermission="false" />
<section name="AllowableCommentHtml" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="NonBlogPages" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="FriendlyUrlSettings" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="EnclosureMimetypes" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="FullTextSearchEngineSettings" type="Subtext.Framework.Util.XmlSerializerSectionHandler, Subtext.Framework" requirePermission="false" />
Expand All @@ -15,7 +16,7 @@
<!-- Change the connectionStringName AppSetting to switch from one database to another. -->
<connectionStrings>
<clear />
<add name="subtextData" connectionString="Server=.\SQLEXPRESS;Database=SubtextData;Trusted_Connection=True;User Instance=false;" />
<add name="subtextData" connectionString="Server=.\SQLEXPRESS;Database=SubtextData;Trusted_Connection=True;User Instance=false;" />
</connectionStrings>
<FullTextSearchEngineSettings type="Subtext.Framework.Configuration.FullTextSearchEngineSettings, Subtext.Framework">
<Parameters>
Expand Down Expand Up @@ -57,6 +58,15 @@
<add key="sub" value="" />
<add key="code" value="" />
</AllowableCommentHtml>

<!--
This section contains information about the pages which are to be considered as static file, and should be ignored by the blog parser.
The value attribute is to summarize about the purpose of the page
-->
<NonBlogPages>
<add key="rss2.aspx" value="" />
</NonBlogPages>

<!--
This section contains a set of key / values pairs to:
1 - define the default mimetypes available in the dropdown list
Expand Down Expand Up @@ -126,7 +136,7 @@
-->
<SyndicationCompression type="gzip" level="high" />
<BlogConfigurationSettings type="Subtext.Framework.Configuration.BlogConfigurationSettings, Subtext.Framework">
<Tracking enableAggBugs="true" enableWebStats="true" queueStats="true" queueStatsCount="5" enableTrackBacks="true" enablePingBacks="true" pingWeblogs="true" />
<Tracking enableAggBugs="true" enableWebStats="false" queueStats="true" queueStatsCount="5" enableTrackBacks="true" enablePingBacks="true" pingWeblogs="true" />
<!--
Checkout Subtext.Framework.Security for hashing passwords.
This should be set when first installing the application
Expand Down Expand Up @@ -214,6 +224,10 @@
<add key="CommCreditAffiliateCode" value="SC145233" />
<add key="CommCreditAffiliateKey" value="SBT145$3_" />
<add key="FeedBurnerUrl" value="http://feedproxy.google.com/" />
<!--
Show or hide the admin link in, for now, the BlogNotActive.aspx page
-->
<add key="ShowHostAdminLink" value="true"/>
</appSettings>
<system.web>
<!-- You might need to change the value of this next item to Medium or
Expand Down
2 changes: 1 addition & 1 deletion src/Subtext.Web/aspx/SystemMessages/BlogNotActive.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<asp:PlaceHolder id="plcInactiveBlogMessage" runat="server" Visible="false">
<p>
For whatever reason, this blog is no longer active. It can be reactivated by
a host admin from the <a href="~/HostAdmin/" id="hostAdminLink" runat="server">Host Admin Tool</a>.
a host admin<span id="spanHostAdmin" runat="server"> from the <a href="~/HostAdmin/" id="hostAdminLink" runat="server">Host Admin Tool</a></span>.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapped this inside a serverside span tag.

</p>
</asp:PlaceHolder>

Expand Down
1 change: 1 addition & 0 deletions src/Subtext.Web/aspx/SystemMessages/BlogNotActive.aspx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ protected override void OnLoad(EventArgs e)
lnkBlog.HRef = Url.BlogUrl();
}
base.OnLoad(e);
spanHostAdmin.Visible = Subtext.Framework.Configuration.Config.Settings.HostAdminLinkEnabled;
}
}
}
30 changes: 18 additions & 12 deletions src/Subtext.Web/aspx/SystemMessages/BlogNotActive.aspx.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.