Skip to content

Commit

Permalink
Added Post List widget (3.2.0.9)
Browse files Browse the repository at this point in the history
  • Loading branch information
rxtur committed Feb 6, 2016
1 parent b1817b5 commit d15fc16
Show file tree
Hide file tree
Showing 14 changed files with 292 additions and 205 deletions.
7 changes: 1 addition & 6 deletions BlogEngine/BlogEngine.Core/Helpers/WidgetHelper.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using BlogEngine.Core.DataStore;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BlogEngine.Core.Helpers
{
Expand Down Expand Up @@ -42,6 +37,6 @@ public static void SaveSettings(StringDictionary settings, string widgetId)
ws.SaveSettings(settings);

Blog.CurrentInstance.Cache[cacheId] = settings;
}
}
}
}
26 changes: 26 additions & 0 deletions BlogEngine/BlogEngine.Core/Post.cs
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,32 @@ public bool IsVisibleToPublic
}
}

/// <summary>
/// URL of the first image in the post, if any
/// </summary>
public string FirstImgSrc
{
get
{
int idx = Content.IndexOf("<img src=");
if (idx > 0)
{
try
{
idx = idx + 10;
var idxEnd = Content.IndexOf("\"", idx);
if (idxEnd > idx)
{
var len = idxEnd - idx;
return Content.Substring(idx, len);
}
}
catch (Exception) { }
}
return "";
}
}

#endregion

