Skip to main content

A script to share your obsidian vault (in partial way)

Project description

⚠️ The script and site are not a replacement for Obsidian Publish, which is a much more efficient way to share Obsidian files.

Table Of Content


Get Started

  • You first need to create a template using YAFPA-blog
  • After, do pip install YAFPA

Requirements

The script uses :

You can install all with pip install -r requirements.txt

Environment

The first time you use the script, it will ask you three things :

  • Your vault path (absolute path !)
  • The path of the blog (absolute too !)
  • The link of your blog, as https://my-awesome-blog.netlify.app/

You can reconfig the path with yafpa --config

The file will be created in $HOME/.YAFPA-env (~/.YAFPA-env) so you can edit it directly.

Script

usage: yafpa [-h] [--preserve | --update] [--filepath FILEPATH] [--git] [--keep] [--config]

Create file in folder, move image in assets, convert to relative path, add share support, and push to git

optional arguments:

  • -h, --help: show this help message and exit
  • --preserve, --p, --P : Don't delete file if already exist
  • --update, --u, --U : force update : delete all file and reform.
  • --filepath FILEPATH, --f FILEPATH, --F FILEPATH : Filepath of the file you want to convert
  • --git, --g, --G : No commit and no push to git
  • --keep, --k : Keep deleted file from vault and removed shared file
  • --config, --c : Edit the config file

Checking differences

The script will convert all file with share:true and check if the contents are differents with the version in _notes. The only things that are ignored is the contents of the metadata. If you want absolutely change the metadata you can:

  • Use yafpa --file <filepath> directly
  • Use --u to force update all file
  • Continue to work on the file before pushing it.
  • Add a newline
  • Manually delete the file
  • Add or edit the metadata keys (unless date/title/created/update/link).

:warning: In case you have two files with the same name but :

  • In different folder
  • With different sharing statut The script will bug because I don't check folder (It's volontary). In this unique case, you need to rename one of the files.

Options

Share all

yafpa and all yafpa option without --F FILEPATH will automatically read all file in your vault to check the share: true key in metadata (frontmatter YAML).

By default, the script will check the difference between line (cf checking difference), and convert only the file with difference. You can use --u to force update.

Share only a file

The command will be : yafpa --F filepath

The file to be shared does not need to contain share: true in its YAML, and will be updated no matter what.

How it works

The script :

  • Moves file (with share: true frontmatter or specific file) in the _notes folder
  • Moves image in assets/img and convert (with alt support)
  • Converts highlight (==mark== to [[mark::highlight]])
  • Converts "normal" writing to GFM markdown (adding \n each \n)
  • Supports non existant file (adding a css for that 😉)
  • Supports image flags css (Lithou snippet 🙏)
  • Support normal and external files (convert "normal markdown link" to "wikilinks")
  • Edit link to support transluction (if not embed: False)
  • Remove block id (no support)
  • Add CSS settings for inline tags (no link support) ; Tags are : class = .hash ; id = #tag_name (so you can style each tags you use)
  • Frontmatter : Update the date. If there is already a date key, save it to created and update date.
  • Frontmatter : In absence of title, add the file's title.
  • Copy the link to your clipboard if one file is edited.
  • ⭐ Admonition convertion to "callout inspired notion"
  • Update the frontmatter in the original file, adding the link and change share to true if one file is shared.

Finally, the plugin will add, commit and push if supported.

Note : The clipboard may not work in your configuration. I have (and can) only test the script on IOS and Windows, so I use pyperclip and pasteboard to do that. If you are on MacOS, Linux, Android, please, check your configuration on your python and open an issue if it doesn't work. Note : I can't testing on these 3 OS, so I can't create a clipboard option on my own.

Custom CSS

You can add CSS using the file (custom.css)[https://github.com/Mara-Li/yet-another-free-publish-alternative/blob/master/assets/css/custom.css]. The plugin Markdown Attribute allow to use the creation of inline css. Some information about this :

  • You need to add : after the first {
  • The inline IAL work only if there is stylized markdown. In absence, the text will be bolded.
  • It won't work with highlight (removed automatically by the script)

⚠️ As I use CodeMirror Options and Contextual Typography, I warn you : the use of #tags to stylize the text before it doesn't work with my build. So, as an option to don't have a random tag in a text, you can use custom.css to remove it with display: none (you can have an example with #left).

Frontmatter settings

  • share: true : Share the file
  • embed: false : remove the transluction (convert to normal wikilinks)
  • update: false : Don't update the file at all after the first push
  • current: false : Don't update the date
  • private: true : Use the _private folder collection instead of the _notes collection.

Admonition

As admonition is very tricky, I choose to convert all admonition to a "callout Notion". The script will :

  • Remove codeblock for admonition codeblocks
  • Convert ```ad-``` to !!!ad-
  • Bold title and add a IAL {: .title}

JavaScript will niced all things.

⚠️ As always with markdown, you will see some problem with new paragraph inside admonition. You can use $~$ to fake line. The script will automatically add this. Also, you can add emoji on title to add some nice formatting.

⚠️ Depeciated, need to be updated

Depreciated ! Please don't use it. ### IOS Shortcuts ### IOS To use the shortcuts, you need : - [Pyto](https://apps.apple.com/fr/app/pyto-python-3/id1436650069) - [Toolbox Pro](https://apps.apple.com/fr/app/toolbox-pro-for-shortcuts/id1476205977) - [Working Copy](https://workingcopyapp.com/)

The main shortcut is on RoutineHub (more pratical for version update) : share one file (it's equivalent to yafpa --f <filepath>)

There is another shortcuts to "share all" files : Share all true file in vault (it's equivalent to yafpa without arguments)

Note : You first need to clone the repo with Working Copy and install all requirements.

To use the shortcuts, you need :

Before running the shortcuts, you need to install all requirements, aka :

jump <vault>
cd script
pip install -r requirements.txt

For the moment I can't create a shortcuts to share only one file BUT ! You can using a-shell as you do in a normal terminal, aka :

jump <vault>
python3 <vault-path>/script/sharing.py <file>

You could also create an alias for sharing using ~/.profile: alias share='python3 <git-folder>/script/sharing.py'

Obsidian

→ Please use Wikilinks with "short links" (I BEG YOU) You can integrate the script within obsidian using the nice plugin Obsidian ShellCommands.

You could create two commands :

  1. share all : yafpa
  2. share one : yafpa --f {{file_path:absolute}}

You can use :

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

YAFPA-1.47.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

YAFPA-1.47-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file YAFPA-1.47.tar.gz.

File metadata

  • Download URL: YAFPA-1.47.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for YAFPA-1.47.tar.gz
Algorithm Hash digest
SHA256 d22d7bfea3e4dc92fe703546889104f0e54ace3554da4d5c2eb5cd964b41136f
MD5 c37d4a462b18e65ac126b57e6618a489
BLAKE2b-256 9dc2aee8e4b14823f9c524a813304d434d0bb0b8ce3df0a1177686ad06e9a6a5

See more details on using hashes here.

File details

Details for the file YAFPA-1.47-py3-none-any.whl.

File metadata

  • Download URL: YAFPA-1.47-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for YAFPA-1.47-py3-none-any.whl
Algorithm Hash digest
SHA256 810e86afda0e2b7a54436fef8b3e7c9245e5e6c9921df14250d0a542f5d12eba
MD5 ef96f725122aef9b041cc810dc425774
BLAKE2b-256 a1aea1136c9f0f6271ef2ebbdbac411e02744ad2a4fab393448b514cb4501370

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page