Skip to content

Commit

Permalink
replace showdown with highlight + markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Aug 3, 2019
1 parent 43331e2 commit 648a10b
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ app/assets/v2/js/event_ethdenver2019/blockies.js
app/assets/v2/js/lib/ipfs-api.js
app/assets/v2/js/lib/jquery*.js
app/assets/v2/js/lib/jsrender.js
app/assets/v2/js/lib/showdown.js
app/assets/v2/js/lib/markdown-it.js
app/assets/v2/js/lib/highlight.js
app/assets/v2/js/lib/tooltip.js
app/assets/v2/js/lib/tweenlite.js
app/assets/v2/js/abi.js
Expand Down
1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ app/assets/v2/css/jquery.select2.min.css
app/assets/v2/css/bootstrap.min.css
app/assets/v2/js/lib/tweenlite.js
app/assets/v2/js/abi.js
app/assets/v2/css/highlight_github.css
10 changes: 3 additions & 7 deletions app/assets/v2/css/bounty.css
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ body {
color: #000000;
}

#issue_description pre, code {
/* #issue_description pre, code {
padding: 1em 0;
}
} */

#bounty-info-row {
margin-left: 1px;
Expand Down Expand Up @@ -529,11 +529,6 @@ a.btn {
color: #F5A623;
}

.code-snippet {
background-color: #F2F6F9;
padding: 1rem;
}

#funder_notif_info .bounty-notification {
border: orange 1px solid;
border-radius: 3px;
Expand Down Expand Up @@ -737,6 +732,7 @@ a.btn {
.modal .magnify {
width: auto;
max-width: 100%;
overflow-y: scroll;
}

.bg-container {
Expand Down
1 change: 1 addition & 0 deletions app/assets/v2/css/highlight_github.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions app/assets/v2/js/lib/highlight.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/assets/v2/js/lib/markdown-it.js

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions app/assets/v2/js/lib/showdown.js

This file was deleted.

34 changes: 22 additions & 12 deletions app/assets/v2/js/pages/bounty_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,24 @@ var callbacks = {
return [ 'status', ui_status ];
},
'issue_description': function(key, val, result) {
var converter = new showdown.Converter({
simplifiedAutoLink: true
});

ui_body = sanitize(converter.makeHtml(val));
const _markdown = new markdownit({
linkify: true,
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
return '<pre class="hljs"><code>' +
hljs.highlight(lang, str, true).value +
'</code></pre>';
} catch (__) {}
}
return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
}
})
_markdown.renderer.rules.table_open = function() {
return '<table class="table">';
};
ui_body = sanitize(_markdown.render(val));
return [ 'issue_description', ui_body ];
},
'bounty_owner_address': address_ize,
Expand Down Expand Up @@ -905,11 +918,10 @@ var build_detail_page = function(result) {
_result = callbacks[key](key, val, result);
val = _result[1];
}
var _entry = {
'head': head,
'key': key,
'val': val
};

hljs.initHighlighting.called = false;
hljs.initHighlighting();

var id = '#' + key;

if ($(id).length) {
Expand All @@ -931,12 +943,10 @@ var build_detail_page = function(result) {
'</div>' +
'<div class="col-12 pt-2 pb-2"><img class="magnify" src="' + $(this).attr('src') + '"/></div></div></div>');

var modal = $(content).appendTo('body').modal({
$(content).appendTo('body').modal({
modalClass: 'modal magnify'
});
});

$('#bounty_details #issue_description code').parent().addClass('code-snippet');
};

const is_current_user_interested = function(result) {
Expand Down
11 changes: 6 additions & 5 deletions app/dashboard/templates/bounty/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<link rel="stylesheet" href="{% static "v2/css/bounty.css" %}">
<link rel="stylesheet" href="{% static "v2/css/user_popover.css" %}">
<link rel="stylesheet" href="{% static "v2/css/tag.css" %}">
<link rel="stylesheet" href="{% static "v2/css/highlight_github.css" %}">
</head>

<body class="interior {{active}} g-font-muli">
Expand Down Expand Up @@ -438,19 +439,19 @@ <h5 class="bounty-heading">{% trans "Funder" %}</h5>
{% endif %}
</script>

<!-- jQuery -->
<script src="{% static "v2/js/lib/showdown.js" %}"></script>
<script src="{% static "v2/js/lib/highlight.js" %}"></script>
<script src="{% static "v2/js/lib/markdown-it.js" %}"></script>

<script src="{% static "v2/js/abi.js" %}"></script>
<script src="/dynamic/js/tokens_dynamic.js"></script>
<script src="{% static "v2/js/tokens.js" %}"></script>
<script src="{% static "v2/js/amounts.js" %}"></script>
<script src="{% static "v2/js/clipboard.js" %}"></script>>
<script src="{% static "v2/js/clipboard.js" %}"></script>
<script>
$('[data-toggle="popover"]').popover()

$("body").on("mouseover", "[data-username] img", function(e) {
openContributorPopOver($(this).parent().data("username"), $(this));
});
});
</script>
<script src="{% static "v2/js/pages/bounty_funder_payout_reminder.js" %}"></script>
<script src="{% static "v2/js/pages/bounty_share.js" %}"></script>
Expand Down

0 comments on commit 648a10b

Please sign in to comment.