Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# TODO
- [x] Cache html version until changes in md file
- [ ] Adding user authentications for restricted access
- [ ] Optional auth to protect files against changes by unauthorized users
- [x] Edit and remove icons at the top instead of the text at the bottom
- [ ] Drawio integration
- [x] Knowledge graph using [visjs](https://visjs.github.io/vis-network/examples/)
- [x] use better search mechanism, using [whoosh](https://whoosh.readthedocs.io/en/latest/intro.html)
- [ ] Drawio integration
107 changes: 0 additions & 107 deletions config.py

This file was deleted.

6 changes: 3 additions & 3 deletions wikmd-config.yaml → config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
wikmd_host: "0.0.0.0"
wikmd_port: 5000
wikmd_logging: 1
wikmd_logging_file: "wikmd.log"
wikmd_logging_file: "wikimd.log"

git_user: "wikmd"
git_email: "wikmd@no-mail.com"
git_user: "wikimd"
git_email: "wikimd@no-mail.com"

main_branch_name: "main"
sync_with_remote: 0
Expand Down
26 changes: 16 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
beautifulsoup4==4.12.3
blinker==1.7.0
cachelib==0.12.0
certifi==2024.2.2
charset-normalizer==3.3.2
click==8.1.7
Flask==3.0.2
Flask-Login==0.6.3
gitdb==4.0.11
GitPython==3.1.42
idna==3.6
itsdangerous==2.1.2
Jinja2==3.1.3
lxml==5.1.0
Markdown==3.5.2
MarkupSafe==2.1.5
PyYAML==6.0.1
Werkzeug==3.0.1
Whoosh==2.7.4
beautifulsoup4==4.12.3
click==8.1.7
gitdb==4.0.11
idna==3.6
pandoc-eqnos==2.5.0
pandoc-fignos==2.4.0
pandoc-secnos==2.2.2
pandoc-tablenos==2.3.0
pandoc-xnos==2.5.0
pandocfilters==1.5.1
psutil==5.9.8
pypandoc==1.13
PyYAML==6.0.1
requests==2.31.0
smmap==5.0.1
lxml==5.1.0
soupsieve==2.5
urllib3==2.2.1
watchdog==2.1.9
cachelib==0.12.0
psutil==5.9.8
Werkzeug==3.0.1
Whoosh==2.7.4
File renamed without changes.
File renamed without changes.
71 changes: 71 additions & 0 deletions src/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import os
import yaml

WIKMD_CONFIG_FILE = "../config.yaml"

def config_list(yaml_config, config_item_name):
"""
Function that gets a config item of type list.
Priority is in the following order either from environment variables or yaml file or default value.
"""
default_value = ["image/gif", "image/jpeg", "image/png", "image/svg+xml", "image/webp"]
if os.getenv(config_item_name.upper()):
# Env Var in the form `EXAMPLE="a, b, c, d"` or `EXAMPLE="a,b,c,d"`
return [ext.strip() for ext in os.getenv(config_item_name.upper()).split(",")]
elif yaml_config[config_item_name.lower()]:
return yaml_config[config_item_name.lower()]
else:
return default_value


class WikmdConfig:
"""
Class that stores the configuration of wikmd.
"""
def __init__(self):
"""
Function that gets the configuration parameters from .yaml file, os environment variables or default values.
Each configuration parameter is stored into a class attribute.
Env. vars take precedence.
"""
__location__ = os.path.realpath(
os.path.join(os.getcwd(), os.path.dirname(__file__)))

# .yaml config file
with open(os.path.join(__location__, WIKMD_CONFIG_FILE)) as f:
yaml_config = yaml.safe_load(f)

# Load config parameters from env. vars, yaml or default values (the firsts take precedence)
self.wikmd_host = yaml_config.get("wikmd_host")
self.wikmd_port = yaml_config.get("wikmd_port")
self.wikmd_logging = yaml_config.get("wikmd_logging")
self.wikmd_logging_file = yaml_config.get("wikmd_logging_file")

self.git_user = yaml_config.get("git_user")
self.git_email = yaml_config.get("git_email")

self.main_branch_name = yaml_config.get("main_branch_name")
self.sync_with_remote = yaml_config.get("sync_with_remote")
self.remote_url = yaml_config.get("remote_url")

self.wiki_directory = yaml_config.get("wiki_directory")
self.homepage = yaml_config.get("homepage")
self.homepage_title = yaml_config.get("homepage_title")
self.images_route = yaml_config.get("images_route")

self.hide_folder_in_wiki = yaml_config.get("hide_folder_in_wiki")

self.plugins = yaml_config.get("plugins")

self.protect_edit_by_password = yaml_config.get("protect_edit_by_password")
self.password_in_sha_256 = yaml_config.get("password_in_sha_256")

self.local_mode = yaml_config.get("local_mode")

self.image_allowed_mime = config_list(yaml_config, "image_allowed_mime")
self.optimize_images = yaml_config.get("optimize_images", )

self.cache_dir = yaml_config.get("cache_dir")
self.search_dir = yaml_config.get("search_dir")

self.secret_key = yaml_config.get("secret_key")
3 changes: 0 additions & 3 deletions git_manager.py → src/git_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
from config import WikmdConfig
from utils import move_all_files


TEMP_DIR = "temp"


cfg = WikmdConfig()


def is_git_repo(path: str) -> bool:
"""
Function that determines if the given path is a git repo.
Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion knowledge_graph.py → src/knowledge_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

cfg = WikmdConfig()


def extend_ids(links):
for link in links:
for l in link["links"]:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions wiki.py → src/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@
import knowledge_graph
import secrets

from flask import Flask, render_template, request, redirect, url_for, make_response, send_file, \
send_from_directory, flash

from flask import Flask, render_template, request, redirect, url_for, make_response, send_file, send_from_directory, flash
from werkzeug.utils import safe_join, secure_filename
from threading import Thread
from hashlib import sha256

from cache import Cache
from image_manager import ImageManager
from config import WikmdConfig
from git_manager import WikiRepoManager
from search import Search, Watchdog
from web_dependencies import get_web_deps
from plugins.load_plugins import PluginLoader

from utils import pathify


SESSIONS = []

cfg = WikmdConfig()
Expand All @@ -34,7 +33,8 @@
HOMEPAGE_PATH = pathify(cfg.wiki_directory, cfg.homepage)
HIDDEN_PATHS = tuple([UPLOAD_FOLDER_PATH, GIT_FOLDER_PATH, HOMEPAGE_PATH] + HIDDEN_FOLDER_PATH_LIST)

app = Flask(__name__)
app = Flask(__name__, template_folder="../templates", static_folder="../static")

app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER_PATH
app.config['SECRET_KEY'] = cfg.secret_key

Expand Down