From 67b178da81307bdaded62db099082354d7d33e5f Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Feb 05 2016 21:19:40 +0000
Subject: [PATCH 1/3] Indentation fixes


---

diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html
index ee22e92..996538a 100644
--- a/pagure/templates/_formhelper.html
+++ b/pagure/templates/_formhelper.html
@@ -13,41 +13,41 @@
 {% endmacro %}
 
 {% macro render_bootstrap_field(field, field_description="", formclass="") %}
-            <fieldset class="form-group {% if field.errors %}has-error{% endif %} {% if formclass %}issue-metadata-form{% endif %}">
-              {% set formclasses = "form-control"%}
-              {% if field.errors %} {% set formclasses = formclasses + " form-control-error" %} {% endif %}
-              {% if field.type == "SelectField" %} {% set formclasses = formclasses + " c-select" %} {% endif %}
+  <fieldset class="form-group {% if field.errors %}has-error{% endif %} {% if formclass %}issue-metadata-form{% endif %}">
+    {% set formclasses = "form-control"%}
+    {% if field.errors %} {% set formclasses = formclasses + " form-control-error" %} {% endif %}
+    {% if field.type == "SelectField" %} {% set formclasses = formclasses + " c-select" %} {% endif %}
 
-              {% if field.type == 'BooleanField' %}
-                {% set formclasses = formclasses + " checkbox-inline" %}
-                  <label class="c-input c-checkbox">
-                    {{ field(type='checkbox', **kwargs) }}
-                    <span class="c-indicator"></span>
-                    <strong>{{ field.label }}</strong>
-                  </label>
-                  </br>
-                  {% if field_description %}
-                    <small class="text-muted">{{ field_description }}</small>
-                  {% endif %}
-              {% else %}
-                <strong>{{ field.label }}</strong>
-                {{ field(class_=formclasses)|safe }}
-                <div>
-                  {% if field_description %}
-                    <small class="text-muted">{{field_description}}</small>
-                  {% endif %}
-                  {% if field.errors %}
-                  <span class="pull-xs-right text-danger">
-                    <small>
-                    {% for error in field.errors %}
-                      {{ error }}&nbsp;
-                    {% endfor %}
-                    </small>
-                  </span>
-                  {% endif %}
-                </div>
-              {% endif %}
-            </fieldset>
+    {% if field.type == 'BooleanField' %}
+      {% set formclasses = formclasses + " checkbox-inline" %}
+        <label class="c-input c-checkbox">
+          {{ field(type='checkbox', **kwargs) }}
+          <span class="c-indicator"></span>
+          <strong>{{ field.label }}</strong>
+        </label>
+        </br>
+        {% if field_description %}
+          <small class="text-muted">{{ field_description }}</small>
+        {% endif %}
+    {% else %}
+      <strong>{{ field.label }}</strong>
+      {{ field(class_=formclasses)|safe }}
+      <div>
+        {% if field_description %}
+          <small class="text-muted">{{field_description}}</small>
+        {% endif %}
+        {% if field.errors %}
+        <span class="pull-xs-right text-danger">
+          <small>
+          {% for error in field.errors %}
+            {{ error }}&nbsp;
+          {% endfor %}
+          </small>
+        </span>
+        {% endif %}
+      </div>
+    {% endif %}
+  </fieldset>
 {% endmacro %}
 
 (class_="c-select")
@@ -105,17 +105,18 @@
 {% macro show_comment(comment, id, repo, username, issueid, form, repo_admin) %}
 <div class="card clearfix">
   <div id="comment-{{ id }}" class="card-header">
