Most .Text bloggers have dealt with the assholes who spam their blog with bogus comments and the annoyance of having to click on the post link, find the comment, then delete with a popup confirmation. So since I was sending myself a smart HTML Comment Email Notice, I'd add a one-click Comment Delete function to circumvent the process I just described.
To add this process I needed a link in the email, which would execute a new page I would add in the administrative section. Email pic shown here.
Adding a page to .Text Admin takes care of any access issues, since that directory is Forms Authenticated. It also gave me a chance to add a new element to .Text Admin in 0.95. I added several in 0.94, but this was my first opportunity to work with 0.95 admin logic. Like many areas of .Text 0.95, the code is smarter and more straightforward than 0.94.
The following steps were all that were required to add an administrative page to .Text 0.95.
- Copied and renamed an existing .Text admin page. I used Statistics.aspx since it was a smaller page, and renamed it to DBVTUtils.aspx since I will want it to perform more services in the future than just deleting a comment.
- Added the new page to the Navigation.config file.
<Page title="DBVT" id="Dottext.Web.Admin.Pages.DBVTUtils" url="DBVTUtils.aspx" />
- Added the tab to PageTemplate.ascx
<!--li><a href="DBVTUtils.aspx" id="TabDBVT">DBVT</a></--li>
- Updated the admin.css to add the #TabDBVT tab stylings.
That was it. Real easy.
In the DBVTUtils page I'm simply passing EntryID and Action querystring values from the embedded email link. The page will eventually list several functions, with either a “No action taken” or the action taken for the particular item. No confirmations, no additional clicks. Clicking on the embedded email link does it all. Screenshot of the DBVTUtils admin page follows the code below.
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
lblDeletion.Text = NOACTIONTAKEN;
BindLocalUI();
}
}
private void BindLocalUI()
{
if (Request.QueryString["action"] != null)
{
string action = Request.QueryString["action"].ToString();
switch (action)
{
case "delete":
int _entryID = int.Parse(Request.QueryString["entryID"].ToString());
Entries.Delete(_entryID);
lblDeletion.Text = "Comment " + _entryID.ToString() + " deleted.";
break;
default:
break;
}
}
}