Skip to content

Commit

Permalink
Merge pull request #62 from shmolf/issue-reporting
Browse files Browse the repository at this point in the history
Issue reporting
  • Loading branch information
Lissy93 authored Aug 17, 2024
2 parents 0ee3aed + bc14830 commit a4232f9
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 22 deletions.
36 changes: 36 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",

"customizations": {
"vscode": {
"extensions": [
"ms-python.vscode-pylance",
"ms-azuretools.vscode-docker",
"ms-python.autopep8"
]
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "latest"
}
}

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
8 changes: 5 additions & 3 deletions lib/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ def normalize_string(original, lowercase = True):

for x in templates:
normalized_title = normalize_string(x['title'])
if normalized_title not in seen_titles:
seen_titles.add(normalized_title)
filtered_data.append(x)
if normalized_title in seen_titles:
continue

seen_titles.add(normalized_title)
filtered_data.append(x)

categories = x.get('categories', [])
x['categories'] = []
Expand Down
25 changes: 23 additions & 2 deletions lib/download.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import os
import csv
import requests
import json

dir = os.path.dirname(os.path.abspath(__file__))

destination_dir = os.path.join(dir, '../sources')
sources_list = os.path.join(dir, '../sources.csv')

# Downloads the file from a given URL, to the local destination
def download(url: str, filename: str):
def download(url: str, filename: str, maintainer: str):
file_path = os.path.join(destination_dir, filename)
print('Downloading', url)
r = requests.get(url, stream=True)
if r.ok:
print('saving to', os.path.abspath(file_path))
Expand All @@ -19,6 +21,25 @@ def download(url: str, filename: str):
f.write(chunk)
f.flush()
os.fsync(f.fileno())

sourceJson = {}
with open(file_path) as f:
try:
sourceJson = json.load(f)
# Add maintainer field to each template
for t in sourceJson.get('templates', []):
t['maintainer'] = maintainer

except json.decoder.JSONDecodeError as err:
print(f'Skipping one of the sources due to an error: {f.name}')
print(f'Error msg: {err.msg}')

if not sourceJson:
return

with open(file_path, 'w') as f:
json.dump(sourceJson, f, indent=2, sort_keys=False)

else: # HTTP status code 4XX/5XX
print('Download failed: status code {}\n{}'.format(r.status_code, r.text))

Expand All @@ -38,4 +59,4 @@ def get_source_list():

# For each source, download the templates JSON file
for sourceUrl in get_source_list():
download(sourceUrl[1], sourceUrl[0] + '.json')
download(sourceUrl[1], sourceUrl[0] + '.json', sourceUrl[2])
10 changes: 6 additions & 4 deletions lib/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,28 @@ def generate_app_list():
markdown_content = ''
for index, template in enumerate(templates):
name = template['title'].title()
maintainer = template.get('maintainer')
maintainer_md_link = f" -- ([Report issues]({maintainer}))" if maintainer else ''
description = re.sub('[^0-9a-zA-Z]+', ' ', (template['description'] or ''))
if 'logo' in template and template['logo']:
logo = f"<img title=\"{description}\" src='{template['logo']}' width='26' height='26' /> "
else:
logo = ' '
markdown_content += f"{index+1}. {logo}**[{name}]({slugify(name)} '{description}')**\n"
logo = ' '
markdown_content += f"{index+1}. {logo}**[{name}]({slugify(name)} '{description}')** {maintainer_md_link}\n"
return markdown_content

def generate_sources_list():
sources = load_csv_file(sources_path)
markdown_content = ''

for index, source in enumerate(sources):
if len(source) > 1 and source[1].strip():
url = source[1].strip()
parsed_url = urllib.parse.urlparse(url)
username = parsed_url.path.split('/')[1]
avatar = f'<img src="https://github.com/{username}.png?size=40" width="26" height="26" />'
markdown_content += f"{index + 1}. {avatar} [template]({url}) by [@{username}](https://github.com/{username})\n"

return markdown_content