-        {{ comment.user.default_email | avatar(16) | safe }}
-        <a href="{{ url_for('view_user', username=comment.user.user)}}">
-          {{ comment.user.user }}
-        </a> <a class="headerlink pull-xs-right" title="Permalink to this headline"
-          href="#comment-{{ id }}"><span title="{{
-          comment.date_created.strftime('%Y-%m-%d %H:%M:%S')
-          }}">{{ comment.date_created | humanize}}</span>
-</a>
+    {{ comment.user.default_email | avatar(16) | safe }}
+    <a href="{{ url_for('view_user', username=comment.user.user)}}">
+      {{ comment.user.user }}
+    </a>
+    <a class="headerlink pull-xs-right" title="Permalink to this headline"
+      href="#comment-{{ id }}">
+      <span title="{{
+        comment.date_created.strftime('%Y-%m-%d %H:%M:%S')
+        }}">{{ comment.date_created | humanize}}</span>
+    </a>
   </div>
   <div class="card-block">
-
     <section class="issue_comment">
       <div>
         <span class="edit_date" title="{{
@@ -146,20 +147,19 @@
               (comment.parent.status in [True, 'Open'] and g.fas_user.username == comment.user.username)
               or repo_admin) %}
           <a class="btn btn-secondary btn-sm" href="{{ '%s/comment/%s/edit' % (request.base_url, comment.id) }}"
-              class="edit_btn" data-comment="{{ comment.id }}"
-              data-objid="{{ issueid }}">
-              <span class="oi" data-glyph="pencil"></span>
+            class="edit_btn" data-comment="{{ comment.id }}"
+            data-objid="{{ issueid }}">
+            <span class="oi" data-glyph="pencil"></span>
           </a>
           {% endif %}
           {% if id != 0 and g.fas_user and (
               (comment.parent.status in [True, 'Open'] and g.fas_user.username == comment.user.username)
               or repo_admin) %}
           <button class="btn btn-secondary btn-sm" type="submit" name="drop_comment" value="{{ comment.id }}"
-              onclick="return confirm('Do you really want to remove this comment?');"
-              title="Remove comment">
-              <span class="oi" data-glyph="trash"></span>
+            onclick="return confirm('Do you really want to remove this comment?');"
+            title="Remove comment">
+            <span class="oi" data-glyph="trash"></span>
           </button>
-
           {% endif %}
         </div>
       </div>
@@ -171,24 +171,24 @@
 
 {% macro show_initial_comment(comment, username, repo, issueid, repo_admin) %}
 <div class="clearfix p-b-3">
-    <section class="issue_comment" id="comment-0">
-      <div class="comment_body">
-        {%- autoescape false -%}
+  <section class="issue_comment" id="comment-0">
+    <div class="comment_body">
+      {%- autoescape false -%}
 {{ comment.content | markdown }}
-        {%- endautoescape -%}
-      </div>
-    </section>
-        <aside class="issue_action icon pull-xs-right">
-          <a class="btn btn-secondary btn-sm reply"
-            title="Reply to this comment - loose formating">
-            reply
-          </a>
-      {% if repo_admin or (
-            g.fas_user and g.fas_user.username == comment.user.username) %}
-      <a class="btn btn-secondary btn-sm" href="{{ url_for('edit_issue', username=username,
-                    repo=repo.name, issueid=issueid) }}">
-          edit</a>
-      {% endif %}
-        </aside>
+      {%- endautoescape -%}
+    </div>
+  </section>
+  <aside class="issue_action icon pull-xs-right">
+    <a class="btn btn-secondary btn-sm reply"
+      title="Reply to this comment - loose formating">
+      reply
+    </a>
+    {% if repo_admin or (
+      g.fas_user and g.fas_user.username == comment.user.username) %}
+    <a class="btn btn-secondary btn-sm" href="{{ url_for('edit_issue', username=username,
+              repo=repo.name, issueid=issueid) }}">
+    edit</a>
+    {% endif %}
+  </aside>
 </div>
 {% endmacro %}
diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html
index de2c328..6b1edc3 100644
--- a/pagure/templates/issue.html
+++ b/pagure/templates/issue.html
@@ -65,7 +65,7 @@
               </span>
             </small>
             <textarea class="form-control" rows=8 id="comment" name="comment"
