#4034 Fix viewing patch attached to ticket
Merged 5 years ago by pingou. Opened 5 years ago by pingou.

@@ -3,6 +3,16 @@ 

  {% block title %}Patch File - {{

      repo.namespace + '/' if repo.namespace }}{{ repo.name }} {% endblock %}

  

+ {% block header %}

+ <link href="{{ url_for('static', filename='vendor/highlight.js/styles/github.css') }}?version={{ g.version}}"

+   rel="stylesheet" />

+ <style>

+   .hljs {

+     background: #fff;

+   }

+ </style>

+ {% endblock %}

+ 

  {% block repo %}

  <ul class="nav nav-tabs nav-small border-bottom-0" role="tablist" id="pr-tabs">

    <li class="nav-item pull-xs-right">
@@ -15,9 +25,9 @@ 

    <strong>{{ patchfile }}</strong>

  </div>

  <div class="card card-block">

-   {% autoescape false %}

-     {{ diff }}

-   {% endautoescape %}

+   <div class="card-body p-0">

+     <pre class="syntaxhighlightblock"><code>{{ diff }}</code></pre>

+   </div>

  </div>

  <p>

    <a href="{{ request.base_url + '?raw=1' }}">View Raw</a>
@@ -26,4 +36,18 @@ 

  

  {% block jscripts %}

    {{ super() }}

+ <script type="text/javascript"

+   src="{{ url_for('static', filename='vendor/highlight.js/highlight.pack.js') }}?version={{ g.version}}"></script>

+ <script src="{{ url_for('static', filename='vendor/highlightjs-line-numbers/highlightjs-line-numbers.min.js') }}?version={{ g.version}}"></script>

+ <script type="text/javascript"

+   src="{{ url_for('static', filename='vendor/highlight.js/spec.js') }}?version={{ g.version}}"></script>

+ 

+ <script>

+   $(document).ready(function() {

+   $('pre.syntaxhighlightblock code').each(function(i, block) {

+     hljs.highlightBlock(block);

+     hljs.lineNumbersBlock(block);

+   })

+ });

+ </script>

  {% endblock %}

file modified
+1 -1
@@ -1470,7 +1470,7 @@ 

              select="issues",

              repo=repo,

              username=username,

-             diff=data,

+             diff=data.decode('utf-8'),

              patchfile=orig_filename,

          )

  

Convert the bytes into a valid string and use highlight.js to render it
nicely as in the same way we are using highlight.js to render nicely
files in the repo.

Fixes https://pagure.io/pagure/issue/3822

rebased onto 0bf02f08fa82cd7456b15171d4c74ac302f6a639

5 years ago

rebased onto 4ec0e47

5 years ago

Thanks for the review :)

Pull-Request has been merged by pingou

5 years ago