diasporadiaries

a platform for writing stories with personal accounts and messages
git clone https://git.parazyd.org/diasporadiaries
Log | Files | Refs | Submodules | README | LICENSE

edit.html (5332B)


      1 {% include 'header.html' %}
      2 
      3   <title>Edit | Diaspora Diaries</title>
      4 
      5   <link href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote-bs4.css" rel="stylesheet">
      6   <script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote-bs4.js"></script>
      7   <script src="/static/js/summernote-cleaner.js"></script>
      8 
      9   <script>
     10     function countryCheck(that, idname) {
     11       if (that.value == "nn") {
     12         document.getElementById(idname).style.display = "inline";
     13       } else {
     14         document.getElementById(idname).style.display = "none";
     15       }
     16     }
     17   </script>
     18 
     19 {% include 'nav.html' %}
     20 
     21   <main role="main" class="container">
     22 
     23    {% if current_user.is_admin %}
     24     <p>
     25       <button type="button" class="btn btn-outline-danger" data-toggle="modal" data-target="#deleteModal">
     26         Delete this story
     27       </button>
     28     </p>
     29 
     30     <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalTitle" aria-hidden="true">
     31       <div class="modal-dialog modal-dialog-centered" role="document">
     32         <div class="modal-content">
     33           <div class="modal-header">
     34             <h5 class="modal-title" id="deleteModalLongTitle">Delete story?</h5>
     35             <button type="button" class="close" data-dismiss="modal" aria-label="Close">
     36               <span aria-hidden="true">&times;</span>
     37             </button>
     38           </div>
     39           <div class="modal-body">
     40             <p>Are you sure you wish to delete this story?</p>
     41           </div>
     42           <div class="modal-footer">
     43             <button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button>
     44             <a href="/delete?key={{ story['deletekey'] }}" class="btn btn-outline-danger">Delete</a>
     45           </div>
     46         </div>
     47       </div>
     48     </div>
     49     {% endif %}
     50 
     51     <form action="/edit" method="POST" id="storyform">
     52       <div class="form-group">
     53         <input type="hidden" name="Id" value="{{ story['id'] }}">
     54 
     55         <p class="lead">Name:<br>
     56           <input type="text" class="form-control" name="Name" required value="{{ story['name'] }}">
     57         </p>
     58 
     59         <p class="lead">Country of embarkment:<br>
     60           <select name="Embark" class="form-control" form="storyform" onchange="countryCheck(this, 'embarkother');" id="embarkbox">
     61           <option value="{{ story['embark']}}">{{ story['embarkname'] }}</option>
     62           </select>
     63           <input type="text" class="form-control" name="EmbarkOther" id="embarkother" style="display: none;" placeholder="Type country here">
     64         </p>
     65 
     66         <p class="lead">Country of disembarkment:<br>
     67           <select name="Disembark" class="form-control" form="storyform" onchange="countryCheck(this, 'disembarkother');" selected="{{ story['disembark'] }}">
     68           <option value="{{ story['disembark'] }}">{{ story['disembarkname'] }}</option>
     69           </select>
     70           <input type="text" class="form-control" name="DisembarkOther" id="disembarkother" style="display: none;" placeholder="Type country here">
     71         </p>
     72 
     73         <p class="lead">City of the story:<br>
     74           <input type="text" class="form-control" name="City" value="{{ story['city'] }}">
     75         </p>
     76 
     77         {% if current_user.is_admin %}
     78         <p class="lead">Email:<br>
     79           <input type="email" class="form-control" name="Email" value="{{ story['email'] }}">
     80         </p>
     81         {% endif %}
     82 
     83         <p class="lead">Story abstract:<br>
     84           <textarea name="Abstract" class="form-control" form="storyform">{{ story['abstract'] }}</textarea>
     85         </p>
     86 
     87         <p class="lead">The story:<br>
     88            <textarea id="storytext" name="Story" form="storyform" required>{{ story['story'] }}</textarea>
     89         </p>
     90 
     91         <input type="submit" class="btn btn-outline-primary" value="Submit">
     92       </div>
     93     </form>
     94 
     95   </main>
     96 
     97   <script>
     98     $('.summernote').summernote({
     99       toolbar:[
    100         ['cleaner',['cleaner']], // The Button
    101         ['style',['style']],
    102         ['font',['bold','underline','clear']],
    103         ['fontname',['fontname']],
    104         ['color',['color']],
    105         ['para',['ul','ol','paragraph']],
    106         ['height',['height']],
    107         ['table',['table']],
    108         ['insert',['media','link','hr']],
    109         ['view',['fullscreen','codeview']],
    110         ['help',['help']]
    111       ],
    112       cleaner:{
    113         action: 'both', // both|button|paste
    114         newline: '<br>', // Summernote's default is to use '<p><br></p>'
    115         notStyle: 'position:absolute;top:0;left:0;right:0', // Position of Notification
    116         icon: '<i class="note-icon">[Your Button]</i>',
    117         keepHtml: false, // Remove all Html formats
    118         keepOnlyTags: ['<p>', '<br>', '<ul>', '<li>', '<b>', '<strong>','<i>', '<a>'], // If keepHtml is true, remove all tags except these
    119         keepClasses: false, // Remove Classes
    120         badTags: ['style', 'script', 'applet', 'embed', 'noframes', 'noscript', 'html'], // Remove full tags with contents
    121         badAttributes: ['style', 'start'], // Remove attributes from remaining tags
    122         limitChars: false, // 0/false|# 0/false disables option
    123         limitDisplay: 'both', // text|html|both
    124         limitStop: false // true/false
    125       }
    126     });
    127 
    128     $(document).ready(function() {
    129       $('#storytext').summernote();
    130     });
    131   </script>
    132 {% include 'footer.html' %}