Skip to content

Commit

Permalink
Significant improvements to CLI, configuration workflow, docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alopezrivera committed Jul 24, 2021
1 parent 1ab53d3 commit 851649c
Show file tree
Hide file tree
Showing 20 changed files with 160 additions and 80 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,36 @@

## 3. Anchorage CLI

![alt text](docs/screencaps/title.png)

#### Browser choice
![alt text](docs/screencaps/br_choice.png | height=70)

#### Filter choice
![alt text](docs/screencaps/filter_choice.png | height=70)

##### Filter targets
![alt text](docs/screencaps/filter_targets.png | height=70)

##### String and substring filters
![alt text](docs/screencaps/filter_strings.png | height=70)

##### Regex filter
![alt text](docs/screencaps/filter_regex.png | height=70)

### Archive choice
![alt text](docs/screencaps/archive_choice.png | height=70)

#### Local: directory choice
![alt text](docs/screencaps/local_path.png)

#### Online: save current snapshots
![alt text](docs/screencaps/overwrite.png)

![alt text](docs/screencaps/exp_runtime.png)

####

## 4. Python library

### 4.1 Bookmark retrieval
Expand Down
4 changes: 4 additions & 0 deletions anchorage/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from anchorage.cli import main

if __name__ == "__main__":
main()
6 changes: 3 additions & 3 deletions anchorage/anchor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ def anchor_locally(collection,
log_anchorage(err)


def anchor_online(collection):
def anchor_online(collection, overwrite):
"""
Anchor all bookmarks in an online archive.
:param collection: Bookmark JSON file or __bookmark__ class instance.
"""

if isinstance(collection, bookmarks):
err = collection.loop(lambda k, v: add_online(url=v["url"]),
err = collection.loop(lambda k, v: add_online(url=v["url"], overwrite=overwrite),
pb_label="ARCHIVING",
suppress_output=True)
else:
err = bookmarks(collection).loop(lambda k, v: add_online(url=v["url"]),
err = bookmarks(collection).loop(lambda k, v: add_online(url=v["url"], overwrite=overwrite),
pb_label="ARCHIVING",
suppress_output=True)

Expand Down
58 changes: 32 additions & 26 deletions anchorage/anchor_infrs/config.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
import codecs

config = codecs.decode(r'# Welcome to the\n'
r'# /\ | | | (_)\n'
r'# / \ _ __ ___| |__ ___ _ __ __ _ __ _ ___ ___| |_|\n'
r'# / /\ \ | _ \ / __| _ \ / _ \| __/ _ |/ _ |/ _ \ / __| | |\n'
r'# / ____ \| | | | (__| | | | (_) | | | (_| | (_| | __/ | (__| | |\n'
r'# /_/ \_\_| |_|\___|_| |_|\___/|_| \__,_|\__, |\___| \___|_|_|\n'
r'# __/ | \n'
r'# |___/ \n'
r'# Configuration file\n'
config = codecs.decode(r'# Welcome to the \n'
r'# /\ | | | (_) \n'
r'# / \ _ __ ___| |__ ___ _ __ __ _ __ _ ___ ___| |_| \n'
r'# / /\ \ | _ \ / __| _ \ / _ \| __/ _ |/ _ |/ _ \ / __| | | \n'
r'# / ____ \| | | | (__| | | | (_) | | | (_| | (_| | __/ | (__| | | \n'
r'# /_/ \_\_| |_|\___|_| |_|\___/|_| \__,_|\__, |\___| \___|_|_| \n'
r'# __/ | \n'
r'# |___/ \n'
r'# Configuration file \n'
r'#\n'
r'# Below you can see the path to the Bookmarks JSON/JSONLZ4 file for a\n'
r'# Below you can see the path to the Bookmarks JSON/JSONLZ4 file for a \n'
r'# series of browsers.\n'
r'# \n'
r'# Set your default browser to one of the available to skip browser\n'
r'# choice when using the Anchorage CLI. \n'
r'# Set your default browser to one of the available to skip browser \n'
r'# choice when using the Anchorage CLI. \n'
r'# \n'
r'# You can add new browsers and the path to their bookmarks file. You \n'
r'# will then be able to set the new browser as the default, or choose\n'
r'# it in the Anchorage CLI.\n'
r'# You can add new browsers and the path to their bookmarks file. You \n'
r'# will then be able to set the new browser as the default, or choose \n'
r'# it in the Anchorage CLI. \n'
r'# \n'
r'# If using a custom browser **it must comply with the Chromium or \n'
r'# Firefox bookmark storage conventions (i.e. dictionary key naming)**.\n'
r'# If using a custom browser **it must comply with the Chromium or \n'
r'# Firefox bookmark storage conventions (i.e. dictionary key naming)**. \n'
r'# If this is not the case, export your bookmarks to a supported browser\n'
r'# and proceed.\n'
r'# Antonio Lopez Rivera, 2021\n'
r'# and proceed. \n'
r'# \n'
r'# Path convention: \n'
r'# Windows: APPDATA/<your path> \n'
r'# Linux, MacOS: <full path> \n'
r'# \n'
r'# Antonio Lopez Rivera, 2021 \n'
r'\n'
r'[chrome]\n'
r'linux = "~/.config/google-chrome/Default/Bookmarks"\n'
r'macos = "~/Library/Application Support/Google/Chrome/Default/Bookmarks"\n'
r'linux = "?"\n'
r'macos = "?"\n'
r'windows = "Local/Google/Chrome/User Data/Default/Bookmarks"\n'
r'\n'
r'[edge]\n'
r'[firefox]\n'
r'linux = "?"\n'
r'macos = "?"\n'
r'windows = "Local/Microsoft/Edge/User Data/Default/Bookmarks"\n'
r'windows = "Roaming/Mozilla/Firefox/Profiles/mfeew61f.default-release/bookmarkbackups/"\n'
r'\n'
r'[firefox]\n'
r'[edge]\n'
r'linux = "?"\n'
r'macos = "?"\n'
r'windows = "Roaming/Mozilla/Firefox/Profiles/mfeew61f.default-release/bookmarkbackups/" \n'
r'windows = "Local/Microsoft/Edge/User Data/Default/Bookmarks"\n'
r'\n'
r'["edge beta"]\n'
r'linux = "?"\n'
r'macos = "?"\n'
r'windows = "Local/Microsoft/Edge Beta/User Data/Default/Bookmarks"\n',
r'windows = "Local/Microsoft/Edge Beta/User Data/Default/Bookmarks"\n'
,
'unicode_escape')

2 changes: 1 addition & 1 deletion anchorage/anchor_utils/aesthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def newline():
print("")


def title(text="Anchorage", font="big", color="yellow"):
def title(text="Anchorage", font="big", color="cyan"):
"""
Generates the Anchorage CLI title.
Expand Down
12 changes: 7 additions & 5 deletions anchorage/bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,20 @@ def path(browser, overwrite=False):
"""
if browser == "firefox":
o_sys = operating_system()
preamble = ("\\".join(str(os.getenv("APPDATA")).split("\\")[:-1]) + "\\") if o_sys == "windows" else ""
dir_path = preamble + loc(overwrite)[browser][o_sys].replace("/", "\\")
dir_path = loc(overwrite)[browser][o_sys]
most_recent = datetime.datetime(1970, 1, 1)
for filename in os.listdir(dir_path):
file_date = datetime.datetime.strptime(filename[10:20], "%Y-%m-%d")
if file_date > most_recent:
most_recent = file_date
bk_path = dir_path + "\\" + filename
bk_path = dir_path + "/" + filename
else:
o_sys = operating_system()
preamble = ("\\".join(str(os.getenv("APPDATA")).split("\\")[:-1])+"\\") if o_sys == "windows" else ""
bk_path = preamble + loc(overwrite)[browser][o_sys].replace("/", "\\")
bk_path = loc(overwrite)[browser][o_sys]

if o_sys == "windows":
preamble = ("\\".join(str(os.getenv("APPDATA")).split("\\")[:-1]) + "\\")
bk_path = (preamble + bk_path).replace("/", "\\")
return bk_path


Expand Down
Loading

0 comments on commit 851649c

Please sign in to comment.