Skip to content

Commit

Permalink
Version 01.01.05
Browse files Browse the repository at this point in the history
  • Loading branch information
Torsten Weggen committed Mar 25, 2014
1 parent 9b3e424 commit 9a4e53c
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 103 deletions.
1 change: 1 addition & 0 deletions BBNews.csproj
Expand Up @@ -253,6 +253,7 @@
<Content Include="Installation\CleanUp\CleanUp.01.00.00.txt" />
<Content Include="Installation\Config\Config.txt" />
<Content Include="Installation\License.txt" />
<Content Include="Installation\ReleaseNotes\Release.01.01.05.txt" />
<Content Include="Installation\ReleaseNotes\Release.01.01.04.txt" />
<Content Include="Installation\ReleaseNotes\Release.01.01.02.txt" />
<Content Include="Installation\ReleaseNotes\Release.01.01.01.txt" />
Expand Down
2 changes: 1 addition & 1 deletion Components/BBNewsController.cs
Expand Up @@ -313,7 +313,7 @@ public void ReadFeed(int FeedId)
DateTime pubDate = (feedItem.PublishDate.LocalDateTime != DateTime.MinValue ? feedItem.PublishDate.LocalDateTime : (DateTime)SqlDateTime.MinValue);
DateTime lastUpdated = (feedItem.LastUpdatedTime.LocalDateTime != DateTime.MinValue ? feedItem.LastUpdatedTime.LocalDateTime : (DateTime)SqlDateTime.MinValue);
news.Pubdate = (pubDate > lastUpdated ? pubDate : lastUpdated);
news.Pubdate = (news.Pubdate < (DateTime)SqlDateTime.MinValue ? (DateTime)SqlDateTime.MinValue : news.Pubdate);
news.Pubdate = (news.Pubdate <= (DateTime)SqlDateTime.MinValue ? DateTime.Now : news.Pubdate);
news.Internal = false;

if (feedItem.Id != null)
Expand Down
2 changes: 1 addition & 1 deletion Components/SqlDataProvider.cs
Expand Up @@ -335,7 +335,7 @@ public override void SaveNewsByGuid(Components.NewsInfo News)
" VALUES " +
" (@FeedId,@Title,@Summary,@Author,@News,@Link,@Image,@GUID,@Pubdate,@Hide,@Internal)";

SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.Text, insCmd, SqlParams);
int result = SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.Text, insCmd, SqlParams);
}

}
Expand Down
74 changes: 32 additions & 42 deletions Components/TwitterApi11.cs
Expand Up @@ -61,6 +61,7 @@ private class Tweets
{
public List<Tweet> statuses { get; set; }
}

