Skip to content

Commit 15b40d8

Browse files
committed
add SIFT plugin
1 parent a4b9843 commit 15b40d8

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

code/SIFT.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
import sys
3+
4+
# open a text file ending with .md and append a paragraph to it
5+
# Usage: python test.py <filename>.md
6+
def append_to_file(filepath, filename, parent):
7+
with open(filepath) as f:
8+
text = f.read()
9+
append_text = '''---
10+
layout: default
11+
title: {filename}
12+
long_title: {filename}
13+
parent: {parent}
14+
grand_parent: Plugins
15+
---
16+
'''.format(filename=filename, parent=parent)
17+
text = append_text + text
18+
with open(filepath, 'w') as out:
19+
out.write(text)
20+
21+
def reformat_plugin_dir(dirpath, plugin_name):
22+
for root, dirs, files in os.walk(dirpath):
23+
for file in files:
24+
if file.endswith('.md') and not file.startswith('index') and not file.startswith('Home'):
25+
append_to_file(os.path.join(root, file), file.strip('.md'), plugin_name)
26+
27+
# main
28+
def main():
29+
if len(sys.argv) != 3:
30+
print('Usage: python test.py <plugin_dir_path> <plugin_name>')
31+
sys.exit(1)
32+
dirpath = sys.argv[1]
33+
plugin_name = sys.argv[2]
34+
reformat_plugin_dir(dirpath, plugin_name)
35+
36+
if __name__ == "__main__":
37+
main()

code/update_plugins.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
git -C /Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins/SIFT.wiki fetch origin master
2+
git -C /Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins/SIFT.wiki reset --hard origin/master
3+
python /Users/dtyoung/Documents/EEGLAB/sccn.github.io/code/SIFT.py /Users/dtyoung/Documents/EEGLAB/sccn.github.io/plugins/SIFT.wiki SIFT

plugins/SIFT.wiki

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit c1aafb48de8c7a1ff329d8e44f0429feb9d54de9

plugins/index.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
layout: default
3+
title: Plugins
4+
has_children: true
5+
has_toc: false
6+
nav_order: 7
7+
---
8+
This is a test

0 commit comments

Comments
 (0)