added no-distraction-dynamic theme
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<img alt="LaMetric-System-Monitor" src="https://standardnotes.org/assets/icon.png"/>
|
<img alt="Standard Notes Extension" src="../assets/standardnotes.png?raw=true"/>
|
||||||
|
|
||||||
## Standard Notes Extensions - Self-Hosted Repository
|
## Standard Notes Extensions - Self-Hosted Repository
|
||||||
Host Standard Notes extensions on your own server. This utility parses most of the open-source extensions available from original repository as well as from other authors and builds an extensions repository which then can be plugged directly into Standard Notes Web/Desktop Clients. (https://standardnotes.org/)
|
Host Standard Notes extensions on your own server. This utility parses most of the open-source extensions available from original repository as well as from other authors and builds an extensions repository which then can be plugged directly into Standard Notes Web/Desktop Clients. (https://standardnotes.org/)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ from zipfile import ZipFile
|
|||||||
import requests
|
import requests
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
def get_environment(base_dir):
|
def get_environment(base_dir):
|
||||||
"""
|
"""
|
||||||
Parse the environment variables from .env
|
Parse the environment variables from .env
|
||||||
@@ -29,18 +30,21 @@ def get_environment(base_dir):
|
|||||||
github:
|
github:
|
||||||
username:
|
username:
|
||||||
token:
|
token:
|
||||||
""", Loader=yaml.FullLoader)
|
""",
|
||||||
|
Loader=yaml.FullLoader)
|
||||||
if os.path.isfile(os.path.join(base_dir, ".env")):
|
if os.path.isfile(os.path.join(base_dir, ".env")):
|
||||||
with open(os.path.join(base_dir, ".env")) as temp_env_file:
|
with open(os.path.join(base_dir, ".env")) as temp_env_file:
|
||||||
temp_envvar = yaml.load(temp_env_file, Loader=yaml.FullLoader)
|
temp_envvar = yaml.load(temp_env_file, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
return temp_envvar
|
return temp_envvar
|
||||||
|
|
||||||
|
|
||||||
def process_zipball(repo_dir, release_version):
|
def process_zipball(repo_dir, release_version):
|
||||||
"""
|
"""
|
||||||
Grab the release zipball and extract it without the root/parent/top directory
|
Grab the release zipball and extract it without the root/parent/top directory
|
||||||
"""
|
"""
|
||||||
with ZipFile(os.path.join(repo_dir, release_version) + ".zip", 'r') as zipball:
|
with ZipFile(os.path.join(repo_dir, release_version) + ".zip",
|
||||||
|
'r') as zipball:
|
||||||
for member in zipball.namelist():
|
for member in zipball.namelist():
|
||||||
# Parse files list excluding the top/parent/root directory
|
# Parse files list excluding the top/parent/root directory
|
||||||
filename = '/'.join(member.split('/')[1:])
|
filename = '/'.join(member.split('/')[1:])
|
||||||
@@ -50,13 +54,18 @@ def process_zipball(repo_dir, release_version):
|
|||||||
if filename.startswith('.'): continue
|
if filename.startswith('.'): continue
|
||||||
source = zipball.open(member)
|
source = zipball.open(member)
|
||||||
try:
|
try:
|
||||||
target = open(os.path.join(repo_dir, release_version, filename), "wb")
|
target = open(
|
||||||
|
os.path.join(repo_dir, release_version, filename), "wb")
|
||||||
with source, target:
|
with source, target:
|
||||||
target = open(os.path.join(repo_dir, release_version, filename), "wb")
|
target = open(
|
||||||
|
os.path.join(repo_dir, release_version, filename),
|
||||||
|
"wb")
|
||||||
shutil.copyfileobj(source, target)
|
shutil.copyfileobj(source, target)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
# Create the directory
|
# Create the directory
|
||||||
os.makedirs(os.path.dirname(os.path.join(repo_dir, release_version, filename)))
|
os.makedirs(
|
||||||
|
os.path.dirname(
|
||||||
|
os.path.join(repo_dir, release_version, filename)))
|
||||||
continue
|
continue
|
||||||
# Delete the archive zip
|
# Delete the archive zip
|
||||||
os.remove(os.path.join(repo_dir, release_version) + ".zip")
|
os.remove(os.path.join(repo_dir, release_version) + ".zip")
|
||||||
@@ -76,24 +85,29 @@ def git_clone_method(ext_yaml, public_dir, ext_has_update):
|
|||||||
ext_last_commit = (run([
|
ext_last_commit = (run([
|
||||||
'git', '--git-dir=' +
|
'git', '--git-dir=' +
|
||||||
os.path.join(public_dir, '{}_tmp'.format(repo_name), '.git'),
|
os.path.join(public_dir, '{}_tmp'.format(repo_name), '.git'),
|
||||||
'rev-list', '--tags', '--max-count=1'], stdout=PIPE, check=True).stdout.decode('utf-8').replace("\n", ""))
|
'rev-list', '--tags', '--max-count=1'
|
||||||
|
],
|
||||||
|
stdout=PIPE,
|
||||||
|
check=True).stdout.decode('utf-8').replace(
|
||||||
|
"\n", ""))
|
||||||
ext_version = run([
|
ext_version = run([
|
||||||
'git', '--git-dir',
|
'git', '--git-dir',
|
||||||
os.path.join(public_dir, '{}_tmp'.format(repo_name), '.git'),
|
os.path.join(public_dir, '{}_tmp'.format(repo_name), '.git'),
|
||||||
'describe', '--tags', ext_last_commit], stdout=PIPE, check=True).stdout.decode('utf-8').replace("\n", "")
|
'describe', '--tags', ext_last_commit
|
||||||
|
],
|
||||||
|
stdout=PIPE,
|
||||||
|
check=True).stdout.decode('utf-8').replace("\n", "")
|
||||||
|
|
||||||
# check if the latest version already exist
|
# check if the latest version already exist
|
||||||
if not os.path.exists(
|
if not os.path.exists(os.path.join(repo_dir, ext_version)):
|
||||||
os.path.join(repo_dir, ext_version)):
|
|
||||||
ext_has_update = True
|
ext_has_update = True
|
||||||
shutil.move(
|
shutil.move(
|
||||||
os.path.join(public_dir, '{}_tmp'.format(repo_name)),
|
os.path.join(public_dir, '{}_tmp'.format(repo_name)),
|
||||||
os.path.join(public_dir, repo_name,
|
os.path.join(public_dir, repo_name, '{}'.format(ext_version)))
|
||||||
'{}'.format(ext_version)))
|
|
||||||
# Delete .git resource from the directory
|
# Delete .git resource from the directory
|
||||||
shutil.rmtree(
|
shutil.rmtree(
|
||||||
os.path.join(public_dir, repo_name,
|
os.path.join(public_dir, repo_name, '{}'.format(ext_version),
|
||||||
'{}'.format(ext_version), '.git'))
|
'.git'))
|
||||||
else:
|
else:
|
||||||
# ext already up-to-date
|
# ext already up-to-date
|
||||||
# print('Extension: {} - {} (already up-to-date)'.format(ext_yaml['name'], ext_version))
|
# print('Extension: {} - {} (already up-to-date)'.format(ext_yaml['name'], ext_version))
|
||||||
@@ -121,7 +135,6 @@ def parse_extensions(base_dir, base_url, ghub_session):
|
|||||||
|
|
||||||
with open(os.path.join(extension_dir, extfiles)) as extyaml:
|
with open(os.path.join(extension_dir, extfiles)) as extyaml:
|
||||||
ext_yaml = yaml.load(extyaml, Loader=yaml.FullLoader)
|
ext_yaml = yaml.load(extyaml, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
ext_has_update = False
|
ext_has_update = False
|
||||||
repo_name = ext_yaml['github'].split('/')[-1]
|
repo_name = ext_yaml['github'].split('/')[-1]
|
||||||
repo_dir = os.path.join(public_dir, repo_name)
|
repo_dir = os.path.join(public_dir, repo_name)
|
||||||
@@ -130,8 +143,17 @@ def parse_extensions(base_dir, base_url, ghub_session):
|
|||||||
if ghub_session is not None:
|
if ghub_session is not None:
|
||||||
# Github API Method
|
# Github API Method
|
||||||
# Get extension Github meta-data
|
# Get extension Github meta-data
|
||||||
ext_git_info = json.loads(ghub_session.get('https://api.github.com/repos/{github}/releases/latest'.format(**ext_yaml)).text)
|
ext_git_info = json.loads(
|
||||||
ext_version = ext_git_info['tag_name']
|
ghub_session.get(
|
||||||
|
'https://api.github.com/repos/{github}/releases/latest'.
|
||||||
|
format(**ext_yaml)).text)
|
||||||
|
try:
|
||||||
|
ext_version = ext_git_info['tag_name']
|
||||||
|
except KeyError:
|
||||||
|
print(
|
||||||
|
"Error: Unable to update %s (%s) does it have a release at Github?"
|
||||||
|
% (ext_yaml['name'], extfiles))
|
||||||
|
continue
|
||||||
# Check if extension directory alredy exists
|
# Check if extension directory alredy exists
|
||||||
if not os.path.exists(repo_dir):
|
if not os.path.exists(repo_dir):
|
||||||
os.makedirs(repo_dir)
|
os.makedirs(repo_dir)
|
||||||
@@ -140,13 +162,17 @@ def parse_extensions(base_dir, base_url, ghub_session):
|
|||||||
ext_has_update = True
|
ext_has_update = True
|
||||||
os.makedirs(os.path.join(repo_dir, ext_version))
|
os.makedirs(os.path.join(repo_dir, ext_version))
|
||||||
# Grab the release and then unpack it
|
# Grab the release and then unpack it
|
||||||
with requests.get(ext_git_info['zipball_url'], stream=True) as zipball_stream:
|
with requests.get(ext_git_info['zipball_url'],
|
||||||
with open(os.path.join(repo_dir, ext_version) + ".zip", 'wb') as zipball_file:
|
stream=True) as zipball_stream:
|
||||||
|
with open(
|
||||||
|
os.path.join(repo_dir, ext_version) + ".zip",
|
||||||
|
'wb') as zipball_file:
|
||||||
shutil.copyfileobj(zipball_stream.raw, zipball_file)
|
shutil.copyfileobj(zipball_stream.raw, zipball_file)
|
||||||
# unpack the zipball
|
# unpack the zipball
|
||||||
process_zipball(repo_dir, ext_version)
|
process_zipball(repo_dir, ext_version)
|
||||||
else:
|
else:
|
||||||
ext_version, ext_has_update = git_clone_method(ext_yaml, public_dir, ext_has_update)
|
ext_version, ext_has_update = git_clone_method(
|
||||||
|
ext_yaml, public_dir, ext_has_update)
|
||||||
|
|
||||||
# Build extension info (stateless)
|
# Build extension info (stateless)
|
||||||
# https://domain.com/sub-domain/my-extension/index.json
|
# https://domain.com/sub-domain/my-extension/index.json
|
||||||
@@ -161,8 +187,8 @@ def parse_extensions(base_dir, base_url, ghub_session):
|
|||||||
thumbnail_url=ext_yaml.get('thumbnail_url', None),
|
thumbnail_url=ext_yaml.get('thumbnail_url', None),
|
||||||
valid_until='2030-05-16T18:35:33.000Z',
|
valid_until='2030-05-16T18:35:33.000Z',
|
||||||
url='/'.join([base_url, repo_name, ext_version, ext_yaml['main']]),
|
url='/'.join([base_url, repo_name, ext_version, ext_yaml['main']]),
|
||||||
download_url='https://github.com/{}/archive/{}.zip'.
|
download_url='https://github.com/{}/archive/{}.zip'.format(
|
||||||
format(ext_yaml['github'], ext_version),
|
ext_yaml['github'], ext_version),
|
||||||
latest_url='/'.join([base_url, repo_name, 'index.json']),
|
latest_url='/'.join([base_url, repo_name, 'index.json']),
|
||||||
flags=ext_yaml.get('flags', []),
|
flags=ext_yaml.get('flags', []),
|
||||||
dock_icon=ext_yaml.get('dock_icon', {}),
|
dock_icon=ext_yaml.get('dock_icon', {}),
|
||||||
@@ -179,10 +205,12 @@ def parse_extensions(base_dir, base_url, ghub_session):
|
|||||||
with open(os.path.join(public_dir, repo_name, 'index.json'),
|
with open(os.path.join(public_dir, repo_name, 'index.json'),
|
||||||
'w') as ext_json:
|
'w') as ext_json:
|
||||||
json.dump(extension, ext_json, indent=4)
|
json.dump(extension, ext_json, indent=4)
|
||||||
print('Extension: {:30s} {:6s}\t(updated)'.format(ext_yaml['name'], ext_version))
|
print('Extension: {:30s} {:6s}\t(updated)'.format(
|
||||||
|
ext_yaml['name'], ext_version))
|
||||||
else:
|
else:
|
||||||
# ext already up-to-date
|
# ext already up-to-date
|
||||||
print('Extension: {:30s} {:6s}\t(already up-to-date)'.format(ext_yaml['name'], ext_version))
|
print('Extension: {:30s} {:6s}\t(already up-to-date)'.format(
|
||||||
|
ext_yaml['name'], ext_version))
|
||||||
|
|
||||||
extensions.append(extension)
|
extensions.append(extension)
|
||||||
os.chdir('..')
|
os.chdir('..')
|
||||||
@@ -214,12 +242,15 @@ def main():
|
|||||||
if (env_var['github']['username'] and env_var['github']['token']):
|
if (env_var['github']['username'] and env_var['github']['token']):
|
||||||
# Get a re-usable session object using user credentials
|
# Get a re-usable session object using user credentials
|
||||||
ghub_session = requests.Session()
|
ghub_session = requests.Session()
|
||||||
ghub_session.auth = (env_var['github']['username'], env_var['github']['token'])
|
ghub_session.auth = (env_var['github']['username'],
|
||||||
|
env_var['github']['token'])
|
||||||
try:
|
try:
|
||||||
ghub_verify = ghub_session.get("https://api.github.com/")
|
ghub_verify = ghub_session.get("https://api.github.com/")
|
||||||
if not ghub_verify.headers['status'] == "200 OK":
|
if not ghub_verify.headers['status'] == "200 OK":
|
||||||
print("Error: %s " % ghub_verify.headers['status'])
|
print("Error: %s " % ghub_verify.headers['status'])
|
||||||
print("Bad Github credentials in the .env file, check and try again.")
|
print(
|
||||||
|
"Bad Github credentials in the .env file, check and try again."
|
||||||
|
)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Unknown error occured: %s" % e)
|
print("Unknown error occured: %s" % e)
|
||||||
@@ -229,10 +260,14 @@ def main():
|
|||||||
ghub_session.close()
|
ghub_session.close()
|
||||||
else:
|
else:
|
||||||
# Environment file missing
|
# Environment file missing
|
||||||
print("Environment not set (read env.sample)")
|
print(
|
||||||
input("⚠️ This method is set to be deprecated soon, Press any key to continue:\n")
|
"Environment variables not set (read env.sample). Using Git Clone method instead"
|
||||||
|
)
|
||||||
|
input(
|
||||||
|
"⚠️ This method in't that efficient, Press any key to continue:\n")
|
||||||
parse_extensions(base_dir, base_url, None)
|
parse_extensions(base_dir, base_url, None)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
19
extensions/no-distraction-dynamic.yaml
Normal file
19
extensions/no-distraction-dynamic.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
id: com.iganesh.theme-no-distraction-dynamic
|
||||||
|
github: iganeshk/sn-theme-no-distraction-dynamic
|
||||||
|
main: dist/dist.css
|
||||||
|
|
||||||
|
name: No Distraction (Dynamic)
|
||||||
|
layerable: true
|
||||||
|
content_type: SN|Theme
|
||||||
|
area: themes
|
||||||
|
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.
|
||||||
|
|
||||||
|
dock_icon:
|
||||||
|
type: svg
|
||||||
|
source: |-
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path d="M15.093 6.694h0.92v2.862l3.987-4.024-3.988-4.025v2.387h-0.92c-3.694 0-5.776 2.738-7.614 5.152-1.652 2.172-3.080 4.049-5.386 4.049h-2.092v2.799h2.093c3.694 0 5.776-2.736 7.614-5.152 1.652-2.173 3.080-4.048 5.386-4.048zM5.41 8.458c0.158-0.203 0.316-0.412 0.477-0.623 0.39-0.514 0.804-1.055 1.252-1.596-1.322-1.234-2.915-2.144-5.046-2.144h-2.093v2.799h2.093c1.327 0 2.362 0.623 3.317 1.564zM16.012 13.294h-0.92c-1.407 0-2.487-0.701-3.491-1.738-0.1 0.131-0.201 0.264-0.303 0.397-0.441 0.58-0.915 1.201-1.439 1.818 1.356 1.324 3 2.324 5.232 2.324h0.92v2.398l3.989-4.025-3.988-4.025v2.851z"></path></svg>
|
||||||
|
# Shuffle Icon from Entypo by Daniel Bruce
|
||||||
|
...
|
||||||
Reference in New Issue
Block a user