public TwitterApi11 (string tokenKey, string tokenSecret, string consumerKey, string consumerSecret)
{
TokenKey = tokenKey;
Expand All @@ -69,7 +70,6 @@ public TwitterApi11 (string tokenKey, string tokenSecret, string consumerKey, st
ConsumerSecret = consumerSecret;
}


public List<NewsInfo> GetUserTimeLine(string twitterUsername, int tweetsCount)
{
// Other OAuth connection/authentication variables
Expand Down Expand Up @@ -143,11 +143,6 @@ public List<NewsInfo> GetUserTimeLine(string twitterUsername, int tweetsCount)

public List<NewsInfo> SearchTweets(string searchTerm, int tweetsCount)
{
string TokenKey = "55684465-gvmJ81DMpzs7QxjY4BlQM2GzRWE9sUZIVTWMrX9nN";
string TokenSecret = "nO07e9Vyj4MVJtAYTmYaW2RrEtuJSineAIesWtTTXA";
string ConsumerKey = "HEc2tiosBZ0U62SLmsYaOA";
string ConsumerSecret = "i3OGf4Rm3bA5MSV55X2froEjo4TCJtA49msBJ1dW9Fc";

// Other OAuth connection/authentication variables
string oAuthVersion = "1.0";
string oAuthSignatureMethod = "HMAC-SHA1";
Expand Down Expand Up @@ -233,49 +228,44 @@ private List<NewsInfo> TweetsToNews(List<Tweet> tweets)
tweet.Internal = false;
tweet.Hide = false;
tweet.Title = HttpUtility.HtmlDecode(userTweet.text);
string title = tweet.Title;

int pos = tweet.Title.IndexOf("http://t.co");
if (pos > -1)
{
string start = tweet.Title.Substring(0, pos - 1);
string rest = tweet.Title.Substring(pos);
int posEnde = rest.IndexOf(" ");
List<string> urls = new List<string>();

int i = 0;
while (title.IndexOf("http://t.co") > -1 && i < 100)
{
i++;
int pos = title.IndexOf("http://t.co");
string url = title.Substring(pos);
int posEnde = url.IndexOf(" ");
if (posEnde > -1)
{
tweet.Link = rest.Substring(0, posEnde - 1);
rest = rest.Substring(posEnde);
tweet.News = start + " <a href=\"" + tweet.Link + "\">" + tweet.Link + "</a> " + rest;
tweet.Title = start + " " + tweet.Link + rest;
}
else
{
tweet.Link = rest;
tweet.News = start + " <a href=\"" + tweet.Link + "\">" + tweet.Link + "</a> ";
tweet.Title = start + " " + tweet.Link;
}
url = url.Substring(0, posEnde).Trim();
urls.Add(url);
title = title.Replace(url, "");
}
pos = tweet.Title.IndexOf("https://t.co");
if (pos > -1)
{
string start = tweet.Title.Substring(0, pos - 1);
string rest = tweet.Title.Substring(pos);
int posEnde = rest.IndexOf(" ");

i = 0;
while (title.IndexOf("https://t.co") > -1 && i < 100)
{
i++;
int pos = title.IndexOf("https://t.co");
string url = title.Substring(pos);
int posEnde = url.IndexOf(" ");
if (posEnde > -1)
{
tweet.Link = rest.Substring(0, posEnde - 1);
rest = rest.Substring(posEnde);
tweet.News = start + " <a href=\"" + tweet.Link + "\">" + tweet.Link + "</a> " + rest;
tweet.Title = start + " " + tweet.Link + rest;
}
else
{
tweet.Link = rest;
tweet.News = start + " <a href=\"" + tweet.Link + "\">" + tweet.Link + "</a> ";
tweet.Title = start + " " + tweet.Link;
}
url = url.Substring(0, posEnde).Trim();
urls.Add(url);
title = title.Replace(url, "");
}
if (urls.Any())
tweet.Link = urls[0];

foreach (string url in urls)
{
if (!url.EndsWith(""))
tweet.News = tweet.News.Replace(url, "<a href=\"" + url + "\">" + url + "</a>");
}

news.Add(tweet);
}
return (from l in news where l.News != String.Empty orderby l.Pubdate descending select l).ToList();
Expand Down
11 changes: 11 additions & 0 deletions Installation/ReleaseNotes/Release.01.01.05.txt
@@ -0,0 +1,11 @@
<h2>Release Notes bitboxx bbnews 01.01.05</h2>
<p>bbnews 01.01.05 will work for any DNN version <strong>6.1.0</strong> and up.
<h3>BUG FIXES</h3>
<ul>
<li>Fixed a bug replacing only first url in twitter feed with a link in the news</li>
<li>Fixed a bug attaching complete html code after rss code</li>
<li>Fixed a bug when fedditem pubdate is empty or not present</li>
</ul>
<h3>ENHANCEMENTS</h3>
<ul>
</ul>
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Expand Up @@ -40,6 +40,6 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:

[assembly: AssemblyVersion("1.1.4.0")]
[assembly: AssemblyFileVersion("1.1.4.0")]
[assembly: AssemblyVersion("1.1.5.0")]
[assembly: AssemblyFileVersion("1.1.5.0")]

128 changes: 71 additions & 57 deletions View.ascx.cs
Expand Up @@ -27,6 +27,7 @@
using System.Linq;
using System.ServiceModel.Syndication;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
Expand Down Expand Up @@ -194,7 +195,7 @@ protected void Page_Init(object sender, System.EventArgs e)
if (user.IsInRole("Administrator") && IsEditable)
MultiView1.Visible = true;

if (Settings["NewsInRow"] != null)
if (Settings["NewsInRow"] != null)
{
newsInRow = 1;
rowsPerPage = 5;
Expand All @@ -211,7 +212,7 @@ protected void Page_Init(object sender, System.EventArgs e)
else
{
string message = Localization.GetString("Configure.Message", this.LocalResourceFile);
DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, message, ModuleMessage.ModuleMessageType.YellowWarning);
DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, message + " (NewsInRow)", ModuleMessage.ModuleMessageType.YellowWarning);
}
if (Settings["TemplateName"] == null && Settings["Template"] != null )
{
Expand All @@ -220,8 +221,15 @@ protected void Page_Init(object sender, System.EventArgs e)
ctrl.SaveTemplateFile("Module_" + ModuleId.ToString(), (string) Settings["Template"]);

string message = Localization.GetString("Configure.Message", this.LocalResourceFile);
DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, message, ModuleMessage.ModuleMessageType.YellowWarning);
DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, message + " (Template)", ModuleMessage.ModuleMessageType.YellowWarning);
}

if (Settings["CategoryID"] == null)
{
string message = Localization.GetString("Configure.Message", this.LocalResourceFile);
DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, message + " (Category)", ModuleMessage.ModuleMessageType.YellowWarning);
IsConfigured = false;
}
}

