Loading bin/build_pontifex.sh 0 → 100755 +61 −0 Viewed Changes for bin/build_pontifex.sh: 61 added lines, 0 removed lines. Original line number Diff line number Diff line #!/bin/bash # run this from the basedir of the hugo folder PONTIFEX_BASEDIR=`pwd` # use local bin folder if [ ! -n "${PONTIFEX_BIN}" ]; then PONTIFEX_BIN=`pwd`/bin fi echo "Using Preprocessing routines from PONTIFEX_BIN=${PONTIFEX_BIN}" BUILD_DIR=${PONTIFEX_BASEDIR}/content/en/docs INPUT_JSON="${PONTIFEX_BASEDIR}/nodes/cyto.json" jsonconverter="python3 ${PONTIFEX_BIN}/makejson.py" hugoconverter="python3 ${PONTIFEX_BIN}/makehugo.py" # Preprocessing echo "Creating files for nodes..." cd ${PONTIFEX_BASEDIR}/nodes for i in ??? do ## Pandoc mkdir -p $i touch $i/$i.tex #delete this line once all nodes have texfiles cp -f packs.tex $i/. #needed for pandoc processing pandoc -f latex -t html $i/$i.tex -o $i/$i-snippet.html --mathjax rm -f $i/packs.tex #cleanup ## JSON Files and HUGO $jsonconverter $INPUT_JSON $i > $i/$i.json $hugoconverter $i done # Copy to destination echo "Copying files to HUGO..." cd ${PONTIFEX_BASEDIR}/nodes for i in ??? do first=${i:0:1} mkdir -p ${BUILD_DIR}/chapter$first/$i cp $i/$i.json ${BUILD_DIR}/chapter$first/$i cp $i.md ${BUILD_DIR}/chapter$first/ done # Run Hugo echo "Running HUGO..." cd ${PONTIFEX_BASEDIR} npm install ./node_modules/.bin/hugo/hugo echo "Done!" echo "Run docker run -it --rm --name apache-server -p 8080:80 -v \`pwd\`/public:/usr/local/apache2/htdocs/ httpd:2.4-alpine and open up http://localhost:8080/ in order to view the webpage. " bin/makehugo.py 0 → 100644 +153 −0 Viewed Changes for bin/makehugo.py: 153 added lines, 0 removed lines. Original line number Diff line number Diff line """Make hugo This script allows the user to put everything into a md-file for hugo input: (0) index = xxx (x) xxx.html (x) xxx.json output: xxx.md usage: python3 makehugo.py xxx """ import json import sys # function: input: index = xxx, output: - import logging test = 0 if test == 1: index = "100" path = f"../nodes/{index}/{index}" # test else: index = str(sys.argv[1]) path = f"{index}/{index}" with open(f"{path}.json", 'r') as input: mydata = json.load(input) nodes = mydata["nodes"] edges = mydata["edges"] mylines = [] # Declare an empty list. with open(f"../nodes/dummy_for_hugo.md", 'rt') as myfile: # open file for myline in myfile: # For each line in the file, mylines.append(myline.rstrip('\n')) # Read cyto with open('../nodes/cyto.json', 'r') as f: mydata = json.load(f) mynode = mydata["nodes"][index] # read content filename = mynode["notes"] videolink = mynode["video"] webworklink = mynode["webwork"] discussionlink = mynode["discussion"] title = mynode["label"].replace('\n',' ') content = mynode["content"] podcast = mynode["podcast"] timestamp = "2022-04-01T08:48:57+00:00" chapter = f"chapter{index[0]}" youtubend = videolink[videolink.find("embed")+6:] # preprocess podcast ntabs = 3 if podcast != "": ntabs = ntabs + 1 podcast = '{{< tab tabName="Podcast">}}\n'+ podcast + '\n{{< /tab >}}\n' # read notes with spaces in front of each line mynotes = "" with open(f"../nodes/{index}/{filename}", 'rt') as myfile2: for myline in myfile2: mynotes = mynotes + myline #preds and succs def match_edge(nid): """checks if edge has source or target as given id""" for edge in edges: if edge["data"]["source"] == nid: return "s" if edge["data"]["target"] == nid: return "t" def snippet(a, b, c=0): """takes input to put it into table form""" if c == 1: c = ' class="bg-danger"' else: c = '' string = f""" <tr{c}> <th scope="row">{a}</th> <td>{b}</td> </tr> """ return string def read_node(node): """gives id, label with link and content of a node""" nid = node["data"]["id"] cid = f"chapter{nid[0]}" a = node["data"]["label"] b = node["data"]["content"] a = f'<a href="../../{cid}/{nid}/">{a}</a>' return (nid, a, b) mystring = "" mystring2 = "" # Equal index for node in nodes: (nid, a, b) = read_node(node) if nid == index: # mystring2 += snippet(a, b, 1) # Don't add current node # change headertag for ind, myline in enumerate(mylines): new = f"""Topic: <a href="{index}-node.html">{node["data"]["label"]}</a>""" if f'<h1 id="headertag">NODE {index}</h1>' in myline: mylines[ind] = f' <h1 id="headertag">{new}</h1>' # Unequal index for node in nodes: (nid, a, b) = read_node(node) if nid != index: if match_edge(nid) == "s": mystring += snippet(a, b) elif match_edge(nid) == "t": mystring2 += snippet(a, b) # Equal index for node in nodes: (nid, a, b) = read_node(node) if nid == index: # mystring += snippet(a, b, 1) # Don't add current node pass preds = mystring succs = mystring2 # define fillers fillers = ["###TITLE###", "###DEC###", "###TIME###", "###CHAP###","###INDEX###", "###TABLEPRED###", "###TABLESUCC###", "###NOTES###", "###YTURLEND###", "###PODCAST###" ,"###ETHERLINK###", "###WEBWORKLINK###", "###NTABS###"] # put content into same order content = [title, content, timestamp, chapter, index, preds, succs,mynotes, youtubend, podcast, discussionlink, webworklink, str(ntabs)] for ind, myline in enumerate(mylines): for num, filler in enumerate(fillers): if filler in myline: mylines[ind] = myline.replace(filler, content[num]) # Write HTML with open(f"{index}.md", "w") as file: for element in mylines: # For each element in the list, file.write(element+"\n") bin/makejson.py 0 → 100644 +80 −0 Viewed Changes for bin/makejson.py: 80 added lines, 0 removed lines. Original line number Diff line number Diff line """Make xxx.json This script allows the user to create index.json for a given node in cyto.json input: (1) cyto.json (2) index as number output: index.json in console usage: python3 makejson.py cyto.json index > index/index.json """ import json import sys ## function: input: json, id , output: json in console print(json) import logging with open(sys.argv[1], 'r') as input: mydata = json.load(input) index = str(sys.argv[2]) # # Test # with open('../nodes/hr_cyto.json', 'r') as f: # mydata = json.load(f) # index = "108" nodes = mydata["nodes"] edges = mydata["edges"] # Check if index is in nodes try: mynode = nodes[index] except: logging.critical(f"The Node number {index} is missing in cyto.json!") sys.exit(1) def add_edge_attributes(edge): y = edge["target"] if y == index: edge["color"] = "#abe8ef" edge["style"] = "solid" else: edge["color"] = "#b8b8b8" edge["style"] = "dashed" def all_connections(node): node_id = node["id"] connections = [] real_nodes = [{"data": node}] # the order matters for the visualization # (group incoming and outgoing nodes) for edge in edges.values(): if edge["source"] == node_id: real_nodes.append(dict({"data": nodes[edge["target"]]})) nodes[edge["target"]]["color"] = "#b8b8b8" add_edge_attributes(edge) connections.append({"data":edge}) for edge in edges.values(): if edge["target"] == node_id: real_nodes.append(dict({"data": nodes[edge["source"]]})) nodes[edge["source"]]["color"] = "#abe8ef" add_edge_attributes(edge) connections.append({"data":edge}) return connections, real_nodes real_edges, real_nodes = all_connections(mynode) mydata2 = dict() mydata2["nodes"] = real_nodes mydata2["edges"] = real_edges # the json file where the output must be stored pretty_obj = json.dumps(mydata2, indent = 6) print(pretty_obj) .dockerignore 0 → 100644 +1 −0 Viewed Changes for .dockerignore: 1 added line, 0 removed lines. Original line number Diff line number Diff line * .gitlab-ci.yml +3 −3 Viewed Changes for .gitlab-ci.yml: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ review-app-build: - sed -i -e "s;/js/basic.js;${REVIEW_BASE_DIR}/${CI_COMMIT_REF_NAME}/js/basic.js;" layouts/shortcodes/header1.html - sed -i -e "s;/js/basic2.js;${REVIEW_BASE_DIR}/${CI_COMMIT_REF_NAME}/js/basic2.js;" layouts/shortcodes/header2.html - sed -i -e "s;/js/pontifex-tour.js;${REVIEW_BASE_DIR}/${CI_COMMIT_REF_NAME}/js/pontifex-tour.js;" layouts/shortcodes/header1.html - /pontifex/bin/build_pontifex.sh - bin/build_pontifex.sh artifacts: paths: - public Loading @@ -29,7 +29,7 @@ review-build: - sed -i -e "s;baseurl.*;baseurl = \"${REVIEW_BASE_DIR}/\";" config/production/config.toml - sed -i -e "s;/js/basic.js;${REVIEW_BASE_DIR}/js/basic.js;" layouts/shortcodes/header1.html - sed -i -e "s;/js/basic2.js;${REVIEW_BASE_DIR}/js/basic2.js;" layouts/shortcodes/header2.html - /pontifex/bin/build_pontifex.sh - bin/build_pontifex.sh artifacts: paths: - public Loading @@ -43,7 +43,7 @@ master-build: - sed -i -e "s;baseurl.*;baseurl = \"${BASE_DIR}/\";" config/production/config.toml - sed -i -e "s;/js/basic.js;${BASE_DIR}/js/basic.js;" layouts/shortcodes/header1.html - sed -i -e "s;/js/basic2.js;${BASE_DIR}/js/basic2.js;" layouts/shortcodes/header2.html - /pontifex/bin/build_pontifex.sh - bin/build_pontifex.sh artifacts: paths: - public Loading Loading
bin/build_pontifex.sh 0 → 100755 +61 −0 Viewed Changes for bin/build_pontifex.sh: 61 added lines, 0 removed lines. Original line number Diff line number Diff line #!/bin/bash # run this from the basedir of the hugo folder PONTIFEX_BASEDIR=`pwd` # use local bin folder if [ ! -n "${PONTIFEX_BIN}" ]; then PONTIFEX_BIN=`pwd`/bin fi echo "Using Preprocessing routines from PONTIFEX_BIN=${PONTIFEX_BIN}" BUILD_DIR=${PONTIFEX_BASEDIR}/content/en/docs INPUT_JSON="${PONTIFEX_BASEDIR}/nodes/cyto.json" jsonconverter="python3 ${PONTIFEX_BIN}/makejson.py" hugoconverter="python3 ${PONTIFEX_BIN}/makehugo.py" # Preprocessing echo "Creating files for nodes..." cd ${PONTIFEX_BASEDIR}/nodes for i in ??? do ## Pandoc mkdir -p $i touch $i/$i.tex #delete this line once all nodes have texfiles cp -f packs.tex $i/. #needed for pandoc processing pandoc -f latex -t html $i/$i.tex -o $i/$i-snippet.html --mathjax rm -f $i/packs.tex #cleanup ## JSON Files and HUGO $jsonconverter $INPUT_JSON $i > $i/$i.json $hugoconverter $i done # Copy to destination echo "Copying files to HUGO..." cd ${PONTIFEX_BASEDIR}/nodes for i in ??? do first=${i:0:1} mkdir -p ${BUILD_DIR}/chapter$first/$i cp $i/$i.json ${BUILD_DIR}/chapter$first/$i cp $i.md ${BUILD_DIR}/chapter$first/ done # Run Hugo echo "Running HUGO..." cd ${PONTIFEX_BASEDIR} npm install ./node_modules/.bin/hugo/hugo echo "Done!" echo "Run docker run -it --rm --name apache-server -p 8080:80 -v \`pwd\`/public:/usr/local/apache2/htdocs/ httpd:2.4-alpine and open up http://localhost:8080/ in order to view the webpage. "
bin/makehugo.py 0 → 100644 +153 −0 Viewed Changes for bin/makehugo.py: 153 added lines, 0 removed lines. Original line number Diff line number Diff line """Make hugo This script allows the user to put everything into a md-file for hugo input: (0) index = xxx (x) xxx.html (x) xxx.json output: xxx.md usage: python3 makehugo.py xxx """ import json import sys # function: input: index = xxx, output: - import logging test = 0 if test == 1: index = "100" path = f"../nodes/{index}/{index}" # test else: index = str(sys.argv[1]) path = f"{index}/{index}" with open(f"{path}.json", 'r') as input: mydata = json.load(input) nodes = mydata["nodes"] edges = mydata["edges"] mylines = [] # Declare an empty list. with open(f"../nodes/dummy_for_hugo.md", 'rt') as myfile: # open file for myline in myfile: # For each line in the file, mylines.append(myline.rstrip('\n')) # Read cyto with open('../nodes/cyto.json', 'r') as f: mydata = json.load(f) mynode = mydata["nodes"][index] # read content filename = mynode["notes"] videolink = mynode["video"] webworklink = mynode["webwork"] discussionlink = mynode["discussion"] title = mynode["label"].replace('\n',' ') content = mynode["content"] podcast = mynode["podcast"] timestamp = "2022-04-01T08:48:57+00:00" chapter = f"chapter{index[0]}" youtubend = videolink[videolink.find("embed")+6:] # preprocess podcast ntabs = 3 if podcast != "": ntabs = ntabs + 1 podcast = '{{< tab tabName="Podcast">}}\n'+ podcast + '\n{{< /tab >}}\n' # read notes with spaces in front of each line mynotes = "" with open(f"../nodes/{index}/{filename}", 'rt') as myfile2: for myline in myfile2: mynotes = mynotes + myline #preds and succs def match_edge(nid): """checks if edge has source or target as given id""" for edge in edges: if edge["data"]["source"] == nid: return "s" if edge["data"]["target"] == nid: return "t" def snippet(a, b, c=0): """takes input to put it into table form""" if c == 1: c = ' class="bg-danger"' else: c = '' string = f""" <tr{c}> <th scope="row">{a}</th> <td>{b}</td> </tr> """ return string def read_node(node): """gives id, label with link and content of a node""" nid = node["data"]["id"] cid = f"chapter{nid[0]}" a = node["data"]["label"] b = node["data"]["content"] a = f'<a href="../../{cid}/{nid}/">{a}</a>' return (nid, a, b) mystring = "" mystring2 = "" # Equal index for node in nodes: (nid, a, b) = read_node(node) if nid == index: # mystring2 += snippet(a, b, 1) # Don't add current node # change headertag for ind, myline in enumerate(mylines): new = f"""Topic: <a href="{index}-node.html">{node["data"]["label"]}</a>""" if f'<h1 id="headertag">NODE {index}</h1>' in myline: mylines[ind] = f' <h1 id="headertag">{new}</h1>' # Unequal index for node in nodes: (nid, a, b) = read_node(node) if nid != index: if match_edge(nid) == "s": mystring += snippet(a, b) elif match_edge(nid) == "t": mystring2 += snippet(a, b) # Equal index for node in nodes: (nid, a, b) = read_node(node) if nid == index: # mystring += snippet(a, b, 1) # Don't add current node pass preds = mystring succs = mystring2 # define fillers fillers = ["###TITLE###", "###DEC###", "###TIME###", "###CHAP###","###INDEX###", "###TABLEPRED###", "###TABLESUCC###", "###NOTES###", "###YTURLEND###", "###PODCAST###" ,"###ETHERLINK###", "###WEBWORKLINK###", "###NTABS###"] # put content into same order content = [title, content, timestamp, chapter, index, preds, succs,mynotes, youtubend, podcast, discussionlink, webworklink, str(ntabs)] for ind, myline in enumerate(mylines): for num, filler in enumerate(fillers): if filler in myline: mylines[ind] = myline.replace(filler, content[num]) # Write HTML with open(f"{index}.md", "w") as file: for element in mylines: # For each element in the list, file.write(element+"\n")
bin/makejson.py 0 → 100644 +80 −0 Viewed Changes for bin/makejson.py: 80 added lines, 0 removed lines. Original line number Diff line number Diff line """Make xxx.json This script allows the user to create index.json for a given node in cyto.json input: (1) cyto.json (2) index as number output: index.json in console usage: python3 makejson.py cyto.json index > index/index.json """ import json import sys ## function: input: json, id , output: json in console print(json) import logging with open(sys.argv[1], 'r') as input: mydata = json.load(input) index = str(sys.argv[2]) # # Test # with open('../nodes/hr_cyto.json', 'r') as f: # mydata = json.load(f) # index = "108" nodes = mydata["nodes"] edges = mydata["edges"] # Check if index is in nodes try: mynode = nodes[index] except: logging.critical(f"The Node number {index} is missing in cyto.json!") sys.exit(1) def add_edge_attributes(edge): y = edge["target"] if y == index: edge["color"] = "#abe8ef" edge["style"] = "solid" else: edge["color"] = "#b8b8b8" edge["style"] = "dashed" def all_connections(node): node_id = node["id"] connections = [] real_nodes = [{"data": node}] # the order matters for the visualization # (group incoming and outgoing nodes) for edge in edges.values(): if edge["source"] == node_id: real_nodes.append(dict({"data": nodes[edge["target"]]})) nodes[edge["target"]]["color"] = "#b8b8b8" add_edge_attributes(edge) connections.append({"data":edge}) for edge in edges.values(): if edge["target"] == node_id: real_nodes.append(dict({"data": nodes[edge["source"]]})) nodes[edge["source"]]["color"] = "#abe8ef" add_edge_attributes(edge) connections.append({"data":edge}) return connections, real_nodes real_edges, real_nodes = all_connections(mynode) mydata2 = dict() mydata2["nodes"] = real_nodes mydata2["edges"] = real_edges # the json file where the output must be stored pretty_obj = json.dumps(mydata2, indent = 6) print(pretty_obj)
.dockerignore 0 → 100644 +1 −0 Viewed Changes for .dockerignore: 1 added line, 0 removed lines. Original line number Diff line number Diff line *
.gitlab-ci.yml +3 −3 Viewed Changes for .gitlab-ci.yml: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ review-app-build: - sed -i -e "s;/js/basic.js;${REVIEW_BASE_DIR}/${CI_COMMIT_REF_NAME}/js/basic.js;" layouts/shortcodes/header1.html - sed -i -e "s;/js/basic2.js;${REVIEW_BASE_DIR}/${CI_COMMIT_REF_NAME}/js/basic2.js;" layouts/shortcodes/header2.html - sed -i -e "s;/js/pontifex-tour.js;${REVIEW_BASE_DIR}/${CI_COMMIT_REF_NAME}/js/pontifex-tour.js;" layouts/shortcodes/header1.html - /pontifex/bin/build_pontifex.sh - bin/build_pontifex.sh artifacts: paths: - public Loading @@ -29,7 +29,7 @@ review-build: - sed -i -e "s;baseurl.*;baseurl = \"${REVIEW_BASE_DIR}/\";" config/production/config.toml - sed -i -e "s;/js/basic.js;${REVIEW_BASE_DIR}/js/basic.js;" layouts/shortcodes/header1.html - sed -i -e "s;/js/basic2.js;${REVIEW_BASE_DIR}/js/basic2.js;" layouts/shortcodes/header2.html - /pontifex/bin/build_pontifex.sh - bin/build_pontifex.sh artifacts: paths: - public Loading @@ -43,7 +43,7 @@ master-build: - sed -i -e "s;baseurl.*;baseurl = \"${BASE_DIR}/\";" config/production/config.toml - sed -i -e "s;/js/basic.js;${BASE_DIR}/js/basic.js;" layouts/shortcodes/header1.html - sed -i -e "s;/js/basic2.js;${BASE_DIR}/js/basic2.js;" layouts/shortcodes/header2.html - /pontifex/bin/build_pontifex.sh - bin/build_pontifex.sh artifacts: paths: - public Loading