From 15b40d855e4c5cf471833164211500ed6609ea5f Mon Sep 17 00:00:00 2001 From: Dung Truong Date: Thu, 30 May 2024 14:32:53 -0400 Subject: [PATCH] add SIFT plugin --- code/SIFT.py | 37 +++++++++++++++++++++++++++++++++++++ code/update_plugins.sh | 3 +++ plugins/SIFT.wiki | 1 + plugins/index.md | 8 ++++++++ 4 files changed, 49 insertions(+) create mode 100644 code/SIFT.py create mode 100644 code/update_plugins.sh create mode 160000 plugins/SIFT.wiki create mode 100644 plugins/index.md diff --git a/code/SIFT.py b/code/SIFT.py new file mode 100644 index 0000000..3244b6a --- /dev/null +++ b/code/SIFT.py @@ -0,0 +1,37 @@ +import os +import sys + +# open a text file ending with .md and append a paragraph to it +# Usage: python test.py .md +def append_to_file(filepath, filename, parent): + with open(filepath) as f: + text = f.read() + append_text = '''--- +layout: default +title: {filename} +long_title: {filename} +parent: {parent} +grand_parent: Plugins +--- +'''.format(filename=filename, parent=parent) + text = append_text + text + with open(filepath, 'w') as out: + out.write(text) + +def reformat_plugin_dir(dirpath, plugin_name): + for root, dirs, files in os.walk(dirpath): + for file in files: + if file.endswith('.md') and not file.startswith('index') and not file.startswith('Home'): + append_to_file(os.path.join(root, file), file.strip('.md'), plugin_name) + +# main +def main(): + if len(sys.argv) != 3: + print('Usage: python test.py ') + sys.exit(1) + dirpath = sys.argv[1] + plugin_name = sys.argv[2] + reformat_plugin_dir(dirpath, plugin_name) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/code/update_plugins.sh b/code/update_plugins.sh new file mode 100644 index 0000000..3348c28 --- /dev/null +++ b/code/update_plugins.sh @@ -0,0 +1,3 @@ +git -C /Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins/SIFT.wiki fetch origin master +git -C /Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins/SIFT.wiki reset --hard origin/master +python /Users/dtyoung/Documents/EEGLAB/sccn.github.io/code/SIFT.py /Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins/SIFT.wiki SIFT diff --git a/plugins/SIFT.wiki b/plugins/SIFT.wiki new file mode 160000 index 0000000..c1aafb4 --- /dev/null +++ b/plugins/SIFT.wiki @@ -0,0 +1 @@ +Subproject commit c1aafb48de8c7a1ff329d8e44f0429feb9d54de9 diff --git a/plugins/index.md b/plugins/index.md new file mode 100644 index 0000000..6d1aab4 --- /dev/null +++ b/plugins/index.md @@ -0,0 +1,8 @@ +--- +layout: default +title: Plugins +has_children: true +has_toc: false +nav_order: 7 +--- +This is a test