protected void Page_Load(object sender, System.EventArgs e)
Expand All @@ -230,34 +238,7 @@ protected void Page_Load(object sender, System.EventArgs e)
{
if (IsConfigured)
{
if (Request["feed"] != null)
{
string format = Request["feed"].ToLower().Trim();
SyndicationFeed feed = CreateFeed();
Response.ContentType = "text/xml";
Response.Charset = "utf-8";
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
using (XmlWriter writer = XmlWriter.Create(Response.OutputStream, settings))
{
switch (format)
{
case "atom":
Atom10FeedFormatter atom10Formatter = new Atom10FeedFormatter(feed);
atom10Formatter.WriteTo(writer);
break;
case "rss":
default:
Rss20FeedFormatter rss20Formatter = new Rss20FeedFormatter(feed);
rss20Formatter.WriteTo(writer);
break;

}

}
Response.End();
}
else
if (Request["feed"] != null)
{
switch (ViewIndex)
{
Expand Down Expand Up @@ -357,33 +338,66 @@ protected void Pager_PreRender(object sender, EventArgs e)
}
protected void Page_Prerender(object sender, EventArgs e)
{
string titleLabelName = DotNetNukeContext.Current.Application.Version.Major < 6 ? "lblTitle" : "titleLabel";
Control ctl = Globals.FindControlRecursiveDown(this.ContainerControl, titleLabelName);
if (Request["feed"] != null)
{
string format = Request["feed"].ToLower().Trim();
SyndicationFeed feed = CreateFeed();
Response.Clear();
Response.ContentType = "text/xml";
Response.Charset = "utf-8";
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
using (XmlWriter writer = XmlWriter.Create(Response.OutputStream, settings))
{
switch (format)
{
case "atom":
Atom10FeedFormatter atom10Formatter = new Atom10FeedFormatter(feed);
atom10Formatter.WriteTo(writer);
break;
case "rss":
default:
Rss20FeedFormatter rss20Formatter = new Rss20FeedFormatter(feed);
rss20Formatter.WriteTo(writer);
break;

}
writer.Flush();
}
Response.Flush();
Response.End();
}
else
{

if ((ctl != null))
{
if (Settings["ShowTitle"] != null && Convert.ToBoolean((string) Settings["ShowTitle"]) && TheNews != null)
{
// We can set the title of our module
((Label) ctl).Text = TheNews.Title;
}
if (Settings["ShowRss"]!= null)
{
int position = Convert.ToInt32(Settings["ShowRss"]);
Control rssIconCtrl = ParseControl("<a href=\"" + Globals.NavigateURL(TabId, "", "feed=rss") +
"\"><img src=\"" + Page.ResolveUrl("~/images/action_rss.gif") + "\" style=\"vertical-align:middle; padding-right:5px;\" /></a>");
switch (position)
{
case 1:
ctl.Parent.Controls.AddAt(0, rssIconCtrl);
break;
case 2:
ctl.Parent.Controls.Add(rssIconCtrl);
break;
}

}
}
string titleLabelName = DotNetNukeContext.Current.Application.Version.Major < 6 ? "lblTitle" : "titleLabel";
Control ctl = Globals.FindControlRecursiveDown(this.ContainerControl, titleLabelName);

if ((ctl != null))
{
if (Settings["ShowTitle"] != null && Convert.ToBoolean((string) Settings["ShowTitle"]) && TheNews != null)
{
// We can set the title of our module
((Label) ctl).Text = TheNews.Title;
}
if (Settings["ShowRss"] != null)
{
int position = Convert.ToInt32(Settings["ShowRss"]);
Control rssIconCtrl = ParseControl("<a href=\"" + Globals.NavigateURL(TabId, "", "feed=rss") +
"\"><img src=\"" + Page.ResolveUrl("~/images/action_rss.gif") + "\" style=\"vertical-align:middle; padding-right:5px;\" /></a>");
switch (position)
{
case 1:
ctl.Parent.Controls.AddAt(0, rssIconCtrl);
break;
case 2:
ctl.Parent.Controls.Add(rssIconCtrl);
break;
}

}
}
}

}
protected void lstNews_ItemCreated(object sender, ListViewItemEventArgs e)
Expand Down

0 comments on commit 9a4e53c

Please sign in to comment.