Skip to content

Commit

Permalink
Merge pull request #91 from NREL/FixDiffPages
Browse files Browse the repository at this point in the history
Use new JS diff engine
  • Loading branch information
Myoldmopar authored Aug 4, 2022
2 parents 212d62a + 15088d8 commit b3f163c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
pack_tool: tar -zcvf
extension: .tar.gz
pack_suffix: -C dist runner
- os: macos-10.15
- os: macos-11
python: python3
pip_arg: ""
nosetests_args: ""
Expand Down
71 changes: 28 additions & 43 deletions epregressions/diffs/ci_compare_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# add the root of the repo to the python path so it can find things relative to it like the epregressions package
from os.path import dirname, realpath

sys.path.append(os.path.join(dirname(realpath(__file__)), '..', '..'))

from epregressions.builds.install import EPlusInstallDirectory
Expand Down Expand Up @@ -45,7 +46,6 @@ def process_diffs(diff_name, diffs, this_has_diffs, this_has_small_diffs):


def main_function(file_name, base_dir, mod_dir, base_sha, mod_sha, make_public, device_id, test_mode):

print("Device id: %s" % device_id)

# build type really doesn't matter, so use the simplest one, the E+ install
Expand Down Expand Up @@ -257,55 +257,40 @@ def main_function(file_name, base_dir, mod_dir, base_sha, mod_sha, make_public,
# print("Processing output file: {0}, uploading to: {1}".format(filepath_to_send, filepath))

key = boto.s3.key.Key(bucket, file_path)
file_to_send = open(file_path_to_send, 'r')
key.set_contents_from_string(file_to_send.read())

if make_public:
key.make_public()

htmlkey = boto.s3.key.Key(bucket, file_path + ".html")
htmlkey.set_contents_from_string("""
with open(file_path_to_send, 'r') as file_to_send:
contents = file_to_send.read()
key.set_contents_from_string(contents)

if make_public:
key.make_public()

htmlkey = boto.s3.key.Key(bucket, file_path + ".html")

if file_path_to_send.endswith('.htm'):
htmlkey.set_contents_from_string(
contents,
headers={"Content-Type": "text/html", "Content-Disposition": "inline"}
)
else:
htmlkey.set_contents_from_string(
"""
<!doctype html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<link href="//alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css" />
<link href="//alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css" rel="stylesheet" type="text/css" />
<script src="//alexgorbatchev.com/pub/sh/current/scripts/shCore.js" type="text/javascript"></script>
<script src="//alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js" type="text/javascript"></script>
<script src="//alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js" type="text/javascript"></script>
<script src="//alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js" type="text/javascript"></script>
<script src="//alexgorbatchev.com/pub/sh/current/scripts/shBrushDiff.js" type="text/javascript"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/languages/diff.min.js"></script>
</head>
<body>
<script>
filename = '/""" + file_path + """'
</script>
<div id="codeholder">
</div>
<script>
$.get(filename , function( data ) {
elem = document.createElement("pre");
brush = "plain";
if (filename.indexOf(".dif") != -1)
{
brush = "diff";
}
elem.setAttribute("class", "brush: " + brush + "; gutter: true;");
elem.appendChild(document.createTextNode(data.replace("<", "&lt;")));
document.getElementById("codeholder").appendChild(elem);
SyntaxHighlighter.highlight(elem);
});
SyntaxHighlighter.all();
</script>
<pre><code class="diff">
""" + contents + """
</code></pre>
<script>hljs.highlightAll();</script>
</body>
</html>
""", headers={"Content-Type": "text/html"})
""",
headers={"Content-Type": "text/html"}
)

if make_public:
htmlkey.make_public()
Expand Down

0 comments on commit b3f163c

Please sign in to comment.