Code Monkey home page Code Monkey logo

akl's Introduction

AKL

Warning This is early stage software. Do not install unless you know what you are doing.

Overall Idea

The goal of this project is to simplify the navigation through a PDF library. A typical usage is:

  1. The user opens a PDF of interest
  2. The PDF contains links to other PDFs online, sometimes with precise destination information (also known as named destinations in the PDF lingo).
  3. The user wants to click on these links and the correct PDF file should open, using the following requirements
    1. The pdf should be opened using the default pdf viewer
    2. The pdf should not be downloaded twice, so that annotations are preserved
    3. The pdf should be opened at the correct position (if specified)

Implementation

The main idea is that akl acts as a proxy when opening a PDF file.

  1. The first time a pdf is opened, a duplicate is created with all the (external) links rewritten to use a custom url scheme handler
  2. Then, the default pdf viewer of the system is used to open this duplicated version.
  3. When external links are clicked on, the operating system forwards them to the akl program.
  4. If the links are already "connected" to a real pdf file on the system, the program opens it as in step (1). Otherwise, the program delegates the link to the default program (most of the time, the default web browser is used).

For all these steps to work correctly, one needs the following things

a. A way to build the new pdfs with rewritten links b. A way to tell the operating system that akl is handling a particular url scheme c. A way to import pdfs, a cache for the rewriten pdfs, and basically a pdf database.

Non goals are

  1. Automatically importing links. While it seems like a good idea, it should be the job of another program, typically a browser extension.
  2. Graphical interface. The objective is to have a very simple program that interfaces as smoothly as possible to widely different environments, hence leveraging as much as possible external programs.

How To Install The AKL-RS program

For now, you have to build the file from source, which means running the following command.

cargo build --release

Note that depending on your system, you may need to install the following:

  • cargo
  • pkg-config
  • libssl-dev
  • libdbus-1-dev

On Linux

Add the desktop file to your list of applications.

cp dist/akl-opener.desktop ~/.local/share/applications/akl-opener.desktop

Register the desktop file as able to open akl links.

echo "x-scheme-handler/akl=akl-opener.desktop;" >> ~/.local/share/applications/mimeapps.list

Add the akl binary to your path, for instance by running

cp target/release/akl-rs /usr/local/bin/akl

If for some reason on evince you do not have the right to launch applications, this can help: in /etc/apparmor.d/usr.bin.evince, add a line allowing to launch /usr/local/bin/akl via:

/usr/local/bin/akl ux,

Beware that this means you trust akl to run arbitrary programs. For the configuration to take effect, you must use

apparmor_parser -T -W -r /etc/apparmor.d/usr.bin.evince

On OSX

TODO

On Windows

Copy the binary akl-rs.exe into a safe location, for instance C:\Program Files (x86)\AKL\akl.exe.

Optionally, if you want to be able to access it directly from the command line, you can add this directory to your PATH:

  • WIN+R
  • Enter SystemPropertiesAdvanced.exe
  • Environment variables -> Path (current user or system) -> Edit -> New
  • Enter C:\Program Files (x86)\AKL\

Then, register the custom URI scheme by running dist/register_akl_machine.reg (registration for all users) or dist/register_akl_user.reg (registration for the current user only). If your binary is not in C:\Program Files (x86)\AKL\akl.exe, you have to edit the .reg file accordingly.

How To install the AKL Extension

For now, the web extension only works with Firefox and is not available in the app-store. To load the extension you can go to about:debugging, select "my firefox", and temporarily load the firefox-extension/manifest.json file.

akl's People

Contributors

aliaumel avatar e-sh4rk avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

akl's Issues

Better integration to document edition

For now, it is not convenient to use akl when editing a document because it is not in the database. Potential solutions for latex users include

  1. Create a akl package that rewrites links inside the pdf document.
  2. Create a custom latexmk configuration to override the generated pdf document.

Solution 2 typically looks like this

$pdf_mode = 1;
$pdf_update_method = 4;
$pdf_update_command = 'akl convert --uri %S --output %S';
$pdf_previewer = 'start evince';

While solution 1 should look like