-            placeholder="Enter your comment here" tabindex=1></textarea>
+                placeholder="Enter your comment here" tabindex=1></textarea>
 
             <div id="preview">
             </div>
@@ -100,12 +100,12 @@
     <div class="card">
       <div class="card-block">
       {% if authenticated and form %}
-  <form action="{{ url_for('update_issue', username=username,
+        <form action="{{ url_for('update_issue', username=username,
            repo=repo.name, issueid=issueid) }}" method="post"
            onsubmit="return try_async_comment(this)"
            enctype="multipart/form-data">
-  {{ form.csrf_token }}
-          {% endif %}
+        {{ form.csrf_token }}
+      {% endif %}
 
           <fieldset class="form-group issue-metadata-display">
             <label><strong>Status</strong></label>
@@ -189,10 +189,10 @@
           </fieldset>
 
           {% if authenticated and repo_admin %}
-                <fieldset class="form-group issue-metadata-form">
-                  <label for="depends"><strong>Depends on</strong></label>
-                  <input class="form-control" id="depends" type="text" placeholder="issue depending" name="depends" value="{{ issue.depends_text | join(',') }}">
-                </fieldset>
+            <fieldset class="form-group issue-metadata-form">
+              <label for="depends"><strong>Depends on</strong></label>
+              <input class="form-control" id="depends" type="text" placeholder="issue depending" name="depends" value="{{ issue.depends_text | join(',') }}">
+            </fieldset>
           {% endif%}
 
           <input type="submit" class="btn btn-primary issue-metadata-form" value="Update">

From a02e40113d516598e8f50e8a26dd54f92fd23620 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Feb 05 2016 21:19:40 +0000
Subject: [PATCH 2/3] Add a link to the markdown syntax near the input fields for comments


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

---

diff --git a/pagure/templates/issue.html b/pagure/templates/issue.html
index 6b1edc3..0417899 100644
--- a/pagure/templates/issue.html
+++ b/pagure/templates/issue.html
@@ -78,13 +78,17 @@
               <div id="progress-bar" class="progress-bar">0%</div>
             </div>
           </fieldset>
+          <a href="http://daringfireball.net/projects/markdown/syntax"
+             target="_blank">Markdown Syntax</a>
           <input type="hidden" name="tag" value="{{ issue.tags_text | join(',') }}" >
           <input type="hidden" name="assignee" value="{{ issue.assignee.username or '' }}" >
           <input type="hidden" name="blocks" value="{{ issue.blocks_text | join(',') }}">
           <input type="hidden" name="depends" value="{{ issue.depends_text | join(',') }}">
             <div>
-              <input type="submit" class="btn btn-primary" value="Update Issue" tabindex=2 />
-              <input type="button" class="btn btn-secondary" value="Clear" id="clear_comment" tabindex=4 />
+              <input type="submit" class="btn btn-primary"
+                value="Update Issue" tabindex=2 />
+              <input type="button" class="btn btn-secondary"
+                value="Clear" id="clear_comment" tabindex=4 />
             </div>
         </form>
         {% else %}
diff --git a/pagure/templates/pull_request.html b/pagure/templates/pull_request.html
index a6aebbe..4ab71ea 100644
--- a/pagure/templates/pull_request.html
+++ b/pagure/templates/pull_request.html
@@ -341,14 +341,18 @@
                   </span>
                 </small>
                 <textarea class="form-control" rows=8 id="comment" name="comment"
-                placeholder="Enter your comment here"></textarea>
+                placeholder="Enter your comment here" tabindex=1></textarea>
                 <div id="preview">
                 </div>
               </fieldset>
 
+              <a href="http://daringfireball.net/projects/markdown/syntax"
+                 target="_blank">Markdown Syntax</a>
               <div>
