Changeset 13604
- Timestamp:
- 06/10/08 04:12:14 (5 years ago)
- Location:
- lang/csharp/MMMMB/MMMMB
- Files:
-
- 1 added
- 4 modified
-
IFavoritable.cs (added)
-
MMMMB.csproj (modified) (1 diff)
-
MiniBlogView.cs (modified) (1 diff)
-
MiniBlogs/FriendFeed.cs (modified) (2 diffs)
-
MiniBlogs/Twitter.cs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/csharp/MMMMB/MMMMB/MMMMB.csproj
r11290 r13604 41 41 <Compile Include="Entry.cs" /> 42 42 <Compile Include="FileLogger.cs" /> 43 <Compile Include="IFavoritable.cs" /> 43 44 <Compile Include="ILogger.cs" /> 44 45 <Compile Include="IMiniBlog.cs" /> -
lang/csharp/MMMMB/MMMMB/MiniBlogView.cs
r13454 r13604 206 206 public void PermalinkClick(string permalink) 207 207 { 208 ContextMenuStrip menu = new ContextMenuStrip(); 209 210 if (miniBlog is IFavoritable) 211 { 212 IFavoritable favable = (IFavoritable)miniBlog; 213 ToolStripItem fav = new ToolStripMenuItem(favable.FeatureName + "(&F)"); 214 fav.Click += new EventHandler(delegate(object sender, EventArgs e){ 215 favable.Create(permalink); 216 }); 217 menu.Items.Add(fav); 218 menu.Items.Add(new ToolStripSeparator()); 219 } 220 208 221 ToolStripItem open = new ToolStripMenuItem("�J��(&O)"); 209 222 open.Click += new EventHandler(delegate(object sender, EventArgs e){ 210 223 Process.Start(permalink); 211 224 }); 225 menu.Items.Add(open); 226 212 227 ToolStripItem copy = new ToolStripMenuItem("URL ��s�[(&C)"); 213 copy.Click += new EventHandler(delegate(object sender, EventArgs e) 214 { 228 copy.Click += new EventHandler(delegate(object sender, EventArgs e){ 215 229 Clipboard.SetText(permalink); 216 230 }); 217 ContextMenuStrip menu = new ContextMenuStrip();218 menu.Items.Add(open);219 231 menu.Items.Add(copy); 232 220 233 menu.Show(browser, browser.PointToClient(Cursor.Position)); 221 234 } -
lang/csharp/MMMMB/MMMMB/MiniBlogs/FriendFeed.cs
r10748 r13604 9 9 namespace MMMMB.MiniBlogs 10 10 { 11 class FriendFeed : IMiniBlog 11 class FriendFeed : IMiniBlog, IFavoritable 12 12 { 13 13 private string username; … … 84 84 return null; 85 85 } 86 87 #region "IFavoritable" 88 public string FeatureName 89 { 90 get { return "Like"; } 91 } 92 public void Create(string permalink) 93 { 94 string id = Regex.Replace(permalink, @"^http://friendfeed.com/e/([a-z0-9-]+)$", "$1"); 95 WebClient client = new WebClient(); 96 client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); 97 client.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password))); 98 client.UploadString("http://friendfeed.com/api/like?entry=" + id, "POST", ""); 99 } 100 101 public void Destroy(string permalink) 102 { 103 string id = Regex.Replace(permalink, @"^http://friendfeed.com/e/([a-z0-9-]+)$", "$1"); 104 WebClient client = new WebClient(); 105 client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); 106 client.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password))); 107 client.UploadString("http://friendfeed.com/api/like/delete?entry=" + id, "POST", ""); 108 } 109 #endregion 86 110 } 87 111 } -
lang/csharp/MMMMB/MMMMB/MiniBlogs/Twitter.cs
r13455 r13604 2 2 using System.Collections.Generic; 3 3 using System.Text; 4 using System.Text.RegularExpressions; 4 5 using System.Net; 5 6 using System.Xml; … … 9 10 namespace MMMMB.MiniBlogs 10 11 { 11 class Twitter : IMiniBlog 12 class Twitter : IMiniBlog, IFavoritable 12 13 { 13 14 private string username; … … 80 81 return "@" + entry.Name; 81 82 } 83 84 #region "IFavoritable" 85 public string FeatureName 86 { 87 get { return "Favorite this update"; } 88 } 89 public void Create(string permalink) 90 { 91 string id = Regex.Replace(permalink, @"^http://twitter.com/.+?/statuses/([0-9]+)$", "$1"); 92 WebClient client = new WebClient(); 93 client.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password))); 94 client.UploadString("http://twitter.com/favourings/create/" + id + ".xml", "POST", ""); 95 } 96 97 public void Destroy(string permalink) 98 { 99 string id = Regex.Replace(permalink, @"^http://twitter.com/.+?/statuses/([0-9]+)$", "$1"); 100 WebClient client = new WebClient(); 101 client.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes(username + ":" + password))); 102 client.UploadString("http://twitter.com/favourings/destroy/" + id + ".xml", "POST", ""); 103 } 104 #endregion 82 105 } 83 106 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)