This commit is contained in:
iganeshk
2020-01-15 20:48:22 -05:00
commit 03bf5cc383
26 changed files with 750 additions and 0 deletions

166
.gitignore vendored Normal file
View File

@@ -0,0 +1,166 @@
public
### Python.gitignore
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
### macOS.gitignore
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Ganesh Kumar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

80
README.md Normal file
View File

@@ -0,0 +1,80 @@
<img alt="LaMetric-System-Monitor" src="https://standardnotes.org/assets/icon.png"/>
## Standard Notes Extensions - Self-Hosted Repository
Host Standard Notes extensions on your own server. This utility parses list of extensions configured in YAML from the `\extensions` directory, builds a repository JSON index which can be plugged directly into Standard Notes Web/Desktop Clients. (https://standardnotes.org/)
### Requirements
* Python 3
* Python 3 - pyyaml module
### Usage
* Fork this repository to the web-server:
```bash
$ git clone https://github.com/iganeshk/standardnotes-extensions.git
$ cd standardnotes-extensions
$ pip3 install -r requirements.txt
```
* Replace `your-domain.com` at the end of the `build-repo.py` file with your domain name:
```
main(os.getenv('URL', 'https://your-domain.com/extensions'))
```
* [Optional] Make additions or appropriate changes in `/extensions` directory
* Run the utility:
```bash
$ python3 build-repo.py
```
* Server the `/public` directory and verify if the endpoint is reachable
```
https://your-domain.com/extensions/index.json
```
* Import the above endpoint into the web/desktop client.
### Setup with nginx as reverse-proxy
```nginx
location ^~ /extensions {
autoindex off;
alias /path/to/standardnotes-extensions/public;
# CORS HEADERS
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
}
```
### Acknowledgments
This project was adapted from https://github.com/JokerQyou/snextensions to facilitate on-the-fly updating of extensions.
### ToDo
* Implement the usage of GitHub API for efficiency.

148
build_repo.py Normal file
View File

@@ -0,0 +1,148 @@
#!/usr/bin/env/ python3
# coding=utf-8
'''
Parse extensions/*.yaml files & build a directory with following structure:
public/
|-my-extension-1/
| |-1.0.0/ <- version (to avoid static file caching issues)
| | |-index.json <- extension info
| | |-index.html <- extension entrance (component)
| | |-dist <- extension resources
| | |-... <- other files
|-index.json <- repo info, contain all extensions' info
'''
import json
import os
import shutil
from subprocess import run, PIPE
import yaml
def main(base_url):
'''
main function
'''
while base_url.endswith('/'):
base_url = base_url[:-1]
base_dir = os.path.dirname(os.path.abspath(__file__))
extension_dir = os.path.join(base_dir, 'extensions')
public_dir = os.path.join(base_dir, 'public')
if not os.path.exists(os.path.join(public_dir)):
os.makedirs(public_dir)
os.chdir(public_dir)
extensions = []
# Read and parse all extension info
for extfiles in os.listdir(extension_dir):
if not extfiles.endswith('.yaml'):
continue
with open(os.path.join(extension_dir, extfiles)) as extyaml:
ext = yaml.load(extyaml, Loader=yaml.FullLoader)
# Build extension info
repo_name = ext['github'].split('/')[-1]
# https://example.com/sub-domain/my-extension/version/index.html
extension_url = '/'.join([base_url, repo_name, ext['main']])
# https://example.com/sub-domain/my-extension/index.json
extension_info_url = '/'.join([base_url, repo_name, 'index.json'])
extension = dict(
identifier=ext['id'],
name=ext['name'],
content_type=ext['content_type'],
area=ext.get('area', None),
# supplying version not really a concern since it's checked for
version=ext['version'],
description=ext.get('description', None),
marketing_url=ext.get('marketing_url', None),
thumbnail_url=ext.get('thumbnail_url', None),
valid_until='2030-05-16T18:35:33.000Z',
url=extension_url,
download_url='https://github.com/{github}/archive/{version}.zip'.
format(**ext),
latest_url=extension_info_url,
flags=ext.get('flags', []),
dock_icon=ext.get('dock_icon', {}),
layerable=ext.get('layerable', None),
)
# Strip empty values
extension = {k: v for k, v in extension.items() if v}
# Get the latest repository and parse for latest version
# TO-DO: Implement usage of Github API for efficiency
run([
'git', 'clone', 'https://github.com/{github}.git'.format(**ext),
'--quiet', '{}_temp'.format(repo_name)
],
check=True)
ext_latest = (run([
'git', '--git-dir=' +
os.path.join(public_dir, '{}_temp'.format(repo_name), '.git'),
'rev-list', '--tags', '--max-count=1'
],
stdout=PIPE,
check=True).stdout.decode('utf-8').replace("\n", ""))
ext_latest_version = run([
'git', '--git-dir',
os.path.join(public_dir, '{}_temp'.format(repo_name), '.git'),
'describe', '--tags', ext_latest
],
stdout=PIPE,
check=True).stdout.decode('utf-8').replace(
"\n", "")
# Tag the latest releases
extension['version'] = ext_latest_version
extension['url'] = '/'.join([
base_url, repo_name, '{}'.format(ext_latest_version), ext['main']
])
extension['download_url'] = (
'https://github.com/{}/archive/{}.zip'.format(
ext['github'], ext_latest_version))
# check if latest version already exists
if not os.path.exists(
os.path.join(public_dir, repo_name,
'{}'.format(ext_latest_version))):
shutil.move(
os.path.join(public_dir, '{}_temp'.format(repo_name)),
os.path.join(public_dir, repo_name,
'{}'.format(ext_latest_version)))
# Delete .git resource from the directory
shutil.rmtree(
os.path.join(public_dir, repo_name,
'{}'.format(ext_latest_version), '.git'))
else:
# clean-up
shutil.rmtree(os.path.join(public_dir,
'{}_temp'.format(repo_name)))
# Generate JSON file for each extension
with open(os.path.join(public_dir, repo_name, 'index.json'),
'w') as ext_json:
json.dump(extension, ext_json, indent=4)
extensions.append(extension)
print('Loaded extension: {} - {}'.format(ext['name'],
ext_latest_version))
os.chdir('..')
# Generate the index JSON file
with open(os.path.join(public_dir, 'index.json'), 'w') as ext_json:
json.dump(
dict(
content_type='SN|Repo',
valid_until='2030-05-16T18:35:33.000Z',
packages=extensions,
),
ext_json,
indent=4,
)
if __name__ == '__main__':
main(os.getenv('URL', 'https://domain.com/extensions'))

View File

@@ -0,0 +1,15 @@
---
id: org.standardnotes.action-bar
npm: sn-action-bar
github: sn-extensions/action-bar
main: index.html
name: Action Bar
content_type: SN|Component
area: editor-stack
version: 1.3.0
marketing_url: https://standardnotes.org/extensions/action-bar
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/components/action-bar.jpg
description: Useful utility bar with information about the current note as well as actions like duplicate, copy, and save.
flags: []
...

View File

@@ -0,0 +1,15 @@
---
id: org.standardnotes.advanced-markdown-editor
npm: sn-advanced-markdown-editor
github: sn-extensions/advanced-markdown-editor
main: index.html
name: Advanced Markdown Editor
content_type: SN|Component
area: editor-editor
version: 1.3.2
marketing_url: https://standardnotes.org/extensions/advanced-markdown
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/editors/adv-markdown.jpg
description: A fully featured Markdown editor that supports live preview, a styling toolbar, and split pane support.
flags: []
...

View File

@@ -0,0 +1,18 @@
---
id: org.standardnotes.theme-autobiography
npm: sn-theme-autobiography
github: sn-extensions/autobiography-theme
main: dist/dist.css
name: Autobiography
content_type: SN|Theme
version: 1.0.0
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/themes/autobiography.jpg
description: A theme for writers and readers.
dock_icon:
type: circle
background_color: '#9D7441'
foreground_color: '#ECE4DB'
border_color: '#9D7441'
...

View File

@@ -0,0 +1,15 @@
---
id: org.standardnotes.bold-editor
npm: sn-bold-editor
github: sn-extensions/bold-editor
main: dist/index.html
name: Bold Editor
content_type: SN|Component
area: editor-editor
version: 1.0.5
marketing_url:
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/editors/bold.jpg
description: A simple and peaceful rich editor that helps you write and think clearly. Features FileSafe integration, so you can embed your encrypted images, videos, and audio recordings directly inline.
flags: []
...

View File

@@ -0,0 +1,14 @@
---
id: org.standardnotes.code-editor
npm: sn-code-editor
github: sn-extensions/code-editor
main: index.html
name: Code Editor
content_type: SN|Component
area: editor-editor
version: 1.3.3
marketing_url: https://standardnotes.org/extensions/code-editor
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/editors/code.jpg
description: Syntax highlighting and convenient keyboard shortcuts for over 120 programming languages. Ideal for code snippets and procedures.
...

View File

@@ -0,0 +1,13 @@
---
id: org.standardnotes.theme-dynamic
npm: sn-theme-dynamic
github: sn-extensions/dynamic-theme
main: dist/dist.css
name: Dynamic
layerable: true
content_type: SN|Theme
version: 1.0.0
marketing_url: https://standardnotes.org/extensions/dynamic
description: A smart theme that minimizes the tags and notes panels when they are not in use.
...

View File

@@ -0,0 +1,14 @@
---
id: org.standardnotes.fancy-markdown-editor
npm: sn-fancy-markdown-editor
github: sn-extensions/math-editor
main: index.html
name: Math Editor
content_type: SN|Component
area: editor-editor
version: 1.3.2
marketing_url: https://standardnotes.org/extensions/math-editor
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/editors/fancy-markdown.jpg
description: A beautiful split-pane Markdown editor with synced-scroll and LaTeX support. When LaTeX is detected, makes external render network request.
...

View File

@@ -0,0 +1,19 @@
---
id: org.standardnotes.theme-focus
npm: sn-theme-focus
github: sn-extensions/focus-theme
main: dist/dist.css
name: Focus
content_type: SN|Theme
version: 1.2.3
marketing_url: https://standardnotes.org/extensions/focused
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/themes/focus-with-mobile.jpg
description: For when you need to go in.
dock_icon:
type: circle
background_color: '#a464c2'
foreground_color: '#ffffff'
border_color: '#a464c2'
...

View File

@@ -0,0 +1,19 @@
---
id: org.standardnotes.theme-futura
npm: sn-futura-theme
github: sn-extensions/futura-theme
main: dist/dist.css
name: Futura
content_type: SN|Theme
version: 1.2.2
marketing_url: https://standardnotes.org/extensions/futura
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/themes/futura-with-mobile.jpg
description: Calm and relaxed. Take some time off.
dock_icon:
type: circle
background_color: '#fca429'
foreground_color: '#ffffff'
border_color: '#fca429'
...

View File

@@ -0,0 +1,14 @@
---
id: org.standardnotes.github-push
npm: sn-github-push
github: sn-extensions/github-push
main: index.html
name: GitHub Push
content_type: SN|Component
area: editor-stack
version: 1.2.1
marketing_url: https://standardnotes.org/extensions/github-push
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/components/github-push.jpg
description: Push note changes to a public or private GitHub repository, with options for file extension and commit message.
...

View File

@@ -0,0 +1,19 @@
---
id: org.standardnotes.theme-midnight
npm: sn-theme-midnight
github: sn-extensions/midnight-theme
main: dist/dist.css
name: Midnight
content_type: SN|Theme
version: 1.2.1
marketing_url: https://standardnotes.org/extensions/midnight
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/themes/midnight-with-mobile.jpg
description: Elegant utilitarianism.
dock_icon:
type: circle
background_color: '#086DD6'
foreground_color: '#ffffff'
border_color: '#086DD6'
...

View File

@@ -0,0 +1,15 @@
---
id: org.standardnotes.minimal-markdown-editor
npm: sn-minimal-markdown-editor
github: sn-extensions/minimal-markdown-editor
main: index.html
name: Minimal Markdown Editor
content_type: SN|Component
area: editor-editor
version: 1.3.2
marketing_url: https://standardnotes.org/extensions/minimal-markdown-editor
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/editors/min-markdown.jpg
description: A minimal Markdown editor with live rendering and in-text search via Ctrl/Cmd + F
flags: []
...

View File

@@ -0,0 +1,17 @@
---
id: org.standardnotes.theme-no-distraction
npm: sn-theme-no-distraction
github: sn-extensions/no-distraction-theme
main: dist/dist.css
name: No Distraction
content_type: SN|Theme
version: 1.2.2
layerable: true
marketing_url: https://standardnotes.org/extensions/no-distraction
description: A theme for focusing on your writing.
dock_icon:
type: svg
source: <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\"><path d=\"M424 64H88c-26.6 0-48 21.6-48 48v288c0 26.4 21.4 48 48 48h336c26.4 0 48-21.6 48-48V112c0-26.4-21.4-48-48-48zm0 336H88V176h336v224z\"/></svg>
...

View File

@@ -0,0 +1,15 @@
---
id: org.standardnotes.plus-editor
npm: sn-plus-editor
github: sn-extensions/plus-editor
main: index.html
name: Plus Editor
content_type: SN|Component
area: editor-editor
version: 1.3.2
marketing_url: https://standardnotes.org/extensions/plus-editor
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/editors/plus-editor.jpg
description: From highlighting to custom font sizes and colors, to tables and lists, this editor is perfect for crafting any document.
flags: []
...

View File

@@ -0,0 +1,15 @@
---
id: org.standardnotes.standard-sheets
npm: sn-spreadsheets
github: sn-extensions/secure-spreadsheets
main: dist/index.html
name: Secure Spreadsheets
content_type: SN|Component
area: editor-editor
version: 1.3.3
marketing_url:
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/editors/spreadsheets.png
description: A powerful spreadsheet editor with formatting and formula support. Not recommended for large data sets, as encryption of such data may decrease editor performance.
flags: []
...

View File

@@ -0,0 +1,15 @@
---
id: org.standardnotes.simple-markdown-editor
npm: sn-simple-markdown-editor
github: sn-extensions/simple-markdown-editor
main: dist/index.html
name: Simple Markdown Editor
content_type: SN|Component
area: editor-editor
version: 1.3.6
marketing_url: https://standardnotes.org/extensions/simple-markdown-editor
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/editors/simple-markdown.jpg
description: A Markdown editor with dynamic split-pane preview.
flags: []
...

View File

@@ -0,0 +1,15 @@
---
id: org.standardnotes.simple-task-editor
npm: sn-simple-task-editor
github: sn-extensions/simple-task-editor
main: dist/index.html
name: Simple Task Editor
content_type: SN|Component
area: editor-editor
version: 1.3.3
marketing_url: https://standardnotes.org/extensions/simple-task-editor
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/editors/task-editor.jpg
description: A great way to manage short-term and long-term to-do's. You can mark tasks as completed, change their order, and edit the text naturally in place.
flags: []
...

View File

@@ -0,0 +1,19 @@
---
id: org.standardnotes.theme-solarized-dark
npm: sn-theme-solarized-dark
github: sn-extensions/solarized-dark-theme
main: dist/dist.css
name: Solarized Dark
content_type: SN|Theme
version: 1.2.1
marketing_url: https://standardnotes.org/extensions/solarized-dark
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/themes/solarized-dark.jpg
description: The perfect theme for any time.
dock_icon:
type: circle
background_color: '#2AA198'
foreground_color: '#ffffff'
border_color: '#2AA198'
...

View File

@@ -0,0 +1,19 @@
---
id: org.standardnotes.theme-titanium
npm: sn-theme-titanium
github: sn-extensions/titanium-theme
main: dist/dist.css
name: Titanium
content_type: SN|Theme
version: 1.2.2
marketing_url: https://standardnotes.org/extensions/titanium
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/themes/titanium-with-mobile.jpg
description: Light on the eyes, heavy on the spirit.
dock_icon:
type: circle
background_color: '#6e2b9e'
foreground_color: '#ffffff'
border_color: '#6e2b9e'
...

View File

@@ -0,0 +1,14 @@
---
id: org.standardnotes.token-vault
npm: sn-token-vault
github: sn-extensions/token-vault
main: dist/index.html
name: TokenVault
content_type: SN|Component
area: editor-editor
version: 1.0.4
thumbnail_url: https://standard-notes.s3.amazonaws.com/screenshots/models/editors/token-vault.png
description: Encrypt and protect your 2FA secrets for all your internet accounts. TokenVault handles your 2FA secrets so that you never lose them again, or have to start over when you get a new device.
flags: [Beta]
...

View File

@@ -0,0 +1,15 @@
---
id: org.standardnotes.vim-editor
npm: sn-vim-editor
github: sn-extensions/vim-editor
main: index.html
name: Vim Editor
content_type: SN|Component
area: editor-editor
version: 1.3.2
marketing_url: https://standardnotes.org/extensions/vim-editor
thumbnail_url: https://s3.amazonaws.com/standard-notes/screenshots/models/editors/vim.jpg
description: A code editor with Vim key bindings.
flags: []
...

1
requirements.txt Normal file
View File

@@ -0,0 +1 @@
pyyaml