Compare commits

..

No commits in common. "de42bc7f66e6ca4c0363252eebb294f2689263d9" and "3c4e1c735ab08ee4a4db5a597b1d7b3a2ed1a31a" have entirely different histories.

10 changed files with 124 additions and 690 deletions

View File

@ -1,312 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows.Forms;
using BookmarkManager.Services;
using bzit.bomg.Models;
using RyzStudio.Windows.Forms;
using RyzStudio.Windows.ThemedForms;
namespace FizzyLauncher
{
public class AddBatchPageForm : Form
{
private System.Windows.Forms.Label label1;
private readonly WebProvider _webProvider;
private string _rootPath;
private bool _isBusy = false;
private THorizontalSeparator tHorizontalSeparator3;
private ThButton button3;
private ThProgressBar progressBar2;
private RyzStudio.Windows.ThemedForms.Composite.DialogFooter dialogFooter1;
private ThToolbarMemoBox memoBox1;
private List<BookmarkModel> _result = new List<BookmarkModel>();
private bool _requestCancel = false;
public AddBatchPageForm(string rootPath)
{
InitializeComponent();
UISetup.Dialog(this);
_result = new List<BookmarkModel>();
_webProvider = new WebProvider();
_webProvider.IgnoreSSL = true;
_rootPath = rootPath;
}
private void InitializeComponent()
{
label1 = new Label();
tHorizontalSeparator3 = new THorizontalSeparator();
button3 = new ThButton();
progressBar2 = new ThProgressBar();
dialogFooter1 = new RyzStudio.Windows.ThemedForms.Composite.DialogFooter();
memoBox1 = new ThToolbarMemoBox();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.BackColor = System.Drawing.Color.Transparent;
label1.ForeColor = System.Drawing.SystemColors.ControlText;
label1.Location = new System.Drawing.Point(10, 20);
label1.Margin = new Padding(0);
label1.Name = "label1";
label1.Padding = new Padding(0, 8, 0, 0);
label1.Size = new System.Drawing.Size(185, 23);
label1.TabIndex = 153;
label1.Text = "Add pages (one URL on each line)";
label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// tHorizontalSeparator3
//
tHorizontalSeparator3.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
tHorizontalSeparator3.AutoScrollMargin = new System.Drawing.Size(0, 0);
tHorizontalSeparator3.AutoScrollMinSize = new System.Drawing.Size(0, 0);
tHorizontalSeparator3.BackColor = System.Drawing.Color.Transparent;
tHorizontalSeparator3.Location = new System.Drawing.Point(10, 321);
tHorizontalSeparator3.Margin = new Padding(0, 10, 0, 0);
tHorizontalSeparator3.MaximumSize = new System.Drawing.Size(4920, 2);
tHorizontalSeparator3.MinimumSize = new System.Drawing.Size(0, 22);
tHorizontalSeparator3.Name = "tHorizontalSeparator3";
tHorizontalSeparator3.Size = new System.Drawing.Size(424, 22);
tHorizontalSeparator3.TabIndex = 207;
tHorizontalSeparator3.TabStop = false;
//
// button3
//
button3.ActiveImage = null;
button3.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
button3.BackColor = System.Drawing.Color.Transparent;
button3.EnableMenuOnClick = false;
button3.EnableReactiveVisual = true;
button3.HoverImage = null;
button3.IdleImage = null;
button3.LabelText = "&Add Pages";
button3.Location = new System.Drawing.Point(306, 393);
button3.Name = "button3";
button3.Size = new System.Drawing.Size(128, 32);
button3.TabIndex = 209;
button3.TabStop = false;
button3.MouseClick += button3_MouseClick;
//
// progressBar2
//
progressBar2.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
progressBar2.BackColor = System.Drawing.Color.Transparent;
progressBar2.BarColour = System.Drawing.Color.FromArgb(79, 193, 203);
progressBar2.BarTextColour = System.Drawing.Color.Black;
progressBar2.EnableReactiveVisual = false;
progressBar2.Font = new System.Drawing.Font("Segoe UI", 9F);
progressBar2.Location = new System.Drawing.Point(10, 353);
progressBar2.Maximum = 100;
progressBar2.Minimum = 0;
progressBar2.Name = "progressBar2";
progressBar2.ProgressText = "50/100";
progressBar2.ShowProgressText = true;
progressBar2.Size = new System.Drawing.Size(424, 20);
progressBar2.TabIndex = 210;
progressBar2.TabStop = false;
progressBar2.Value = 50;
//
// dialogFooter1
//
dialogFooter1.BackColor = System.Drawing.Color.FromArgb(240, 240, 240);
dialogFooter1.Button1Text = "&Close";
dialogFooter1.Dialog = this;
dialogFooter1.Dock = DockStyle.Bottom;
dialogFooter1.IsBusy = false;
dialogFooter1.Location = new System.Drawing.Point(0, 437);
dialogFooter1.Name = "dialogFooter1";
dialogFooter1.Size = new System.Drawing.Size(444, 84);
//
// memoBox1
//
memoBox1.AllowDrop = true;
memoBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
memoBox1.BackColor = System.Drawing.Color.Transparent;
memoBox1.ClearedValue = "";
memoBox1.EnableReactiveVisual = true;
memoBox1.Font = new System.Drawing.Font("Segoe UI", 9F);
memoBox1.Location = new System.Drawing.Point(10, 53);
memoBox1.Name = "memoBox1";
memoBox1.ReadOnly = false;
memoBox1.ScrollBars = ScrollBars.Vertical;
memoBox1.Size = new System.Drawing.Size(424, 258);
memoBox1.TabIndex = 211;
memoBox1.TabStop = false;
memoBox1.WordWrap = false;
//
// AddBatchPageForm
//
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = System.Drawing.Color.White;
ClientSize = new System.Drawing.Size(444, 521);
Controls.Add(memoBox1);
Controls.Add(dialogFooter1);
Controls.Add(progressBar2);
Controls.Add(button3);
Controls.Add(tHorizontalSeparator3);
Controls.Add(label1);
KeyPreview = true;
MinimumSize = new System.Drawing.Size(460, 560);
Name = "AddBatchPageForm";
Text = "Add Pages (Batch)";
ResumeLayout(false);
PerformLayout();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
memoBox1.Text = string.Empty;
progressBar2.Minimum = 0;
progressBar2.Value = 0;
progressBar2.Maximum = memoBox1.Lines?.Length ?? 0;
memoBox1.Focus();
}
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
if (this.IsBusy)
{
e.Cancel = true;
}
}
public List<BookmarkModel> Result
{
get => _result;
private set => _result = value;
}
protected bool IsBusy
{
get => _isBusy;
set
{
_isBusy = value;
UIControl.SetEnable(memoBox1, !this.IsBusy);
UIControl.Invoke(button3, (x) =>
{
button3.LabelText = (this.IsBusy ? "&Stop" : "&Add Pages");
});
dialogFooter1.IsBusy = _isBusy;
}
}
private async void button3_MouseClick(object sender, MouseEventArgs e)
{
await Task.Run(async () =>
{
if (this.IsBusy)
{
_requestCancel = true;
return;
}
this.IsBusy = true;
this.Result = new List<BookmarkModel>();
progressBar2.Minimum = 0;
progressBar2.Value = 0;
progressBar2.Maximum = memoBox1.Lines?.Length ?? 0;
foreach (var item in memoBox1.Lines ?? new string[0])
{
progressBar2.Value++;
if (string.IsNullOrWhiteSpace(item))
{
continue;
}
var newModel = new BookmarkModel();
newModel.Address = item;
newModel.Path = _rootPath;
if (_requestCancel)
{
break;
}
newModel = await UpdateBookmark(newModel, true, true);
if (newModel == null)
{
continue;
}
if (_requestCancel)
{
break;
}
this.Result.Add(newModel);
}
//_requestCancel = false;
this.IsBusy = false;
if (!_requestCancel)
{
this.DialogResult = DialogResult.OK;
UIControl.Close(this);
}
_requestCancel = false;
});
}
private async Task<BookmarkModel> UpdateBookmark(BookmarkModel model, bool updateTitle, bool updateDescription)
{
if (string.IsNullOrWhiteSpace(model.Address))
{
return null;
}
if (!model.Address.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !model.Address.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase))
{
model.Address = "http://" + model.Address;
}
var document = await _webProvider.RetrieveHtmlDocument(model.Address);
if (document == null)
{
return null;
}
if (updateTitle)
{
model.Title = _webProvider.ParseTitle(document);
}
if (updateDescription)
{
model.Description = _webProvider.ParseDescription(document);
}
return model;
}
}
}

