GithubHelp home page GithubHelp logo

ark-builders / ark-shelf-desktop Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 6.0 1.7 MB

ARK Shelf is where you put your bookmarks during your web surfing. Desktop version.

License: MIT License

JavaScript 1.78% HTML 1.06% TypeScript 21.78% Rust 42.73% Svelte 32.52% CSS 0.14%

ark-shelf-desktop's People

Contributors

gwendalf avatar hhio618 avatar j4w3ny avatar kirillt avatar rizary avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ark-shelf-desktop's Issues

CLI subcommand for link creation

The app should gain CLI flag for running link creation dialog directly, skipping list of existing links:

ark-shelf --add-link

This way it would be possible to bind a hotkey easily for this operation which should be quite common.

Question: what to do if there is already running process of ARK Shelf? Ideally, we should re-use open window.

Extra: we could design the sub-command such a way it would convenient to use it without GUI at all.

Use local data when possible

The preview should use the local data if present. Same as the image. The application should work without online access. A fetch should be done on the LinkCard only if nessecary. (Use timeout for example and listen to the current internet status https://developer.mozilla.org/en-US/docs/Web/API/Navigator/onLine)
For example user create link with internet access. When offline the description and image preview should still be available

Switching order of links

Links should be able to be sorted ascending or descending.

A default need to be chosen. I propose to have a visual indication (color, arrow...) to know which sorting we are on. When clicking again on the sorting button, the mode (ascending/descending) and the visual indication should be updated

Long URLs cause crash

Because URLs are pasted into filename.

Example: adding https://2501babe.github.io/posts/solana101.html?accessToken=eyJhbGciOiJIUzI1NiIsImtpZCI6ImRlZmF1bHQiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJhY2Nlc3NfcmVzb3VyY2UiLCJleHAiOjE2NDQ0ODUzOTUsImciOiI4QXcyeDJNQTJrUVVYdnYwIiwiaWF0IjoxNjQ0NDg1MDk1LCJ1c2VySWQiOi0xNzQ4NDU1ODc5fQ.poTnBB48mQjZhiun-HoSCPNG5pXLBoup42GxUMuSiMI leads to

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 36, kind: InvalidFilename, message: "File name too long" }', core/src/base/link.rs:31:44
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

We should encode URL with some hash function or BASE 32. We can use UUID or timestamps as well but then we need to check duplicates.

Link won't save if scheme is missing

No error raised, simply ignores the entry.

Would suggest to allow entries without the scheme, default to http and handle the result.

An incorrect scheme will save but raises an error with metadata.

Links sorting

A user should be able to sort links by date or by score. Also shuffling would be nice.
The app needs 3-state button, which would cycle sorting modes and reflect current mode by special icon.

Links shuffling

Shuffling is operation of presenting links to user in random order. Lazy shuffling can be implemented using priority queue.

Default directory

In case when no path provided for the link storage, $HOME/.ark-shelf must be used.

UP: This must be a root folder, i.e. it would contain .ark subfolder with metadata.

Dedicated link creation dialog

We don't really need input fields when we are browsing through list of existing links, so better to hide them and invoke dedicated dialog by clicking a button. The dialog should also be interactive: just 1 input for URL and a button like "paste from buffer". When this input is filled, save button, as well as title and description fields must appear. New inputs must already contain filled-in text (similar to what is done by "autofill" button at the moment). "Autofill" button should be removed. The user can alter contents of title and description inputs before saving.

Connection refused

Attempt to save https://www.youtube.com/channel/UC8HFOUdnMnpoWmQMgeKoB3A link resulted in the error:

thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("yt3.ggpht.com")), port: None, path: "/CajG8KRONNS9zrU0sUb7W3JApVYtYux3dGsV0uSJ8tlbweeCXaNClzZu7KLcLiEa7J-9DV9K=s900-c-k-c0x00ffffff-no-rj", query: None, fragment: None }, source: hyper::Error(Connect, ConnectError("tcp connect error", Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })) }', core/src/base/link.rs:155:51
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2022-08-19_19-51-59.mp4

Basic Linux GUI