\makeatletter
% save the old hyper@linkurl command
\let\oldlinkurl\hyper@linkurl
% override it by prepending AKL in front
\renewcommand{\hyper@linkurl}[2]{\oldlinkurl{#1}{akl://open-document/?uri=#2}}
\makeatother

This has numerous disadvantages:

  1. The generated urls will mostly be invalid because not urlencoded
  2. The page/destination parameters are not transferred to the akl link

Better latex and bibtex integration

For the program to reach full potential, it is needed that users create links with extra destination information in their pdfs. That is, instead of writing https://arxiv.org/abs/2207.07450v4, one would write https://arxiv.org/abs/2207.07450v4?page=15 or https://arxiv.org/abs/2207.07450v4?dest=theorem.2.9.

To automate this process, the pdfs imported currently allow to copy to the user's clipboard a direct link with the necessary information. However, it is quite unpleasant to write in usual latex code, and typically would integrate well with the knowledge package.

A prototype idea is to generate the following definitions in a separate file

\knowledge{url={GENERATED_URL_HERE}}
  | ressource name @ bibtex entry name

Together with a command that allows to properly cite parts of a document as follows:

\NewDocumentCommand{\kcite}{ m m }{
   \cite[\kl(#1){#2}]{#1}
}

Concretely, this allows to easily write references in documents, with several keywords referencing the same "named destination" in the document.

This theorem has been proven by \kcite{colcombet2023}{Theorem 1.7} ...

While automating such a behavior is far from simple, a reasonable roadmap would be the following

  1. Allow users to configure the format of the clipboard content using an environment variable.
  2. Add a polished version of the \kcite command to the knowledge package

If this is not enough, the following can be done

  1. Write a bibtex-reverse command taking as input the same arguments as resolve plus a path to a bibtex file. The output is the key of the document in the bibtex file.
  2. Create a vim script (for demo purposes) that allows users to search for a paper, and uses the clipboard selection together with bibtex-reverse to automatically update the knowledge file, and produce the correct command.

Install process

Issue with the config dir creation:

thread 'main' panicked at 'called Result::unwrap()on anErrvalue: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/main.rs:657:18

Issue with the clipboard dependencies:

thread 'main' panicked at 'called Result::unwrap()on anErrvalue: NoBinary', src/main.rs:818:40

Create an index of the documents

Right now a problem is to find documents that are present in the system. This is not particularly easy because of the filename limitations on various operating systems: we cannot place all metadata inside the filename.

A potential solution is to have a real index (xapian?) and search using this. However, an easy low-tech solution is to simply generate a pdf file that is a catalog of the available documents. It would then be fully searchable, and would also nicely interface with the rest of the programs.

Portable web extension

Factor the code to have two manifests, one for chromium based browsers, and the others for firefox like ones. I don't know how to handle safari yet (see safari).

Filename too large for OS

In the following paper https://arxiv.org/abs/2210.16580, the 10 authors create a filename that is too large for the operating system. In particular, the following uri command fails

akl://import-document/?payload=%7B%22uri%22%3A%22https%3A%2F%2Farxiv.org%2Fpdf%2F2210.16580%22%2C%22title%22%3A%22GPC%3A+A+Pattern+Calculus+for+Property+Graphs%22%2C%22authors%22%3A%5B%22Francis%2C+Nadime%22%2C%22Gheerbrant%2C+Am%C3%A9lie%22%2C%22Guagliardo%2C+Paolo%22%2C%22Libkin%2C+Leonid%22%2C%22Marsault%2C+Victor%22%2C%22Martens%2C+Wim%22%2C%22Murlak%2C+Filip%22%2C%22Peterfreund%2C+Liat%22%2C%22Rogova%2C+Alexandra%22%2C%22Vrgo%C4%8D%2C+Domagoj%22%5D%2C%22context%22%3A%5B%5D%2C%22identifiers%22%3A%5B%22https%3A%2F%2Farxiv.org%2Fabs%2F2210.16580%22%2C%22arxiv%3A2210.16580%22%2C%22https%3A%2F%2Farxiv.org%2Fpdf%2F2210.16580%22%5D%2C%22view%22%3Atrue%2C%22force%22%3Afalse%7D

Interactive mode when opening links

When --interactive is set, the program should see whether it has access to a terminal window (in which case it should launch $EDITOR) or not (in which case it should use the open::that command on the text file).

Add an online/offline switch

This switch could be used to

  1. prevent the download of pdf documents when switched off
  2. allow querying crossref when importing a document to autofill the informations

Remove automatic arxiv download

The code handling the arxiv links should be removed from the rust program and delegated to the web extensions / another program.

Handle new kinds of documents

The core of the program could be used to handle links outside of simple pdf files.

The easiest addition would be html pages. However, it is unclear how one should handle editable documents (odt, docx, md, etc.)

Zotero Importer

Build a script that does a migration from Zotero to the akl program.

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.