View File

@ -1,120 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -14,7 +14,7 @@
<Copyright>Ray Lam</Copyright> <Copyright>Ray Lam</Copyright>
<AssemblyVersion>1.0.0.0</AssemblyVersion> <AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion> <FileVersion>1.0.0.0</FileVersion>
<Version>0.6.2.092</Version> <Version>0.6.1.0249</Version>
<PackageId>bukkubuddy</PackageId> <PackageId>bukkubuddy</PackageId>
<RunAnalyzersDuringLiveAnalysis>True</RunAnalyzersDuringLiveAnalysis> <RunAnalyzersDuringLiveAnalysis>True</RunAnalyzersDuringLiveAnalysis>
<SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion> <SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion>
@ -106,9 +106,6 @@
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>AppResource.resx</DependentUpon> <DependentUpon>AppResource.resx</DependentUpon>
</Compile> </Compile>
<Compile Update="AddBatchPageForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="UpdateIconsForm.cs" /> <Compile Update="UpdateIconsForm.cs" />
<Compile Update="FindForm.cs" /> <Compile Update="FindForm.cs" />
<Compile Update="EditBookmarkForm.cs" /> <Compile Update="EditBookmarkForm.cs" />

View File

@ -3,7 +3,6 @@ using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml;
using BookmarkManager.Services; using BookmarkManager.Services;
using bzit.bomg.Models; using bzit.bomg.Models;
using RyzStudio.Windows.Forms; using RyzStudio.Windows.Forms;
@ -408,14 +407,14 @@ namespace FizzyLauncher
if (updateDescription) if (updateDescription)
{ {
textBox3.Text = _webProvider.ParseDescription(document); textBox3.Text = _webProvider.ParseMetaDescription(document);
} }
if (updateIcon) if (updateIcon)
{ {
try try
{ {
pictureBox1.Image = await _webProvider.RetrieveImage(url, document); pictureBox1.Image = await _webProvider.RetrieveImage(document);
if (pictureBox1.Image != null) if (pictureBox1.Image != null)
{ {
if (pictureBox1.Image.Width > 16) if (pictureBox1.Image.Width > 16)

82
MainForm.Designer.cs generated
View File

@ -71,7 +71,6 @@ namespace FizzyLauncher
sortToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); sortToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
folderContextMenu = new System.Windows.Forms.ContextMenuStrip(components); folderContextMenu = new System.Windows.Forms.ContextMenuStrip(components);
addPageToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); addPageToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
toolStripMenuItem10 = new System.Windows.Forms.ToolStripMenuItem();
addFolderToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); addFolderToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator(); toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
openAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); openAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -91,7 +90,6 @@ namespace FizzyLauncher
moveUpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); moveUpToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
moveDownToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); moveDownToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
treeView1 = new RyzStudio.Windows.Forms.BookmarkTreeView(); treeView1 = new RyzStudio.Windows.Forms.BookmarkTreeView();
toolStripMenuItem11 = new System.Windows.Forms.ToolStripMenuItem();
menuStrip1.SuspendLayout(); menuStrip1.SuspendLayout();
rootContextMenu.SuspendLayout(); rootContextMenu.SuspendLayout();
folderContextMenu.SuspendLayout(); folderContextMenu.SuspendLayout();
@ -195,7 +193,7 @@ namespace FizzyLauncher
findToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; findToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
findToolStripMenuItem.Name = "findToolStripMenuItem"; findToolStripMenuItem.Name = "findToolStripMenuItem";
findToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F; findToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F;
findToolStripMenuItem.Size = new System.Drawing.Size(137, 22); findToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
findToolStripMenuItem.Text = "&Find"; findToolStripMenuItem.Text = "&Find";
findToolStripMenuItem.Click += findToolStripMenuItem_Click; findToolStripMenuItem.Click += findToolStripMenuItem_Click;
// //
@ -209,26 +207,26 @@ namespace FizzyLauncher
// expandAllToolStripMenuItem // expandAllToolStripMenuItem
// //
expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem"; expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem";
expandAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22); expandAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
expandAllToolStripMenuItem.Text = "&Expand All"; expandAllToolStripMenuItem.Text = "&Expand All";
expandAllToolStripMenuItem.Click += expandAllToolStripMenuItem_Click; expandAllToolStripMenuItem.Click += expandAllToolStripMenuItem_Click;
// //
// collapseAllToolStripMenuItem // collapseAllToolStripMenuItem
// //
collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem"; collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem";
collapseAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22); collapseAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
collapseAllToolStripMenuItem.Text = "&Collapse All"; collapseAllToolStripMenuItem.Text = "&Collapse All";
collapseAllToolStripMenuItem.Click += collapseAllToolStripMenuItem_Click; collapseAllToolStripMenuItem.Click += collapseAllToolStripMenuItem_Click;
// //
// toolStripSeparator1 // toolStripSeparator1
// //
toolStripSeparator1.Name = "toolStripSeparator1"; toolStripSeparator1.Name = "toolStripSeparator1";
toolStripSeparator1.Size = new System.Drawing.Size(149, 6); toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
// //
// alwaysOnTopToolStripMenuItem // alwaysOnTopToolStripMenuItem
// //
alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem"; alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem";
alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(152, 22); alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
alwaysOnTopToolStripMenuItem.Text = "Always On &Top"; alwaysOnTopToolStripMenuItem.Text = "Always On &Top";
alwaysOnTopToolStripMenuItem.Click += alwaysOnTopToolStripMenuItem_Click; alwaysOnTopToolStripMenuItem.Click += alwaysOnTopToolStripMenuItem_Click;
// //
@ -242,21 +240,21 @@ namespace FizzyLauncher
// toolStripMenuItem9 // toolStripMenuItem9
// //
toolStripMenuItem9.Name = "toolStripMenuItem9"; toolStripMenuItem9.Name = "toolStripMenuItem9";
toolStripMenuItem9.Size = new System.Drawing.Size(168, 22); toolStripMenuItem9.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem9.Text = "Update &Icons"; toolStripMenuItem9.Text = "Update &Icons";
toolStripMenuItem9.Click += toolStripMenuItem9_Click; toolStripMenuItem9.Click += toolStripMenuItem9_Click;
// //
// toolStripSeparator2 // toolStripSeparator2
// //
toolStripSeparator2.Name = "toolStripSeparator2"; toolStripSeparator2.Name = "toolStripSeparator2";
toolStripSeparator2.Size = new System.Drawing.Size(165, 6); toolStripSeparator2.Size = new System.Drawing.Size(177, 6);
// //
// optionsToolStripMenuItem // optionsToolStripMenuItem
// //
optionsToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; optionsToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
optionsToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F12; optionsToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F12;
optionsToolStripMenuItem.Size = new System.Drawing.Size(168, 22); optionsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
optionsToolStripMenuItem.Text = "&Options"; optionsToolStripMenuItem.Text = "&Options";
optionsToolStripMenuItem.Click += optionsToolStripMenuItem_Click; optionsToolStripMenuItem.Click += optionsToolStripMenuItem_Click;
// //
@ -272,19 +270,19 @@ namespace FizzyLauncher
viewHelpToolStripMenuItem1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; viewHelpToolStripMenuItem1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
viewHelpToolStripMenuItem1.Name = "viewHelpToolStripMenuItem1"; viewHelpToolStripMenuItem1.Name = "viewHelpToolStripMenuItem1";
viewHelpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1; viewHelpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1;
viewHelpToolStripMenuItem1.Size = new System.Drawing.Size(146, 22); viewHelpToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
viewHelpToolStripMenuItem1.Text = "&View Help"; viewHelpToolStripMenuItem1.Text = "&View Help";
viewHelpToolStripMenuItem1.Click += viewHelpToolStripMenuItem1_Click; viewHelpToolStripMenuItem1.Click += viewHelpToolStripMenuItem1_Click;
// //
// toolStripMenuItem16 // toolStripMenuItem16
// //
toolStripMenuItem16.Name = "toolStripMenuItem16"; toolStripMenuItem16.Name = "toolStripMenuItem16";
toolStripMenuItem16.Size = new System.Drawing.Size(143, 6); toolStripMenuItem16.Size = new System.Drawing.Size(177, 6);
// //
// aboutToolStripMenuItem1 // aboutToolStripMenuItem1
// //
aboutToolStripMenuItem1.Name = "aboutToolStripMenuItem1"; aboutToolStripMenuItem1.Name = "aboutToolStripMenuItem1";
aboutToolStripMenuItem1.Size = new System.Drawing.Size(146, 22); aboutToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
aboutToolStripMenuItem1.Text = "&About"; aboutToolStripMenuItem1.Text = "&About";
aboutToolStripMenuItem1.Click += aboutToolStripMenuItem1_Click; aboutToolStripMenuItem1.Click += aboutToolStripMenuItem1_Click;
// //
@ -296,92 +294,85 @@ namespace FizzyLauncher
// //
// rootContextMenu // rootContextMenu
// //
rootContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addPageToolStripMenuItem, toolStripMenuItem11, addFolderToolStripMenuItem, toolStripMenuItem2, editToolStripMenuItem, toolStripMenuItem3, sortToolStripMenuItem }); rootContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addPageToolStripMenuItem, addFolderToolStripMenuItem, toolStripMenuItem2, editToolStripMenuItem, toolStripMenuItem3, sortToolStripMenuItem });
rootContextMenu.Name = "rootContextMenu"; rootContextMenu.Name = "rootContextMenu";
rootContextMenu.Size = new System.Drawing.Size(181, 148); rootContextMenu.Size = new System.Drawing.Size(133, 104);
// //
// addPageToolStripMenuItem // addPageToolStripMenuItem
// //
addPageToolStripMenuItem.Name = "addPageToolStripMenuItem"; addPageToolStripMenuItem.Name = "addPageToolStripMenuItem";
addPageToolStripMenuItem.Size = new System.Drawing.Size(180, 22); addPageToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
addPageToolStripMenuItem.Text = "Add &Page"; addPageToolStripMenuItem.Text = "Add &Page";
addPageToolStripMenuItem.Click += addPageToolStripMenuItem_Click; addPageToolStripMenuItem.Click += addPageToolStripMenuItem_Click;
// //
// addFolderToolStripMenuItem // addFolderToolStripMenuItem
// //
addFolderToolStripMenuItem.Name = "addFolderToolStripMenuItem"; addFolderToolStripMenuItem.Name = "addFolderToolStripMenuItem";
addFolderToolStripMenuItem.Size = new System.Drawing.Size(180, 22); addFolderToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
addFolderToolStripMenuItem.Text = "Add &Folder"; addFolderToolStripMenuItem.Text = "Add &Folder";
addFolderToolStripMenuItem.Click += addFolderToolStripMenuItem_Click; addFolderToolStripMenuItem.Click += addFolderToolStripMenuItem_Click;
// //
// toolStripMenuItem2 // toolStripMenuItem2
// //
toolStripMenuItem2.Name = "toolStripMenuItem2"; toolStripMenuItem2.Name = "toolStripMenuItem2";
toolStripMenuItem2.Size = new System.Drawing.Size(177, 6); toolStripMenuItem2.Size = new System.Drawing.Size(129, 6);
// //
// editToolStripMenuItem // editToolStripMenuItem
// //
editToolStripMenuItem.Name = "editToolStripMenuItem"; editToolStripMenuItem.Name = "editToolStripMenuItem";
editToolStripMenuItem.Size = new System.Drawing.Size(180, 22); editToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
editToolStripMenuItem.Text = "&Edit"; editToolStripMenuItem.Text = "&Edit";
editToolStripMenuItem.Click += editToolStripMenuItem_Click; editToolStripMenuItem.Click += editToolStripMenuItem_Click;
// //
// toolStripMenuItem3 // toolStripMenuItem3
// //
toolStripMenuItem3.Name = "toolStripMenuItem3"; toolStripMenuItem3.Name = "toolStripMenuItem3";
toolStripMenuItem3.Size = new System.Drawing.Size(177, 6); toolStripMenuItem3.Size = new System.Drawing.Size(129, 6);
// //
// sortToolStripMenuItem // sortToolStripMenuItem
// //
sortToolStripMenuItem.Name = "sortToolStripMenuItem"; sortToolStripMenuItem.Name = "sortToolStripMenuItem";
sortToolStripMenuItem.Size = new System.Drawing.Size(180, 22); sortToolStripMenuItem.Size = new System.Drawing.Size(132, 22);
sortToolStripMenuItem.Text = "&Sort"; sortToolStripMenuItem.Text = "&Sort";
sortToolStripMenuItem.Click += sortToolStripMenuItem_Click; sortToolStripMenuItem.Click += sortToolStripMenuItem_Click;
// //
// folderContextMenu // folderContextMenu
// //
folderContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addPageToolStripMenuItem1, toolStripMenuItem10, addFolderToolStripMenuItem1, toolStripMenuItem4, openAllToolStripMenuItem, editToolStripMenuItem1, deleteToolStripMenuItem, toolStripMenuItem5, sortToolStripMenuItem1, toolStripMenuItem6, moveUpToolStripMenuItem, moveDownToolStripMenuItem }); folderContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { addPageToolStripMenuItem1, addFolderToolStripMenuItem1, toolStripMenuItem4, openAllToolStripMenuItem, editToolStripMenuItem1, deleteToolStripMenuItem, toolStripMenuItem5, sortToolStripMenuItem1, toolStripMenuItem6, moveUpToolStripMenuItem, moveDownToolStripMenuItem });
folderContextMenu.Name = "folderContextMenu"; folderContextMenu.Name = "folderContextMenu";
folderContextMenu.Size = new System.Drawing.Size(167, 220); folderContextMenu.Size = new System.Drawing.Size(139, 198);
// //
// addPageToolStripMenuItem1 // addPageToolStripMenuItem1
// //
addPageToolStripMenuItem1.Name = "addPageToolStripMenuItem1"; addPageToolStripMenuItem1.Name = "addPageToolStripMenuItem1";
addPageToolStripMenuItem1.Size = new System.Drawing.Size(166, 22); addPageToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
addPageToolStripMenuItem1.Text = "Add &Page"; addPageToolStripMenuItem1.Text = "Add &Page";
addPageToolStripMenuItem1.Click += addPageToolStripMenuItem1_Click; addPageToolStripMenuItem1.Click += addPageToolStripMenuItem1_Click;
// //
// toolStripMenuItem10
//
toolStripMenuItem10.Name = "toolStripMenuItem10";
toolStripMenuItem10.Size = new System.Drawing.Size(166, 22);
toolStripMenuItem10.Text = "Add Page (&Batch)";
toolStripMenuItem10.Click += toolStripMenuItem10_Click;
//
// addFolderToolStripMenuItem1 // addFolderToolStripMenuItem1
// //
addFolderToolStripMenuItem1.Name = "addFolderToolStripMenuItem1"; addFolderToolStripMenuItem1.Name = "addFolderToolStripMenuItem1";
addFolderToolStripMenuItem1.Size = new System.Drawing.Size(166, 22); addFolderToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
addFolderToolStripMenuItem1.Text = "Add &Folder"; addFolderToolStripMenuItem1.Text = "Add &Folder";
addFolderToolStripMenuItem1.Click += addFolderToolStripMenuItem1_Click; addFolderToolStripMenuItem1.Click += addFolderToolStripMenuItem1_Click;
// //
// toolStripMenuItem4 // toolStripMenuItem4
// //
toolStripMenuItem4.Name = "toolStripMenuItem4"; toolStripMenuItem4.Name = "toolStripMenuItem4";
toolStripMenuItem4.Size = new System.Drawing.Size(163, 6); toolStripMenuItem4.Size = new System.Drawing.Size(135, 6);
// //
// openAllToolStripMenuItem // openAllToolStripMenuItem
// //
openAllToolStripMenuItem.Image = BookmarkManager.AppResource.bookmark; openAllToolStripMenuItem.Image = BookmarkManager.AppResource.bookmark;
openAllToolStripMenuItem.Name = "openAllToolStripMenuItem"; openAllToolStripMenuItem.Name = "openAllToolStripMenuItem";
openAllToolStripMenuItem.Size = new System.Drawing.Size(166, 22); openAllToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
openAllToolStripMenuItem.Text = "&Open All"; openAllToolStripMenuItem.Text = "&Open All";
openAllToolStripMenuItem.Click += openAllToolStripMenuItem_Click; openAllToolStripMenuItem.Click += openAllToolStripMenuItem_Click;
// //
// editToolStripMenuItem1 // editToolStripMenuItem1
// //
editToolStripMenuItem1.Name = "editToolStripMenuItem1"; editToolStripMenuItem1.Name = "editToolStripMenuItem1";
editToolStripMenuItem1.Size = new System.Drawing.Size(166, 22); editToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
editToolStripMenuItem1.Text = "&Edit"; editToolStripMenuItem1.Text = "&Edit";
editToolStripMenuItem1.Click += editToolStripMenuItem1_Click; editToolStripMenuItem1.Click += editToolStripMenuItem1_Click;
// //
@ -389,32 +380,32 @@ namespace FizzyLauncher
// //
deleteToolStripMenuItem.Image = BookmarkManager.AppResource.trash; deleteToolStripMenuItem.Image = BookmarkManager.AppResource.trash;
deleteToolStripMenuItem.Name = "deleteToolStripMenuItem"; deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
deleteToolStripMenuItem.Size = new System.Drawing.Size(166, 22); deleteToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
deleteToolStripMenuItem.Text = "&Delete"; deleteToolStripMenuItem.Text = "&Delete";
deleteToolStripMenuItem.Click += deleteToolStripMenuItem_Click; deleteToolStripMenuItem.Click += deleteToolStripMenuItem_Click;
// //
// toolStripMenuItem5 // toolStripMenuItem5
// //
toolStripMenuItem5.Name = "toolStripMenuItem5"; toolStripMenuItem5.Name = "toolStripMenuItem5";
toolStripMenuItem5.Size = new System.Drawing.Size(163, 6); toolStripMenuItem5.Size = new System.Drawing.Size(135, 6);
// //
// sortToolStripMenuItem1 // sortToolStripMenuItem1
// //
sortToolStripMenuItem1.Name = "sortToolStripMenuItem1"; sortToolStripMenuItem1.Name = "sortToolStripMenuItem1";
sortToolStripMenuItem1.Size = new System.Drawing.Size(166, 22); sortToolStripMenuItem1.Size = new System.Drawing.Size(138, 22);
sortToolStripMenuItem1.Text = "&Sort"; sortToolStripMenuItem1.Text = "&Sort";
sortToolStripMenuItem1.Click += sortToolStripMenuItem1_Click; sortToolStripMenuItem1.Click += sortToolStripMenuItem1_Click;
// //
// toolStripMenuItem6 // toolStripMenuItem6
// //
toolStripMenuItem6.Name = "toolStripMenuItem6"; toolStripMenuItem6.Name = "toolStripMenuItem6";
toolStripMenuItem6.Size = new System.Drawing.Size(163, 6); toolStripMenuItem6.Size = new System.Drawing.Size(135, 6);
// //
// moveUpToolStripMenuItem // moveUpToolStripMenuItem
// //
moveUpToolStripMenuItem.Image = BookmarkManager.AppResource.arrow_up_circle; moveUpToolStripMenuItem.Image = BookmarkManager.AppResource.arrow_up_circle;
moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem"; moveUpToolStripMenuItem.Name = "moveUpToolStripMenuItem";
moveUpToolStripMenuItem.Size = new System.Drawing.Size(166, 22); moveUpToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
moveUpToolStripMenuItem.Text = "Move &Up"; moveUpToolStripMenuItem.Text = "Move &Up";
moveUpToolStripMenuItem.Click += moveUpToolStripMenuItem_Click; moveUpToolStripMenuItem.Click += moveUpToolStripMenuItem_Click;
// //
@ -422,7 +413,7 @@ namespace FizzyLauncher
// //
moveDownToolStripMenuItem.Image = BookmarkManager.AppResource.arrow_down_circle; moveDownToolStripMenuItem.Image = BookmarkManager.AppResource.arrow_down_circle;
moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem"; moveDownToolStripMenuItem.Name = "moveDownToolStripMenuItem";
moveDownToolStripMenuItem.Size = new System.Drawing.Size(166, 22); moveDownToolStripMenuItem.Size = new System.Drawing.Size(138, 22);
moveDownToolStripMenuItem.Text = "Move &Down"; moveDownToolStripMenuItem.Text = "Move &Down";
moveDownToolStripMenuItem.Click += moveDownToolStripMenuItem_Click; moveDownToolStripMenuItem.Click += moveDownToolStripMenuItem_Click;
// //
@ -491,13 +482,6 @@ namespace FizzyLauncher
treeView1.Size = new System.Drawing.Size(300, 556); treeView1.Size = new System.Drawing.Size(300, 556);
treeView1.TabIndex = 5; treeView1.TabIndex = 5;
// //
// toolStripMenuItem11
//
toolStripMenuItem11.Name = "toolStripMenuItem11";
toolStripMenuItem11.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem11.Text = "Add Page (&Batch)";
toolStripMenuItem11.Click += toolStripMenuItem11_Click;
//
// MainForm // MainForm
// //
AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
@ -579,8 +563,6 @@ namespace FizzyLauncher
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem9; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem9;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private RyzStudio.Windows.Forms.BookmarkTreeView treeView1; private RyzStudio.Windows.Forms.BookmarkTreeView treeView1;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem10;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem11;
} }
} }