The app must consist of very basic GUI for the start:

  1. The app must receive path to a folder as CLI parameter.
  2. The only window must list all .link files contained in the specified folder.
  3. Each link in the list must:
    a. have [open] button, which opens the link in browser.
    b. have [copy] button, which copies URL of the link into copy/paste buffer.
    c. display title and short version of url, which are encoded in JSON of corresponding .link file.
  4. There must be a text input with several fields:
    a. [url] field.
    b. [title] field.
    c. [description] field.
  5. There must be a [add] button, which creates .link file and:
    a. stores it in the specified folder.
    b. displays fresh link in the list.

The app has to be written in Rust language, so it will be possible to use ArkLib later. GUI framework is up to developer's choice. Qt or Iced should be fine, but other libraries or frameworks can be used as well as soon as they solve the task. The app should be possible to use in macOS. Windows support is nice-to-have.

Tauri State being used for filepath constant

The outcome of parsing the CLI is sent to tauri and then called back from it in multiple places, even though it doesn't change.

Sent to tauri:

     builder
        .manage(cli)

Pulled back from tauri:

async fn read_link(name: String, state: tauri::State<'_, Cli>) -> Result<LinkWrapper, ()> {
    let file_path = format!("{}/{name}", &state.path);
    let link = Link::load(&state.path, &file_path).expect(&format!("Error loading {file_path}"));

Really these could just be the global statics rather than state. There's a lazy static macro in use but OnceLock is also in the standard library now, which could initialise the global.

Which instead would look like:

pub static ARK_SHELF_WORKING_DIR: OnceLock<PathBuf> = OnceLock::new();
pub static SCORES_PATH: OnceLock<PathBuf> = OnceLock::new();

fn main() {
    let cli = Cli::parse();
    let base_dir = match cli.path {
        Ok(path) => PathBuf::from(path),
        // This is using platform defaults but otherwise stick with home_dir() + ark-shelf
        None => ProjectDirs::from("dev", "Ark Builders",  "Shelf-Desktop")
                .map_or(PathBuf::from(""), |proj| PathBuf::from(proj.data_dir()))
    };

    // Initialise global constants
    ARK_SHELF_WORKING_DIR.set(base_dir.clone()).expect("Setting Working Dir");
    SCORES_PATH.set(base_dir.join("scores")).expect("Setting Scores Path");

}

Non-blocking title and description fetching

The app must load missing title or description in background. The link without title or description still should be added into the list, but spinning circles should be used to denote missing fields.

About storage, if the user provided:

  • no title and no description — we store .link file, but we don't store anything in user/properties
  • only description — besides .link file, we store JSON with single field description
  • only title — same, we create JSON with single title field
  • both — we create JSON with both

The cache/metadata storage should be used to store automatically fetched title and description, this is as fallback for user/properties (when 1 or 2 fields are missing). If a title or description is missing in both properties and cache, then we fetch them from the web. If there is no internet connectivity, then spinning circle can be replaced by dedicated "offline" icon.

JSON files with `null` fields

In any storage containing JSON values, missing title or description should result in an absent field in the JSON. Right now, null value is written. If all fields are missing, empty JSON must not be written.

  • JSON objects must not contain null fields
  • empty JSON objects must not be persisted

UI Enhancements

  1. Input fields should be cleared after a link added.
  2. Adding a link should not be signaled using window with a button.
    "Toast" notification which doesn't require user action would be nice.
  3. Description field should be optional.

Can't open fresh folders with `.link` files

By "fresh" I mean folders without .ark subfolder. This means there is any link lacks metadata and preview. Half-initialized folders must be openable, too. In other words, user should be able to copy-paste file externally into the folder and we should catch up with all missing data.

What we do in case a link lacks metadata:

  • If the link is not mentioned in user/properties, we query OGP and record all required fields into cache/metadata
  • If the link also lacks data in user/properties, then we query OGP for missing fields and put them into cache/metadata
  • If the link has all necessary fields in user/properties, then we don't query OGP

What we do in case a link lacks preview:

  • We just download it and put into cache/previews

Link scores

Special mode should be possible to invoke by checkbox or something like that.
In this mode, every link in the list should have 3 buttons:

  • + increases link's score
  • - decreases link's score
  • 0 resets link's score to zero

By default, any link has score zero. Score is useful for prioritizing links.
Related feature: #7

Links deletion

It must be possible to delete any link, both from the list and from the filesystem.

Session tags / Tags context

After #2 is implemented, would be cool to have "context" feature allowing to specify certain tags for current session. These tags would be automatically put on all links added during the session.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.