<commit_before>extends layout


mixin leftcolumn
  if (params.right_lang =="--")
    .col-md-10
      if block
        block
      else
        p No Content provided
  else
    .col-md-5
      if block
        block
      else
        p No Content provided

mixin rightcolumn
  if (params.right_lang !="--")
    .col-md-5
      if block
        block
      else
        p No Content provided
  else
    .col-md-5.hidden
      if block
        block
      else
        p No Content provided




block content
  p
    if article.lock
      .alert.alert-dismissable.alert-info
        button.close( type="button", data-dismiss="alert" ) ×
        | #{article.lock.user} edits since #{layout.moment(article.lock.timestamp).fromNow()} Version #{article.version}
    if info
      if info.message
        if info.status == 'error'
          .alert.alert-dismissable.alert-danger
            button.close( type="button", data-dismiss="alert" ) ×
            | #{info.message}
        if info.status == 'message'
          .alert.alert-dismissable.alert-success
            button.close( type="button", data-dismiss="alert" ) ×
            | #{info.message}
  


          
    if (params.edit && !article.isClosed) 
      form(name="input", action="#{layout.htmlroot}/article/#{article.id}", method="post")
        .row
          .col-md-1
            | Blog <br>
          .col-md-5
            select(id="blog",name="blog").form-control
              option(value="Future") Future
              if (layout.listOfOpenBlog)  
                - var displayed = false;
                for blog in layout.listOfOpenBlog 
                  if blog.name == article.blog         
                    option(value="#{blog.name}" selected) #{blog.name}
                    - displayed = true;
                  else
                     option(value="#{blog.name}" ) #{blog.name}
              if (layout.listOfEditBlog)  
                for blog in layout.listOfEditBlog 
                  if blog.name == article.blog         
                    option(value="#{blog.name}" selected) #{blog.name} (Edit)
                    - displayed = true;
                  else
                     option(value="#{blog.name}" ) #{blog.name} (Edit)
              if (layout.listOfReviewBlog)  
                for blog in layout.listOfReviewBlog 
                  if blog.name == article.blog         
                    option(value="#{blog.name}" selected) #{blog.name} (Review #{layout.user.language})
                    - displayed = true;
                  else
                     option(value="#{blog.name}" ) #{blog.name} (Review #{layout.user.language})
              if (article.blog == "Trash")
                option(value="Trash" selected) Trash
                - displayed = true;
              else
                option(value="Trash" ) Trash
              if (layout.listOfHelpBlog)
                each helpblog in layout.listOfHelpBlog
                  if helpblog.name == article.blog         
                    option(value="#{helpblog.name}" selected) #{helpblog.name}
                    - displayed = true;
                  else
                     option(value="#{helpblog.name}" ) #{helpblog.name}
              if (!displayed)
                option(value="#{article.blog}" selected) #{article.blog}
              
          .col-md-5
            .hidden
              textarea.form-control(name="version",rows=1,hide=true) #{article.version}

          .col-md-1
            input(type="submit", class="btn btn-primary",value="OK")
            a(href="#{layout.htmlroot}/article/#{article.id}?edit=false&style=#{params.style}" class="btn btn-default" role="button") Cancel


        .row
          .col-md-1
            | Category <br>
          +leftcolumn
            select(id="categoryEN",name="categoryEN").form-control
              for category in categories
                - option = category[params.left_lang]
                - if (params.right_lang != "--") option += " / "+category[params.right_lang]
                if (category.EN == article.categoryEN)
                  option(value="#{category.EN}" selected ) #{option} 
                else
                  option(value="#{category.EN}" ) #{option} 
          +rightcolumn
            h2
              | #{article.getCategory(params.right_lang)}

        .row
          .col-md-1
            | Title <br>
          .col-md-10
            textarea.form-control(name="title",rows=1) #{article.title}
               
        .row
          .col-md-1
            | Collection <br>
          .col-md-10
            textarea.form-control(id="collection" name="collection" rows=7) #{article.collection}
        .row
          .col-md-1
            
          .col-md-6
              .div(id="linkArea")
          .col-md-4
            p Drag me to a markdown field, or paste an URL into selected text to create an markdown link.
                
        .row 
          .col-md-1
          +leftcolumn
            | #{params.left_lang}
          +rightcolumn
            | #{params.right_lang}
        .row
          .col-md-1
            | Markdown 
          +leftcolumn
            textarea.form-control(id="markdownLEFT" name = "markdown#{params.left_lang}" rows=7) #{article["markdown"+params.left_lang]}
            div(id="text_left")
              | 'no translation' to specify no translation wanted.
 
          +rightcolumn
            textarea.form-control(id="markdownRIGHT" name = "markdown#{params.right_lang}" rows=7) #{article["markdown"+params.right_lang]}
            div(id="text_right")
              | 'no translation' to specify no translation wanted.
          .col-md-1

            if ((params.left_lang=="DE") || (params.right_lang=="DE"))
              img(id="Japanisch",src="http://blog.openstreetmap.de/wp-uploads//2015/10/jp.svg", class="img-responsive" ,width = 40, onclick="javascript:myclick(this.id)")
              img(id="Französisch",src="http://blog.openstreetmap.de/wp-uploads//2015/01/fr.svg", class="img-responsive" , width = 40 , onclick="javascript:myclick(this.id)")
              img(id="Spanisch",src="http://blog.openstreetmap.de/wp-uploads//2015/01/es.svg", class="img-responsive" , width = 40 , onclick="javascript:myclick(this.id)")
              img(id="Brasilianisches Portugiesisch",src="http://blog.openstreetmap.de/wp-uploads//2015/01/pt-br.svg", class="img-responsive", width = 40 ,onclick="javascript:myclick(this.id)")
              img(id="Tschechisch",src="http://blog.openstreetmap.de/wp-uploads//2015/01/cz.svg", class="img-responsive", width = 40, onclick="javascript:myclick(this.id)")
              img(id="Russisch",src="http://blog.openstreetmap.de/wp-uploads//2015/07/ru.svg", class="img-responsive", width = 40, onclick="javascript:myclick(this.id)")
              img(id="Niederländisch",src="http://blog.openstreetmap.de/wp-uploads//2015/07/nl.svg", class="img-responsive" ,width = 40 ,onclick="javascript:myclick(this.id)")
              img(id="Rumänisch",src="http://blog.openstreetmap.de/wp-uploads//2015/10/ro.svg", class="img-responsive" ,width = 40 ,onclick="javascript:myclick(this.id)")
              img(id="Polish",src="http://blog.openstreetmap.de/wp-uploads//2015/10/pl.svg", class="img-responsive" ,width = 40 ,onclick="javascript:myclick(this.id)")


        .row
          .col-md-1
            | Preview
          +leftcolumn
            .panel.panel-default.panel-body(id="previewLEFT")
                :verbatim
                  !{article["textHtml"+params.left_lang]}
          +rightcolumn
            .panel.panel-default
              .panel-body(id="previewRIGHT")
                :verbatim
                  !{article["textHtml"+params.right_lang]}
        .row
          .col-md-1
            | Comment <br>
          .col-md-11  
            textarea.form-control(
              name="comment"
              rows=7) #{article.comment}
        .row
          .col-md-1
          .col-md-5
            if (article.comment && article.comment!="")
              select(id="commentStatus",name="commentStatus").form-control
                each status in ["open","solved"]
                  if article.commentStatus
                    if status == article.commentStatus
                      option(value="#{status}" selected ) #{status}
                    else
                      option(value="#{status}"  ) #{status}
                  else
                      option(value="#{status}"  ) #{status}

          
    else
     .row
        .col-md-1
          | Blog <br>
        +leftcolumn
          h2
            | #{article.blog}
        +rightcolumn
          h2
        .col-md-1
          a(href="#{layout.htmlroot}/article/#{article.id}?edit=true&style=#{params.style}" class="btn btn-primary" role="button") Edit
      .row
        .col-md-1
          | Category <br>
        +leftcolumn
          h4
            | #{article.getCategory(params.left_lang)}
        +rightcolumn
          h4
            | #{article.getCategory(params.right_lang)}
      .row
        .col-md-1
          | Title <br>
        .col-md-10
          h3
            | #{article.title}
      .row
        .col-md-1
          | Collection <br>
        .col-md-10
          if (article.collection)
                :verbatim
                | <pre>
                !{article.collection.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi, '<a href="$1">$1</a>')}
                | </pre>
      .row 
        .col-md-1
        +leftcolumn
          | #{params.left_lang}
        +rightcolumn
          | #{params.right_lang}

      if (false)
        .row
          .col-md-1
              | Markdown<br>
          +leftcolumn 
              .panel.panel-default
                .panel-body #{article["markdown"+params.left_lang]}
          +rightcolumn
              .panel.panel-default
                .panel-body #{article["markdown"+params.right_lang]}
      .row
        .col-md-1
          | Preview

        +leftcolumn 
          .panel.panel-default
            .panel-body(id="previewLEFT")
                :verbatim
                  !{article["textHtml"+params.left_lang]}
        +rightcolumn 
          .panel.panel-default
            .panel-body(id="previewRIGHT")
                :verbatim
                  !{article["textHtml"+params.right_lang]}
        
      .row
         if (article.comment && article.comment!="")
          .col-md-1
            | Comment 
          .col-md-10 
              | (Comment is #{article.commentStatus})
              :verbatim
              |<pre>
              !{article.comment}
              |</pre>
    .row
      if articleReferences.count >= 1
        h2
          | Links used in other Post
        div
          table.table.table-striped.table-responsive
            thead
              tr
                th
                  | link
                th
                  | article
                th
                  | Blog
            tbody
              each array,link in articleReferences
                if (link != "count" )
                  each articleItem,index in array
                    if (articleItem.id != article.id) && (index <5)
                      tr
                        td
                          a(href='#{link}') #{link}
                        td
                          a(href='#{layout.htmlroot}/article/'+articleItem.id) #{articleItem.displayTitle()}
                        td= articleItem.blog
                    if (index == 8) 
                      tr
                        td
                          a(href='#{link}') #{link}
                        td
                          | Und #{array.length-5} weitere Artikel.
                



    .row
      if changes
        h2
          | History
        div
          table.table.table-striped.table-responsive
            thead
              tr 
                th
                 | id
                th
                 | user
                th
                 | what
                th
                 | from
                th
                 |  to
                th
                 | when
             tbody
              each change, i in changes
                tr
                  td
                    a(href='#{layout.htmlroot}/changes/' + change.id) #{change.id} 
                  td= change.user
                  td= change.property
                  td= layout.util.shorten(change.from)
                  td= layout.util.shorten(change.to)
                  td= layout.moment(change.timestamp).fromNow() 
 
block scripts                
  script(src='https://cdn.jsdelivr.net/markdown-it/5.0.1/markdown-it.min.js')
  script(src="https://cdn.rawgit.com/Triforcey/clip-j/1dbfdfc0646359ee70d714549db947d02705b303/clip-j.js" )

  script.
    window.onload = init;

    function init() {

      markdownLEFT = document.getElementById("markdownLEFT");
      markdownLEFT.onchange = onchangeLEFT;
      markdownLEFT.onkeyup = onchangeLEFT;
      markdownLEFT.onpaste = pasteLEFT;
      markdownLEFT.ondrop = pasteLEFT;
      markdownRIGHT = document.getElementById("markdownRIGHT");
      markdownRIGHT.onchange = onchangeRIGHT;
      markdownRIGHT.onkeyup = onchangeRIGHT;
      markdownRIGHT.onpaste = pasteRIGHT;
      markdownRIGHT.ondrop = pasteRIGHT;
      noTranslationText = document.getElementById("text_right").innerHTML;
     
      coll = document.getElementById("collection");
      coll.onchange = onchangeCollection;
      coll.onkeyup = onchangeCollection;
      onchangeCollection();
    }

    function onleaveEN() {
      var mdEN = document.getElementById("markdownLEFT").value;
      if (mdEN == "-") {
        document.getElementById("markdownLEFT").value = "no translation";
        }
    }
   
    function convert(text) {
      converter = new window.markdownit();

      // generate the OSMBlog Style List
      if (text.substring(0,2)=="* ") text = text.substring(2,999999);
      // convert md to html
      text = converter.render(text);
      // skip <ul> and </ul> at start and end
      

      text = '<ul><li>'+text+'</li></ul>';
      
      return text;

    }
    function isURL(t) {
    
      var isUrlRegex = /^(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&amp;:\/~+#-]*[\w@?^=%&amp;\/~+#-])?/


      if (t) return isUrlRegex.test(t);
      return isUrlRegex;
    }
    
    function generateMarkdownLink(par1,par2) {
        var before = par1;
        var after = par2;
        var tb = '';
    
        while (before.length>0 && before.charAt(0)==after.charAt(0)) {
          tb += before.charAt(0);
          before = before.substring(1,99999);
          after = after.substring(1.99999);
        }
    
        ta = '';
        var beforeSnip='';
        var afterSnip='';
        while ( (before.length>0) && 
                (before.charAt(before.length-1)==after.charAt(after.length-1))) {
          ta =  before.charAt(before.length-1) + ta;
          before = before.substring(0,before.length-1);
          after = after.substring(0,after.length-1); 
        }
        beforeSnip = before;
        afterSnip = after;    
     
      
        console.log("tb    :"+tb);
        console.log("BEFORE:"+"                        ".substring(0,tb.length)+"*"+beforeSnip+"*"+ta);
        console.log("AFTER :"+"                        ".substring(0,tb.length)+"*"+afterSnip+"*"+ta);
  
       

        if (isURL(afterSnip)) {
       
          var allreadyMarkdowned = false;
          if (tb!="" && tb.charAt(tb.length-1)=="(") allreadyMarkdowned= true;
          if (ta!="" && tb.charAt(0)==")") allreadyMarkdowned= true;
          if (!allreadyMarkdowned) {
            var r = tb+"["+beforeSnip+"]("+afterSnip+")"+ta;
            var c ;
            if (beforeSnip == "") {
              c = (tb+"[").length;
            } else {
              c = (tb+"["+beforeSnip+"]("+afterSnip+")").length;
            }
            return {text:r,pos:c};
          }
        }
        return null;
    }
    
    function pasteLEFT() {
     
     
      var mf = document.getElementById("markdownLEFT");
      var textBefore = mf.value;
      
      setTimeout(function(){
        var textAfter = mf.value;
        var r = generateMarkdownLink(textBefore,textAfter);
        if (r) {
          mf.value =r.text;
          mf.selectionStart = mf.selectionEnd = r.pos;

          onchangeLEFT();
        }
      },1);

    }
    function pasteRIGHT() {
     
     
      var mf = document.getElementById("markdownRIGHT");
      var textBefore = mf.value;
      
      setTimeout(function(){
        var textAfter = mf.value;
        var r = generateMarkdownLink(textBefore,textAfter);
        if (r) {
          mf.value =r.text;
          mf.selectionStart = mf.selectionEnd = r.pos;
         onchangeRIGHT();
        }
      },1);

    }

    
    function onchangeLEFT() {
      var md = document.getElementById("markdownLEFT").value;
      previewLEFT = document.getElementById("previewLEFT");
      textLeft = document.getElementById("text_left");
      
      previewLEFT.innerHTML = convert(md);
      var longLink = md.search(/\[[^\]]{40,}\]/g);
      if (longLink>=0) {
        //previewLEFT.style.backgroundColor="#FDC6CD";
        textLeft.innerHTML = "Please shorten ["+md.substring(longLink+1,longLink+40)+"...]"
        textLeft.style.backgroundColor ="#FDC6CD";


        }
      else {
         //previewLEFT.style.backgroundColor="";
         textLeft.style.backgroundColor ="";
         textLeft.innerHTML = noTranslationText;
        }
      }
    function onchangeRIGHT() {
      var mdEN = document.getElementById("markdownRIGHT").value;
      previewRIGHT = document.getElementById("previewRIGHT");
      textRight = document.getElementById("text_right");
      textLeft = document.getElementById("text_left");
      
      previewRIGHT.innerHTML = convert(mdEN);
      var longLink = mdEN.search(/\[[^\]]{40,}\]/g);
      if (longLink>=0) {
        textRight.innerHTML = "Please shorten ["+mdEN.substring(longLink+1,longLink+40)+"...]"
        textRight.style.backgroundColor ="#FDC6CD";
        //previewRIGHT.style.backgroundColor="#FDC6CD";
        
      }
      else {
         textRight.style.backgroundColor ="";
         textRight.innerHTML = noTranslationText;
         //previewRIGHT.style.backgroundColor="";
         
         }
      }
      function onchangeCollection() {
        var cl = document.getElementById("collection").value;
        var linkArea = document.getElementById("linkArea");

        regexToken = /(((ftp|https?):\/\/)[\-\w@:%_\+.~#?,&\/\/=]+)|((mailto:)?[_.\w-]+@([\w][\w\-]+\.)+[a-zA-Z]{2,3})/g;
        var linkList;
       
        var result = "";
        while( (linkList = regexToken.exec(cl)) != null ) {
            console.log("linkList"+JSON.stringify(linkList));
         
            result += '<a href="'+linkList[0]+'"">'+linkList[0]+'</a><br>\n';
            console.log(result);
        }
        result = '<p>'+result+'</p>';
        console.log(result);
        linkArea.innerHTML = result;
      }


      var myclick = function (id) {
        image = document.getElementById(id);
        src = image.src;
        src = "![("+id+")]("+src+")";
        clip(src);
        alert(id+ " flag is copied to clipboard");
        

               }






<commit_msg>Disable closed articles for editing. Close #156<commit_after>extends layout


mixin leftcolumn
  if (params.right_lang =="--")
    .col-md-10
      if block
        block
      else
        p No Content provided
  else
    .col-md-5
      if block
        block
      else
        p No Content provided

mixin rightcolumn
  if (params.right_lang !="--")
    .col-md-5
      if block
        block
      else
        p No Content provided
  else
    .col-md-5.hidden
      if block
        block
      else
        p No Content provided




block content
  p
    if article.lock
      .alert.alert-dismissable.alert-info
        button.close( type="button", data-dismiss="alert" ) ×
        | #{article.lock.user} edits since #{layout.moment(article.lock.timestamp).fromNow()} Version #{article.version}
    if info
      if info.message
        if info.status == 'error'
          .alert.alert-dismissable.alert-danger
            button.close( type="button", data-dismiss="alert" ) ×
            | #{info.message}
        if info.status == 'message'
          .alert.alert-dismissable.alert-success
            button.close( type="button", data-dismiss="alert" ) ×
            | #{info.message}
  


          
    if (params.edit && !article.isClosed) 
      form(name="input", action="#{layout.htmlroot}/article/#{article.id}", method="post")
        .row
          .col-md-1
            | Blog <br>
          .col-md-5
            select(id="blog",name="blog").form-control
              option(value="Future") Future
              if (layout.listOfOpenBlog)  
                - var displayed = false;
                for blog in layout.listOfOpenBlog 
                  if blog.name == article.blog         
                    option(value="#{blog.name}" selected) #{blog.name}
                    - displayed = true;
                  else
                     option(value="#{blog.name}" ) #{blog.name}
              if (layout.listOfEditBlog)  
                for blog in layout.listOfEditBlog 
                  if blog.name == article.blog         
                    option(value="#{blog.name}" selected) #{blog.name} (Edit)
                    - displayed = true;
                  else
                     option(value="#{blog.name}" ) #{blog.name} (Edit)
              if (layout.listOfReviewBlog)  
                for blog in layout.listOfReviewBlog 
                  if blog.name == article.blog         
                    option(value="#{blog.name}" selected) #{blog.name} (Review #{layout.user.language})
                    - displayed = true;
                  else
                     option(value="#{blog.name}" ) #{blog.name} (Review #{layout.user.language})
              if (article.blog == "Trash")
                option(value="Trash" selected) Trash
                - displayed = true;
              else
                option(value="Trash" ) Trash
              if (layout.listOfHelpBlog)
                each helpblog in layout.listOfHelpBlog
                  if helpblog.name == article.blog         
                    option(value="#{helpblog.name}" selected) #{helpblog.name}
                    - displayed = true;
                  else
                     option(value="#{helpblog.name}" ) #{helpblog.name}
              if (!displayed)
                option(value="#{article.blog}" selected) #{article.blog}
              
          .col-md-5
            .hidden
              textarea.form-control(name="version",rows=1,hide=true) #{article.version}

          .col-md-1
            input(type="submit", class="btn btn-primary",value="OK")
            a(href="#{layout.htmlroot}/article/#{article.id}?edit=false&style=#{params.style}" class="btn btn-default" role="button") Cancel


        .row
          .col-md-1
            | Category <br>
          +leftcolumn
            select(id="categoryEN",name="categoryEN").form-control
              for category in categories
                - option = category[params.left_lang]
                - if (params.right_lang != "--") option += " / "+category[params.right_lang]
                if (category.EN == article.categoryEN)
                  option(value="#{category.EN}" selected ) #{option} 
                else
                  option(value="#{category.EN}" ) #{option} 
          +rightcolumn
            h2
              | #{article.getCategory(params.right_lang)}

        .row
          .col-md-1
            | Title <br>
          .col-md-10
            textarea.form-control(name="title",rows=1) #{article.title}
               
        .row
          .col-md-1
            | Collection <br>
          .col-md-10
            textarea.form-control(id="collection" name="collection" rows=7) #{article.collection}
        .row
          .col-md-1
            
          .col-md-6
              .div(id="linkArea")
          .col-md-4
            p Drag me to a markdown field, or paste an URL into selected text to create an markdown link.
                
        .row 
          .col-md-1
          +leftcolumn
            | #{params.left_lang}
          +rightcolumn
            | #{params.right_lang}
        .row
          .col-md-1
            | Markdown 
          +leftcolumn
            if  blog["close"+params.left_lang]
              .panel.panel-default
                .panel-body #{article["markdown"+params.left_lang]}         
            else
              textarea.form-control(id="markdownLEFT" name = "markdown#{params.left_lang}" rows=7) #{article["markdown"+params.left_lang]}
              div(id="text_left")
                | 'no translation' to specify no translation wanted.
 
          +rightcolumn
            if blog["close"+params.right_lang]
              .panel.panel-default
                .panel-body #{article["markdown"+params.right_lang]}         
            else
              textarea.form-control(id="markdownRIGHT" name = "markdown#{params.right_lang}" rows=7) #{article["markdown"+params.right_lang]}
              div(id="text_right")
                | 'no translation' to specify no translation wanted.
          .col-md-1

            if ((params.left_lang=="DE") || (params.right_lang=="DE"))
              img(id="Japanisch",src="http://blog.openstreetmap.de/wp-uploads//2015/10/jp.svg", class="img-responsive" ,width = 40, onclick="javascript:myclick(this.id)")
              img(id="Französisch",src="http://blog.openstreetmap.de/wp-uploads//2015/01/fr.svg", class="img-responsive" , width = 40 , onclick="javascript:myclick(this.id)")
              img(id="Spanisch",src="http://blog.openstreetmap.de/wp-uploads//2015/01/es.svg", class="img-responsive" , width = 40 , onclick="javascript:myclick(this.id)")
              img(id="Brasilianisches Portugiesisch",src="http://blog.openstreetmap.de/wp-uploads//2015/01/pt-br.svg", class="img-responsive", width = 40 ,onclick="javascript:myclick(this.id)")
              img(id="Tschechisch",src="http://blog.openstreetmap.de/wp-uploads//2015/01/cz.svg", class="img-responsive", width = 40, onclick="javascript:myclick(this.id)")
              img(id="Russisch",src="http://blog.openstreetmap.de/wp-uploads//2015/07/ru.svg", class="img-responsive", width = 40, onclick="javascript:myclick(this.id)")
              img(id="Niederländisch",src="http://blog.openstreetmap.de/wp-uploads//2015/07/nl.svg", class="img-responsive" ,width = 40 ,onclick="javascript:myclick(this.id)")
              img(id="Rumänisch",src="http://blog.openstreetmap.de/wp-uploads//2015/10/ro.svg", class="img-responsive" ,width = 40 ,onclick="javascript:myclick(this.id)")
              img(id="Polish",src="http://blog.openstreetmap.de/wp-uploads//2015/10/pl.svg", class="img-responsive" ,width = 40 ,onclick="javascript:myclick(this.id)")


        .row
          .col-md-1
            | Preview
          +leftcolumn
            .panel.panel-default.panel-body(id="previewLEFT")
                :verbatim
                  !{article["textHtml"+params.left_lang]}
          +rightcolumn
            .panel.panel-default
              .panel-body(id="previewRIGHT")
                :verbatim
                  !{article["textHtml"+params.right_lang]}
        .row
          .col-md-1
            | Comment <br>
          .col-md-11  
            textarea.form-control(
              name="comment"
              rows=7) #{article.comment}
        .row
          .col-md-1
          .col-md-5
            if (article.comment && article.comment!="")
              select(id="commentStatus",name="commentStatus").form-control
                each status in ["open","solved"]
                  if article.commentStatus
                    if status == article.commentStatus
                      option(value="#{status}" selected ) #{status}
                    else
                      option(value="#{status}"  ) #{status}
                  else
                      option(value="#{status}"  ) #{status}

          
    else
     .row
        .col-md-1
          | Blog <br>
        +leftcolumn
          h2
            | #{article.blog}
        +rightcolumn
          h2
        .col-md-1
          a(href="#{layout.htmlroot}/article/#{article.id}?edit=true&style=#{params.style}" class="btn btn-primary" role="button") Edit
      .row
        .col-md-1
          | Category <br>
        +leftcolumn
          h4
            | #{article.getCategory(params.left_lang)}
        +rightcolumn
          h4
            | #{article.getCategory(params.right_lang)}
      .row
        .col-md-1
          | Title <br>
        .col-md-10
          h3
            | #{article.title}
      .row
        .col-md-1
          | Collection <br>
        .col-md-10
          if (article.collection)
                :verbatim
                | <pre>
                !{article.collection.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi, '<a href="$1">$1</a>')}
                | </pre>
      .row 
        .col-md-1
        +leftcolumn
          | #{params.left_lang}
        +rightcolumn
          | #{params.right_lang}

      if (false)
        .row
          .col-md-1
              | Markdown<br>
          +leftcolumn 
              .panel.panel-default
                .panel-body #{article["markdown"+params.left_lang]}
          +rightcolumn
              .panel.panel-default
                .panel-body #{article["markdown"+params.right_lang]}
      .row
        .col-md-1
          | Preview

        +leftcolumn 
          .panel.panel-default
            .panel-body(id="previewLEFT")
                :verbatim
                  !{article["textHtml"+params.left_lang]}
        +rightcolumn 
          .panel.panel-default
            .panel-body(id="previewRIGHT")
                :verbatim
                  !{article["textHtml"+params.right_lang]}
        
      .row
         if (article.comment && article.comment!="")
          .col-md-1
            | Comment 
          .col-md-10 
              | (Comment is #{article.commentStatus})
              :verbatim
              |<pre>
              !{article.comment}
              |</pre>
    .row
      if articleReferences.count >= 1
        h2
          | Links used in other Post
        div
          table.table.table-striped.table-responsive
            thead
              tr
                th
                  | link
                th
                  | article
                th
                  | Blog
            tbody
              each array,link in articleReferences
                if (link != "count" )
                  each articleItem,index in array
                    if (articleItem.id != article.id) && (index <5)
                      tr
                        td
                          a(href='#{link}') #{link}
                        td
                          a(href='#{layout.htmlroot}/article/'+articleItem.id) #{articleItem.displayTitle()}
                        td= articleItem.blog
                    if (index == 8) 
                      tr
                        td
                          a(href='#{link}') #{link}
                        td
                          | Und #{array.length-5} weitere Artikel.
                



    .row
      if changes
        h2
          | History
        div
          table.table.table-striped.table-responsive
            thead
              tr 
                th
                 | id
                th
                 | user
                th
                 | what
                th
                 | from
                th
                 |  to
                th
                 | when
             tbody
              each change, i in changes
                tr
                  td
                    a(href='#{layout.htmlroot}/changes/' + change.id) #{change.id} 
                  td= change.user
                  td= change.property
                  td= layout.util.shorten(change.from)
                  td= layout.util.shorten(change.to)
                  td= layout.moment(change.timestamp).fromNow() 
 
block scripts                
  script(src='https://cdn.jsdelivr.net/markdown-it/5.0.1/markdown-it.min.js')
  script(src="https://cdn.rawgit.com/Triforcey/clip-j/1dbfdfc0646359ee70d714549db947d02705b303/clip-j.js" )

  script.
    window.onload = init;

    function init() {

      markdownLEFT = document.getElementById("markdownLEFT");
      markdownLEFT.onchange = onchangeLEFT;
      markdownLEFT.onkeyup = onchangeLEFT;
      markdownLEFT.onpaste = pasteLEFT;
      markdownLEFT.ondrop = pasteLEFT;
      markdownRIGHT = document.getElementById("markdownRIGHT");
      markdownRIGHT.onchange = onchangeRIGHT;
      markdownRIGHT.onkeyup = onchangeRIGHT;
      markdownRIGHT.onpaste = pasteRIGHT;
      markdownRIGHT.ondrop = pasteRIGHT;
      noTranslationText = document.getElementById("text_right").innerHTML;
     
      coll = document.getElementById("collection");
      coll.onchange = onchangeCollection;
      coll.onkeyup = onchangeCollection;
      onchangeCollection();
    }

    function onleaveEN() {
      var mdEN = document.getElementById("markdownLEFT").value;
      if (mdEN == "-") {
        document.getElementById("markdownLEFT").value = "no translation";
        }
    }
   
    function convert(text) {
      converter = new window.markdownit();

      // generate the OSMBlog Style List
      if (text.substring(0,2)=="* ") text = text.substring(2,999999);
      // convert md to html
      text = converter.render(text);
      // skip <ul> and </ul> at start and end
      

      text = '<ul><li>'+text+'</li></ul>';
      
      return text;

    }
    function isURL(t) {
    
      var isUrlRegex = /^(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&amp;:\/~+#-]*[\w@?^=%&amp;\/~+#-])?/


      if (t) return isUrlRegex.test(t);
      return isUrlRegex;
    }
    
    function generateMarkdownLink(par1,par2) {
        var before = par1;
        var after = par2;
        var tb = '';
    
        while (before.length>0 && before.charAt(0)==after.charAt(0)) {
          tb += before.charAt(0);
          before = before.substring(1,99999);
          after = after.substring(1.99999);
        }
    
        ta = '';
        var beforeSnip='';
        var afterSnip='';
        while ( (before.length>0) && 
                (before.charAt(before.length-1)==after.charAt(after.length-1))) {
          ta =  before.charAt(before.length-1) + ta;
          before = before.substring(0,before.length-1);
          after = after.substring(0,after.length-1); 
        }
        beforeSnip = before;
        afterSnip = after;    
     
      
        console.log("tb    :"+tb);
        console.log("BEFORE:"+"                        ".substring(0,tb.length)+"*"+beforeSnip+"*"+ta);
        console.log("AFTER :"+"                        ".substring(0,tb.length)+"*"+afterSnip+"*"+ta);
  
       

        if (isURL(afterSnip)) {
       
          var allreadyMarkdowned = false;
          if (tb!="" && tb.charAt(tb.length-1)=="(") allreadyMarkdowned= true;
          if (ta!="" && tb.charAt(0)==")") allreadyMarkdowned= true;
          if (!allreadyMarkdowned) {
            var r = tb+"["+beforeSnip+"]("+afterSnip+")"+ta;
            var c ;
            if (beforeSnip == "") {
              c = (tb+"[").length;
            } else {
              c = (tb+"["+beforeSnip+"]("+afterSnip+")").length;
            }
            return {text:r,pos:c};
          }
        }
        return null;
    }
    
    function pasteLEFT() {
     
     
      var mf = document.getElementById("markdownLEFT");
      var textBefore = mf.value;
      
      setTimeout(function(){
        var textAfter = mf.value;
        var r = generateMarkdownLink(textBefore,textAfter);
        if (r) {
          mf.value =r.text;
          mf.selectionStart = mf.selectionEnd = r.pos;

          onchangeLEFT();
        }
      },1);

    }
    function pasteRIGHT() {
     
     
      var mf = document.getElementById("markdownRIGHT");
      var textBefore = mf.value;
      
      setTimeout(function(){
        var textAfter = mf.value;
        var r = generateMarkdownLink(textBefore,textAfter);
        if (r) {
          mf.value =r.text;
          mf.selectionStart = mf.selectionEnd = r.pos;
         onchangeRIGHT();
        }
      },1);

    }

    
    function onchangeLEFT() {
      var md = document.getElementById("markdownLEFT").value;
      previewLEFT = document.getElementById("previewLEFT");
      textLeft = document.getElementById("text_left");
      
      previewLEFT.innerHTML = convert(md);
      var longLink = md.search(/\[[^\]]{40,}\]/g);
      if (longLink>=0) {
        //previewLEFT.style.backgroundColor="#FDC6CD";
        textLeft.innerHTML = "Please shorten ["+md.substring(longLink+1,longLink+40)+"...]"
        textLeft.style.backgroundColor ="#FDC6CD";


        }
      else {
         //previewLEFT.style.backgroundColor="";
         textLeft.style.backgroundColor ="";
         textLeft.innerHTML = noTranslationText;
        }
      }
    function onchangeRIGHT() {
      var mdEN = document.getElementById("markdownRIGHT").value;
      previewRIGHT = document.getElementById("previewRIGHT");
      textRight = document.getElementById("text_right");
      textLeft = document.getElementById("text_left");
      
      previewRIGHT.innerHTML = convert(mdEN);
      var longLink = mdEN.search(/\[[^\]]{40,}\]/g);
      if (longLink>=0) {
        textRight.innerHTML = "Please shorten ["+mdEN.substring(longLink+1,longLink+40)+"...]"
        textRight.style.backgroundColor ="#FDC6CD";
        //previewRIGHT.style.backgroundColor="#FDC6CD";
        
      }
      else {
         textRight.style.backgroundColor ="";
         textRight.innerHTML = noTranslationText;
         //previewRIGHT.style.backgroundColor="";
         
         }
      }
      function onchangeCollection() {
        var cl = document.getElementById("collection").value;
        var linkArea = document.getElementById("linkArea");

        regexToken = /(((ftp|https?):\/\/)[\-\w@:%_\+.~#?,&\/\/=]+)|((mailto:)?[_.\w-]+@([\w][\w\-]+\.)+[a-zA-Z]{2,3})/g;
        var linkList;
       
        var result = "";
        while( (linkList = regexToken.exec(cl)) != null ) {
            console.log("linkList"+JSON.stringify(linkList));
         
            result += '<a href="'+linkList[0]+'"">'+linkList[0]+'</a><br>\n';
            console.log(result);
        }
        result = '<p>'+result+'</p>';
        console.log(result);
        linkArea.innerHTML = result;
      }


      var myclick = function (id) {
        image = document.getElementById(id);
        src = image.src;
        src = "![("+id+")]("+src+")";
        clip(src);
        alert(id+ " flag is copied to clipboard");
        

               }







{'fraction_non_alphanumeric': 0.14096105158172006, 'fraction_numerical': 0.01194281768662251, 'mean_word_length': 1.5496511703723024, 'pattern_counts': {'":': 0, '<': 59, '<?xml version=': 0, '>': 67, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5729917', 'n_tokens_mistral': 11716, 'n_tokens_neox': 10979, 'n_words': 1854}