View File

@ -394,36 +394,6 @@ namespace FizzyLauncher
} }
} }
/// <summary>
/// Add page (batch)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem11_Click(object sender, EventArgs e)
{
if (this.IsBusy)
{
return;
}
var nodeType = treeView1.GetNodeType();
if ((nodeType != NodeType.Root) && (nodeType != NodeType.Folder))
{
return;
}
var nodePath = treeView1.GetNodePath();
var form = new AddBatchPageForm(nodePath);
if (form.ShowDialog() == DialogResult.OK)
{
foreach (var item in form.Result)
{
treeView1.AddNode(item);
}
}
}
/// <summary> /// <summary>
/// Add folder /// Add folder
/// </summary> /// </summary>
@ -487,16 +457,6 @@ namespace FizzyLauncher
addPageToolStripMenuItem_Click(sender, e); addPageToolStripMenuItem_Click(sender, e);
} }
/// <summary>
/// Add page (batch)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void toolStripMenuItem10_Click(object sender, EventArgs e)
{
toolStripMenuItem11_Click(this, e);
}
/// <summary> /// <summary>
/// Add folder /// Add folder
/// </summary> /// </summary>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
@ -48,7 +48,7 @@
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter

View File

@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using HtmlAgilityPack; using HtmlAgilityPack;
@ -150,7 +148,7 @@ namespace BookmarkManager.Services
return result; return result;
} }
public async Task<Image> RetrieveImage(string url, HtmlAgilityPack.HtmlDocument document) public async Task<Image> RetrieveImage(HtmlAgilityPack.HtmlDocument document)
{ {
var iconUrl = this.ParseFavicon(document); var iconUrl = this.ParseFavicon(document);
if (string.IsNullOrWhiteSpace(iconUrl)) if (string.IsNullOrWhiteSpace(iconUrl))
@ -158,18 +156,6 @@ namespace BookmarkManager.Services
return null; return null;
} }
try
{
var baseUri = new Uri(url);
var absoluteUri = new Uri(baseUri, iconUrl);
iconUrl = absoluteUri.AbsoluteUri;
}
catch
{
return null;
}
return await this.RetrieveImage(iconUrl); return await this.RetrieveImage(iconUrl);
} }
@ -177,102 +163,132 @@ namespace BookmarkManager.Services
{ {
string result = null; string result = null;
// Find basic title result = ParseTagValue(document, "//title", string.Empty)?.Trim();
result = FindNodeValue(document, "//title", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result)) if (!string.IsNullOrWhiteSpace(result))
{ {
return result; return result;
} }
// Find title from extended meta result = ParseTagValue_Attr(document, "//meta[@property='og:title']", "content", string.Empty)?.Trim();
var patternList = new List<string>() if (!string.IsNullOrWhiteSpace(result))
{ {
"//meta[@property='og:title']", return result;
"//meta[@property='og:site_name']", }
"//meta[@name='twitter:title']",
"//meta[@itemprop='name']"
};
foreach (var item in patternList) result = ParseTagValue_Attr(document, "//meta[@name='twitter:title']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{ {
result = FindNodeAttrValue(document, item, "content", string.Empty)?.Trim(); return result;
if (string.IsNullOrWhiteSpace(result)) }
{
continue;
}
result = ParseTagValue_Attr(document, "//meta[@property='og:site_name']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[@itemprop='name']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result; return result;
} }
return string.Empty; return string.Empty;
} }
public string ParseDescription(HtmlAgilityPack.HtmlDocument document) public string ParseMetaDescription(HtmlAgilityPack.HtmlDocument document)
{ {
var patternList = new List<string>() string result = null;
{
"//meta[@name='description']",
"//meta[@property='og:description']",
"//meta[@name='twitter:description']",
"//meta[@itemprop='description']",
};
foreach (var item in patternList) result = ParseTagValue_Attr(document, "//meta[@name='description']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{ {
var result = FindNodeAttrValue(document, item, "content", string.Empty)?.Trim();
if (string.IsNullOrWhiteSpace(result))
{
continue;
}
return result; return result;
} }
return string.Empty; result = ParseTagValue_Attr(document, "//meta[@property='og:description']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[@name='twitter:description']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[@property='og:description']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[@itemprop='description']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
return result;
} }
public string ParseFavicon(HtmlAgilityPack.HtmlDocument document) public string ParseFavicon(HtmlAgilityPack.HtmlDocument document)
{ {
string result = null; string result = null;
// Find link-rel that contains word result = ParseTagValue_Attr(document, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'shortcut icon']", "href", string.Empty)?.Trim();
result = FindNodeAttrValue_ContainsWord(document, "link", "rel", "href", "icon");
if (!string.IsNullOrWhiteSpace(result)) if (!string.IsNullOrWhiteSpace(result))
{ {
return result; return result;
} }
// Find link-rel contains apple-icon result = ParseTagValue_Attr(document, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'icon']", "href", string.Empty)?.Trim();
var matchPatterns = new List<string>() { "apple-touch-icon", "apple-touch-icon-precomposed" };
result = FindNodeAttrValue_Equals(document, "link", "rel", "href", matchPatterns);
if (!string.IsNullOrWhiteSpace(result)) if (!string.IsNullOrWhiteSpace(result))
{ {
return result; return result;
} }
// Find favicon from extended meta result = ParseTagValue_Attr(document, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'apple-touch-icon']", "href", string.Empty)?.Trim();
var patternList = new List<string>() if (!string.IsNullOrWhiteSpace(result))
{ {
"//meta[@property='og:image']",
"//meta[@name='twitter:image']",
"//meta[@itemprop='image']"
};
foreach (var item in patternList)
{
result = FindNodeAttrValue(document, item, "content", string.Empty)?.Trim();
if (string.IsNullOrWhiteSpace(result))
{
continue;
}
return result; return result;
} }
return string.Empty; result = ParseTagValue_Attr(document, "//link[translate(@rel, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'apple-touch-icon-precomposed']", "href", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[translate(@property, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'og:image']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[translate(@name, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'twitter:image']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[translate(@property, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'og:image']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
result = ParseTagValue_Attr(document, "//meta[translate(@itemprop, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'image']", "content", string.Empty)?.Trim();
if (!string.IsNullOrWhiteSpace(result))
{
return result;
}
return "/favicon.ico";
} }
private string FindNodeValue(HtmlAgilityPack.HtmlDocument document, string xPath, string defaultValue = "") private string ParseTagValue(HtmlAgilityPack.HtmlDocument document, string xPath, string defaultValue = "")
{ {
var hnc = document.DocumentNode.SelectNodes(xPath); var hnc = document.DocumentNode.SelectNodes(xPath);
if (hnc == null) if (hnc == null)
@ -304,7 +320,7 @@ namespace BookmarkManager.Services
return defaultValue; return defaultValue;
} }
private string FindNodeAttrValue(HtmlAgilityPack.HtmlDocument document, string xPath, string attr, string defaultValue = "") private string ParseTagValue_Attr(HtmlAgilityPack.HtmlDocument document, string xPath, string attr, string defaultValue = "")
{ {
var hnc = document.DocumentNode.SelectNodes(xPath); var hnc = document.DocumentNode.SelectNodes(xPath);
if (hnc == null) if (hnc == null)
@ -335,93 +351,5 @@ namespace BookmarkManager.Services
return defaultValue; return defaultValue;
} }
private List<HtmlNode> FindNode(HtmlAgilityPack.HtmlDocument document, string nodeName, string attrName)
{
var xPath = (string.IsNullOrWhiteSpace(attrName) ? $"//{nodeName}" : $"//{nodeName}[@{attrName}]");
var hnc = document.DocumentNode.SelectNodes(xPath);
if (hnc == null)
{
return new List<HtmlNode>();
}
if (hnc.Count <= 0)
{
return new List<HtmlNode>();
}
return hnc.ToList();
}
private string FindNodeAttrValue_ContainsWord(HtmlAgilityPack.HtmlDocument document, string nodeName, string attrName, string returnAttrName, string matchEqualList, string defaultValue = "")
{
var linkNodes = FindNode(document, nodeName, attrName);
foreach (var item in linkNodes)
{
var relValue = item.Attributes[attrName].Value?.Trim() ?? string.Empty;
if (!ContainsWord(relValue, matchEqualList))
{
continue;
}
var hrefValue = item.Attributes[returnAttrName].Value?.Trim() ?? string.Empty;
if (string.IsNullOrWhiteSpace(hrefValue))
{
continue;
}
return System.Web.HttpUtility.HtmlDecode(hrefValue);
}
return defaultValue;
}
private string FindNodeAttrValue_Equals(HtmlAgilityPack.HtmlDocument document, string nodeName, string attrName, string returnAttrName, List<string> matchValueList, string defaultValue = "")
{
var linkNodes = FindNode(document, nodeName, attrName);
foreach (var item in linkNodes)
{
var relValue = item.Attributes[attrName].Value?.Trim() ?? string.Empty;
if (!matchValueList.Contains(relValue?.ToLower() ?? string.Empty))
{
continue;
}
var hrefValue = item.Attributes[returnAttrName].Value?.Trim() ?? string.Empty;
if (string.IsNullOrWhiteSpace(hrefValue))
{
continue;
}
return System.Web.HttpUtility.HtmlDecode(hrefValue);
}
return defaultValue;
}
private bool ContainsWord(string haystack, string needle)
{
haystack = haystack?.Trim() ?? string.Empty;
if (!haystack.Contains(" "))
{
return haystack.Equals(needle, StringComparison.CurrentCultureIgnoreCase);
}
foreach (var item in haystack.Split(" "))
{
if (string.IsNullOrWhiteSpace(item))
{
continue;
}
if (item.Equals(needle, StringComparison.CurrentCultureIgnoreCase))
{
return true;
}
}
return false;
}
} }
} }

View File

@ -360,7 +360,7 @@ namespace FizzyLauncher
try try
{ {
var image = await _webProvider.RetrieveImage(item.Value.Address, document); var image = await _webProvider.RetrieveImage(document);
if (image != null) if (image != null)
{ {
if (image.Width > 16) if (image.Width > 16)

View File

@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "BukkuBuddy Bookmark Manager" #define MyAppName "BukkuBuddy Bookmark Manager"
#define MyAppVersion "0.6.2.092" #define MyAppVersion "0.6.0.716"
#define MyAppPublisher "Hi, I'm Ray" #define MyAppPublisher "Hi, I'm Ray"
#define MyAppURL "https://www.hiimray.co.uk/software-bookmark-manager" #define MyAppURL "https://www.hiimray.co.uk/software-bookmark-manager"
#define MyAppExeName "bukkubuddy.exe" #define MyAppExeName "bukkubuddy.exe"