-                <input type="submit" class="btn btn-primary" value="Update Issue">
-                <input type="button" class="btn btn-secondary" value="Clear" id="clear_comment" />
+                <input type="submit" class="btn btn-primary"
+                  value="Update Issue" tabindex=2 />
+                <input type="button" class="btn btn-secondary" value="Clear"
+                  id="clear_comment" tabindex=3 />
               </div>
             </form>
           {% else %}

From c3b75f5636e39a5e1b7e0887a4298ebcac15786c Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: Feb 05 2016 21:19:40 +0000
Subject: [PATCH 3/3] Adjust unit-tests for the change in indentation in the HTML


---

diff --git a/tests/test_pagure_flask_ui_app.py b/tests/test_pagure_flask_ui_app.py
index fcd5ded..c15c844 100644
--- a/tests/test_pagure_flask_ui_app.py
+++ b/tests/test_pagure_flask_ui_app.py
@@ -161,23 +161,24 @@ class PagureFlaskApptests(tests.Modeltests):
             self.assertEqual(output.status_code, 200)
             self.assertIn('<strong>Create new Project</strong>', output.data)
             self.assertIn(
-                '<small>\n                      This field is required.'
-                '&nbsp;\n                    </small>', output.data)
+                '<small>\n            This field is required.&nbsp;\n'
+                '          </small>', output.data)
 
             data['name'] = 'project-1'
             output = self.app.post('/new/', data=data)
             self.assertEqual(output.status_code, 200)
             self.assertIn('<strong>Create new Project</strong>', output.data)
             self.assertNotIn(
-                '<small>\n                      This field is required.'
-                '&nbsp;\n                    </small>', output.data)
+                '<small>\n            This field is required.&nbsp;\n'
+                '          </small>', output.data)
 
             data['csrf_token'] =  csrf_token
             output = self.app.post('/new/', data=data)
             self.assertEqual(output.status_code, 200)
             self.assertIn('<strong>Create new Project</strong>', output.data)
             self.assertIn(
-                '</button>\n                      No user &#34;username&#34; found',
+                '</button>\n                      No user '
+                '&#34;username&#34; found\n                    </div>',
                 output.data)
 
         user.username = 'foo'
diff --git a/tests/test_pagure_flask_ui_issues.py b/tests/test_pagure_flask_ui_issues.py
index e093181..fab24c2 100644
--- a/tests/test_pagure_flask_ui_issues.py
+++ b/tests/test_pagure_flask_ui_issues.py
@@ -1163,11 +1163,11 @@ class PagureFlaskIssuestests(tests.Modeltests):
                 '<div class="card-header">\n        Edit '
                 'issue #1\n      </div>' in output.data)
             self.assertEqual(output.data.count(
-                '<small>\n                      This field is required'
-                '.&nbsp;\n                    </small>'), 1)
+                '<small>\n            This field is required.&nbsp;\n'
+                '          </small>'), 1)
             self.assertEqual(output.data.count(
-                '<small>\n                      Not a valid choice'
-                '&nbsp;\n                    </small>'), 1)
+                '<small>\n            Not a valid choice&nbsp;'
+                '\n          </small>'), 1)
 
             data['status'] = 'Open'
             data['title'] = 'Test issue #1'
@@ -1177,11 +1177,11 @@ class PagureFlaskIssuestests(tests.Modeltests):
                 '<div class="card-header">\n        Edit '
                 'issue #1\n      </div>' in output.data)
             self.assertEqual(output.data.count(
-                '<small>\n                      This field is required'
-                '.&nbsp;\n                    </small>'), 0)
+                '<small>\n            This field is required.&nbsp;\n'
+                '          </small>'), 0)
             self.assertEqual(output.data.count(
-                '<small>\n                      Not a valid choice'
-                '.&nbsp;\n                    </small>'), 0)
+                '<small>\n            Not a valid choice&nbsp;'
+                '\n          </small>'), 0)
 
             data['csrf_token'] = csrf_token
             output = self.app.post(