#region Comment Properties
Expand Down
2 changes: 1 addition & 1 deletion BlogEngine/BlogEngine.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
[assembly: CLSCompliant(false)]
[assembly: ComVisible(false)]
[assembly: AllowPartiallyTrustedCallers]
[assembly: AssemblyVersion("3.2.0.8")]
[assembly: AssemblyVersion("3.2.0.9")]
[assembly: SecurityRules(SecurityRuleSet.Level1)]
122 changes: 0 additions & 122 deletions BlogEngine/BlogEngine.NET/AppCode/Controls/PageList.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<widget id="a73fa604-cf51-41cc-abac-f1b11643db73" title="Tag cloud" showTitle="True">Tag cloud</widget>
<widget id="deb9fd7c-e0f4-4f24-964d-d5f67332bab0" title="TextBox" showTitle="True">TextBox</widget>
<widget id="47fdb964-2c19-4099-9834-7d6ef8eb424b" title="Category list" showTitle="True">Category list</widget>
<widget id="ab97b0d9-01c7-498a-96f3-fad1c046216e" title="RecentPosts" showTitle="True">RecentPosts</widget>
<widget id="86a54bdc-32ad-4699-9494-d9969d825e8d" title="RecentComments" showTitle="True">RecentComments</widget>
<widget id="2c9454ad-9819-4f62-8b24-e92e45273c73" title="Page List" showTitle="True">Page List</widget>
<widget id="c5535c01-4401-4b71-b9bb-8c3c794029d4" title="Post List" showTitle="True">Post List</widget>
</widgets>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<SerializableStringDictionary>
<SerializableStringDictionary>
<DictionaryEntry Key="author" Value="All" />
<DictionaryEntry Key="showdesc" Value="true" />
<DictionaryEntry Key="numberofposts" Value="10" />
<DictionaryEntry Key="showdate" Value="true" />
<DictionaryEntry Key="showimg" Value="true" />
<DictionaryEntry Key="sortorder" Value="Published" />
<DictionaryEntry Key="cutegory" Value="All" />
</SerializableStringDictionary>
</SerializableStringDictionary>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<post>
<author>Admin</author>
<title>Post two</title>
<description>This is a post two. The variables searchTerm and selectCommand are initialized at the top. You're go</description>
<content>&lt;p&gt;This post is just an example using Post List widget with image in the post body.&lt;/p&gt;
&lt;p&gt;&lt;img src="/image.axd?picture=/350x150.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Post List widget should find first image in the post body and display it in the post list when this option selected in the widget admin.&lt;/p&gt;</content>
<ispublished>True</ispublished>
<isdeleted>False</isdeleted>
<iscommentsenabled>True</iscommentsenabled>
<pubDate>2016-02-06 13:54:00</pubDate>
<lastModified>2016-02-06 09:20:54</lastModified>
<raters>0</raters>
<rating>0</rating>
<slug>post-two</slug>
<tags />
<comments />
<categories />
<notifications />
</post>
6 changes: 3 additions & 3 deletions BlogEngine/BlogEngine.NET/BlogEngine.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -713,12 +713,13 @@
<Content Include="Custom\Widgets\TextBox\edit.cshtml" />
<Content Include="Custom\Widgets\TextBox\widget.cshtml" />
<Content Include="Custom\Widgets\Category list\widget.cshtml" />
<Content Include="Custom\Widgets\RecentPosts\widget.cshtml" />
<Content Include="Custom\Widgets\Search\widget.cshtml" />
<Content Include="Custom\Widgets\RecentPosts\edit.cshtml" />
<Content Include="Custom\Widgets\RecentComments\edit.cshtml" />
<Content Include="Custom\Widgets\RecentComments\widget.cshtml" />
<Content Include="AppCode\Wlw\TagMini.cshtml" />
<Content Include="Custom\Widgets\Page List\widget.cshtml" />
<Content Include="Custom\Widgets\Post List\edit.cshtml" />
<Content Include="Custom\Widgets\Post List\widget.cshtml" />
<None Include="Scripts\jquery-2.1.4.intellisense.js" />
<Content Include="Scripts\i18n\angular-locale_aa-dj.js" />
<Content Include="Scripts\i18n\angular-locale_aa-er.js" />
Expand Down Expand Up @@ -1881,7 +1882,6 @@
<Compile Include="AppCode\Controls\Blogroll.cs" />
<Compile Include="AppCode\Controls\MobileThemeSwitch.cs" />
<Compile Include="AppCode\Controls\MonthList.cs" />
<Compile Include="AppCode\Controls\PageList.cs" />
<Compile Include="AppCode\Controls\PageMenu.cs" />
<Compile Include="AppCode\Controls\PostCalendar.cs" />
<Compile Include="AppCode\Controls\PostPager.cs" />
Expand Down
20 changes: 20 additions & 0 deletions BlogEngine/BlogEngine.NET/Custom/Widgets/Page List/widget.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@using BlogEngine.Core
@{
var title = "Page List";
}
<div class="widget pagelist">
<h4 class="widget-header">@title</h4>
<div class="widget-content">
<ul>
@foreach (var page in BlogEngine.Core.Page.Pages.Where(page => page.ShowInList && page.IsVisibleToPublic))
{
var href = page.RelativeLink;
if (BlogSettings.Instance.RemoveExtensionsFromUrls && !string.IsNullOrEmpty(BlogConfig.FileExtension))
{
href = href.Replace(BlogConfig.FileExtension, "");
}
<li><a href="@href" title="@page.Description">@page.Title</a></li>
}
</ul>
</div>
</div>
100 changes: 100 additions & 0 deletions BlogEngine/BlogEngine.NET/Custom/Widgets/Post List/edit.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
@using BlogEngine.Core.Helpers
@using BlogEngine.Core
@{
var numberOfPosts = 10;
var selCategory = "All";
var selAuthor = "All";
var selOrder = "Published";
var showImg = false;
var showDesc = false;
var showDate = false;

var widgetId = Request.QueryString["id"];
var settings = WidgetHelper.GetSettings(widgetId);

if (IsPost)
{
settings["numberofposts"] = Request.Form["txtNumberOfPosts"];
settings["cutegory"] = Request.Form["ddlCategories"];
settings["author"] = Request.Form["ddlAuthors"];
settings["sortorder"] = Request.Form["ddlSortBy"];
settings["showimg"] = Request.Form["cbShowImg"] == "on" ? "true" : "false";
settings["showdesc"] = Request.Form["cbShowDesc"] == "on" ? "true" : "false";
settings["showdate"] = Request.Form["cbShowDate"] == "on" ? "true" : "false";
WidgetHelper.SaveSettings(settings, widgetId);
}
if (settings != null && settings.Count > 0)
{
numberOfPosts = int.Parse(settings["numberofposts"]);
selCategory = settings["cutegory"];
selAuthor = settings["author"];
selOrder = settings["sortorder"];
showImg = settings["showimg"] == "true" ? true : false;
showDesc = settings["showdesc"] == "true" ? true : false;
showDate = settings["showdate"] == "true" ? true : false;
}

var catList = new List<SelectListItem>();
catList.Add(new SelectListItem { Text = "All", Selected = selCategory == "All" });
foreach (var cat in Category.Categories)
{
catList.Add(new SelectListItem { Text = cat.Title, Selected = cat.Title == selCategory });
}
var authorList = new List<SelectListItem>();
authorList.Add(new SelectListItem { Text = "All", Selected = selAuthor == "All" });
var authors = Membership.GetAllUsers();
foreach (var author in authors)
{
authorList.Add(new SelectListItem { Text = author.ToString(), Selected = author.ToString() == selAuthor });
}
var orderList = new List<SelectListItem>
{
new SelectListItem{ Text = "Latest", Value="Published", Selected = selOrder == "Published" },
new SelectListItem{ Text = "Most commented", Value="Comments", Selected = selOrder == "Comments" },
new SelectListItem{ Text = "Alphabetical", Value="Alphabetical", Selected = selOrder == "Alphabetical" }
};

}
<link rel="stylesheet" href="~/Content/bootstrap.min.css">
<link rel="stylesheet" href="~/admin/themes/standard/css/styles.css">
<style>
body { background-color: #fff; }
</style>
<form method="post">
<div class="form-group">
<label for="txtNumberOfPosts">@Resources.labels.numberOfPosts</label>
@Html.TextBox("txtNumberOfPosts", numberOfPosts, new { @class = "form-control" })
</div>
<div class="form-group">
<label for="ddlCategories">@Resources.labels.category</label>
@Html.DropDownList("ddlCategories", catList, new { @class = "form-control" })
</div>
<div class="form-group">
<label for="ddlAuthors">@Resources.labels.author</label>
@Html.DropDownList("ddlAuthors", authorList, new { @class = "form-control" })
</div>
<div class="form-group">
<label for="ddlSortBy">@Resources.labels.sortOrder</label>
@Html.DropDownList("ddlSortBy", orderList, new { @class = "form-control" })
</div>
<div class="form-group">
<label>
@Html.CheckBox("cbShowImg", showImg) Display first image as thumbnail
</label>
</div>
<div class="form-group">
<label>
@Html.CheckBox("cbShowDesc", showDesc) Display post description
</label>
</div>
<div class="form-group">
<label>
@Html.CheckBox("cbShowDate", showDate) Display date published
</label>
</div>
<div>
<button type="submit" class="btn btn-success btn-sm pull-left">
@Resources.labels.save
</button>
</div>
</form>
Loading

0 comments on commit d15fc16

Please sign in to comment.