def insert_content_between_markers(file_path, start_marker, end_marker, content_to_insert):
Expand Down
26 changes: 13 additions & 13 deletions sources.csv
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
dnburgess_templates, https://raw.githubusercontent.com/dnburgess/self-hosted-template/master/template.json
qballjos_templates, https://raw.githubusercontent.com/Qballjos/portainer_templates/master/Template/template.json
selfhostedpro_templates, https://raw.githubusercontent.com/SelfhostedPro/selfhosted_templates/portainer-2.0/Template/template.json
technorabilia_templates, https://raw.githubusercontent.com/technorabilia/portainer-templates/main/lsio/templates/templates-2.0.json
mikestraney_templates, https://raw.githubusercontent.com/mikestraney/portainer-templates/master/templates.json
xneo1_templates, https://raw.githubusercontent.com/xneo1/portainer_templates/master/Template/template.json
novaspirit_templates, https://raw.githubusercontent.com/novaspirit/pi-hosted/master/pi-hosted_template/template/portainer-v2.json
donpablonow_templates, https://raw.githubusercontent.com/donpablonow/awesome-saas/master/Template/portainer-v2.json
mediadepot_templates, https://raw.githubusercontent.com/mediadepot/templates/master/portainer.json
mycroftwilde_templates, https://raw.githubusercontent.com/mycroftwilde/portainer_templates/master/Template/template.json
mediadepot_templates, https://raw.githubusercontent.com/mediadepot/templates/master/portainer.json
shmolf_templates, https://raw.githubusercontent.com/shmolf/portainer-templates/main/templates-2.0.json
portainer_templates, https://raw.githubusercontent.com/portainer/templates/master/templates-2.0.json
dnburgess_templates, https://raw.githubusercontent.com/dnburgess/self-hosted-template/master/template.json, https://github.com/dnburgess/self-hosted-template/
qballjos_templates, https://raw.githubusercontent.com/Qballjos/portainer_templates/master/Template/template.json, https://github.com/Qballjos/portainer_templates/
selfhostedpro_templates, https://raw.githubusercontent.com/SelfhostedPro/selfhosted_templates/portainer-2.0/Template/template.json, https://github.com/SelfhostedPro/selfhosted_templates/
technorabilia_templates, https://raw.githubusercontent.com/technorabilia/portainer-templates/main/lsio/templates/templates-2.0.json, https://github.com/technorabilia/portainer-templates/
mikestraney_templates, https://raw.githubusercontent.com/mikestraney/portainer-templates/master/templates.json, https://github.com/mikestraney/portainer-templates/
xneo1_templates, https://raw.githubusercontent.com/xneo1/portainer_templates/master/Template/template.json, https://github.com/xneo1/portainer_templates/
novaspirit_templates, https://raw.githubusercontent.com/novaspirit/pi-hosted/master/pi-hosted_template/template/portainer-v2.json, https://github.com/novaspirit/pi-hosted/
donpablonow_templates, https://raw.githubusercontent.com/donpablonow/awesome-saas/master/Template/portainer-v2.json, https://github.com/donpablonow/awesome-saas/
mediadepot_templates, https://raw.githubusercontent.com/mediadepot/templates/master/portainer.json, https://github.com/mediadepot/templates/
mycroftwilde_templates, https://raw.githubusercontent.com/mycroftwilde/portainer_templates/master/Template/template.json, https://github.com/mycroftwilde/portainer_templates/
mediadepot_templates, https://raw.githubusercontent.com/mediadepot/templates/master/portainer.json, https://github.com/mediadepot/templates/
shmolf_templates, https://raw.githubusercontent.com/shmolf/portainer-templates/main/templates-2.0.json, https://github.com/shmolf/portainer-templates/
portainer_templates, https://raw.githubusercontent.com/portainer/templates/master/templates-2.0.json, https://github.com/portainer/templates/
5 changes: 5 additions & 0 deletions sources/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.json

# Keep these
!example_templates.json
!lissy93_tempaltes.json

0 comments on commit a4232f9

Please sign in to comment.