Skip to content

Commit

Permalink
Readme and build scripts updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Mozgovoy committed Mar 1, 2020
1 parent 997e6f8 commit 89c0ae5
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 13 deletions.
1 change: 1 addition & 0 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ packages/**
WebLibraryDownloader/WebLibraryDownloader.csproj.user
WebLibraryDownloader/obj/**
WebLibraryDownloader/bin/**
WebLibrary-x64.zip
5 changes: 5 additions & 0 deletions BuildAndPack.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ rmdir /q /s Release
del WebLibrary-x64.zip
md Release
md Release\locales
md Release\WebLibraryExt
md Release\WebLibraryExt\icons

copy WebLibraryApp\bin\x64\Release\locales\en-US.pak Release\locales\
copy WebLibraryApp\bin\x64\Release\cef.pak Release\
Expand Down Expand Up @@ -37,6 +39,9 @@ copy WebLibraryDownloader\SingleFile-master.zip Release\
copy WebLibraryDownloader\bin\Release\WebLibraryDownloader.exe Release\
copy WebLibraryDownloader\bin\Release\WebLibraryDownloader.exe.config Release\

copy WebLibraryExt\*.* Release\WebLibraryExt\
copy WebLibraryExt\icons\*.* Release\WebLibraryExt\icons\

copy SetupWebLibrary.bat Release\

powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::CreateFromDirectory('Release', 'WebLibrary-x64.zip'); }"
Expand Down
27 changes: 25 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,35 @@ These are the things you can do:
WebLibrary supports keyboard shortcuts, so many basic operations can be perfomed quickly and without annoying mouse clicks. The content of the library is updated automatically, so when files appear or get deleted in the library folder, the main applicaton screen is updated accordingly.

## Content saving and synchronization
WebLibrary does not yet provide its own capabilities for saving web pages. For now, I recommend using a great browser extension [SingleFile](https://github.com/gildas-lormeau/SingleFile). To access your documents from different devices, simply place your library into a cloud-synchronized folder.
To facilitate content saving, WebLibrary provides two additional tools: a Chrome-compatible browser extension for saving web pages, and a GUI app for choosing the current save location. To access your documents from different devices, simply place your library into a cloud-synchronized folder.

## Alternatives
There are other, much more function-rich systems like [TagSpaces](https://www.tagspaces.org/) or [myBase](http://www.wjjsoft.com/mybase.html). I tried using them several times on daily basis, but always had to face with problems like poor page rendering, lack of hotkeys or synchronization issues. However, your experience might be very different.

## Setup
WebLibrary is being developed in very scarce periods of free time and thus heavily relies on third-party components. Unfortunately, it means that its setup is a relatively complicated process at the moment. Note also that only a 64-bit Windows build is currently available.

### Prerequisites
1. [Node.js](https://nodejs.org/en/) runtime.
1. Any Chrome-compatible web browser.
1. [External Application Button](https://chrome.google.com/webstore/detail/external-application-butt/bifmfjgpgndemajpeeoiopbeilbaifdo) Chrome extension. Make sure to click the extension button once and install the "native client" component as instructed.

### Installing WebLibrary and WebLibraryDownloader
1. Depack `WebLibrary-x64.zip` into any folder of your choice.
1. Add this folder into your `PATH` environment variable.
1. Run `SetupWebLibrary.bat` script to install additional dependencies.
1. Run `WebLibraryApp.exe` and choose the location of your library folder. As noted above, it is a good idea to keep it in a cloud-synchronized place.
1. Run `WebLibraryDownloader.exe` and choose the library folder once again. Also provide a path to your Chrome-compatible browser.

### Installing the Chrome Extension
1. Open `chrome://extensions` location in your browser.
1. Enable "Developer mode" in the top-right corner.
1. Press "Load unpacked" button and choose `WebLibraryExt` folder inside your installation path. Extension button should appear in the browser toolbar.

## Tech details
WebLibrary is written in C# and uses [CefSharp](https://github.com/cefsharp/CefSharp/) library to display HTML documents. Metainformation, such as "Favorite" and "Read" flags is encoded in file names (a file `doc.html` becomes `doc{R,S}.html` when it is marked as both read and favorite/starred).

The project can be built with MS Visual Studio 2017. Open `Developer Command Prompt for VS 2017`, navigate to the project folder and run `BuildAndPack.bat`.
The project can be built with MS Visual Studio 2017. Open `Developer Command Prompt for VS 2017`, navigate to the project folder and run `BuildAndPack.bat`. Make sure to have NuGet installed, since it is used to restore missing `CefSharp` packages.

Web pages are saved with the help of a third-party tool [SingleFile](https://github.com/gildas-lormeau/SingleFile). WebLibrary Chrome extension uses [External Application Button](https://add0n.com/external-application-button.html) to call `WebLibraryDownloader.exe` and pass it the URL of the current page to be saved.

8 changes: 6 additions & 2 deletions WebLibraryApp/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ public MainForm()
mArticles = new ArticleList(settings.SortByColumn, settings.ReverseSort, lvArticles, fsWatcher);
mArticles.InitializeColWidths(colWidths);

if (!Directory.Exists(settings.LibHome)) // $mm TODO: exit if no folder is chosen
while (!Directory.Exists(settings.LibHome))
{
MessageBox.Show("Please select a valid library folder", "WebLibraryDownloader", MessageBoxButtons.OK, MessageBoxIcon.Information);
ChooseLibFolder();

}

updateLibTree();
fsWatcher.Path = settings.LibHome;
}
Expand Down Expand Up @@ -105,6 +108,7 @@ private void ChooseLibFolder()
{
using (var fbd = new FolderBrowserDialog())
{
fbd.Description = "Choose Library Folder";
if (fbd.ShowDialog() == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
Properties.Settings.Default.LibHome = fbd.SelectedPath;
}
Expand Down
2 changes: 2 additions & 0 deletions WebLibraryDownloader/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 23 additions & 9 deletions WebLibraryDownloader/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@ public MainForm()
Top = settings.MainForm_Top;
Width = settings.MainForm_Width;
Height = settings.MainForm_Height;

cbAutoSave.CheckedChanged -= cbAutoSave_CheckedChanged;
cbAutoSave.Checked = settings.AutoSave;
// $mm TODO: save current dir
cbAutoSave.CheckedChanged += cbAutoSave_CheckedChanged;

if (!Directory.Exists(settings.LibHome)) // $mm TODO: exit if no folder is chosen
while (!Directory.Exists(settings.LibHome))
{
MessageBox.Show("Please select a valid library folder", "WebLibraryDownloader", MessageBoxButtons.OK, MessageBoxIcon.Information);
ChooseLibFolder();
}

if (!File.Exists(settings.ChromePath))
while (!File.Exists(settings.ChromePath))
{
MessageBox.Show("Please select a valid path to a Chrome-compatible browser", "WebLibraryDownloader", MessageBoxButtons.OK, MessageBoxIcon.Information);
ChooseChromePath();
}

updateLibTree();
}
Expand All @@ -41,6 +49,7 @@ public void SetUrl(string url)
tbUrl.ReadOnly = false;
tbUrl.Text = url;
tbUrl.ReadOnly = true;
btnSave.Enabled = true;
}

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
Expand All @@ -61,11 +70,11 @@ private void btnChooseLibFolder_Click(object sender, EventArgs e)
ChooseLibFolder();
}


private void ChooseLibFolder()
{
using (var fbd = new FolderBrowserDialog())
{
fbd.Description = "Choose Library Folder";
if (fbd.ShowDialog() == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
Properties.Settings.Default.LibHome = fbd.SelectedPath;
}
Expand All @@ -75,7 +84,7 @@ private void ChooseChromePath()
{
using (var fbd = new OpenFileDialog())
{
if (fbd.ShowDialog() == DialogResult.OK)// $mm TODO: check options
if (fbd.ShowDialog() == DialogResult.OK)
Properties.Settings.Default.ChromePath = fbd.FileName;
}
}
Expand Down Expand Up @@ -149,10 +158,9 @@ private void saveUrl(string url, string folder)
exeProcess.WaitForExit();
}
}
catch(Exception e)
catch(Exception)
{
;
// Log error.
// $mm TODO Log error.
}

Close();
Expand All @@ -166,9 +174,15 @@ private void btnChooseChromePath_Click(object sender, EventArgs e)
private void MainForm_Load(object sender, EventArgs e)
{
this.BeginInvoke((MethodInvoker)delegate {
if (cbAutoSave.Checked && tvLibTree.SelectedNode != null)
if (cbAutoSave.Checked && tbUrl.Text.Length > 0 && tvLibTree.SelectedNode != null)
btnSave.PerformClick();
});
}

private void cbAutoSave_CheckedChanged(object sender, EventArgs e)
{
if(cbAutoSave.Checked)
MessageBox.Show("Note: to uncheck this box later, run WebLibraryDownloader without arguments", "WebLibraryDownloader", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

0 comments on commit 89c0ae5

Please sign in to comment.