<commit_before>var debug = require('debug')('OSMBC:routes:tool');
var express = require('express');
var router = express.Router();
var config = require('../config.js');
var url = require('url');
var http = require('http');
var https = require('https');

var parseEvent = require('../model/parseEvent.js');

var articleModule = require('../model/article.js');

var licenses = require("../data/licenses.js");

var sizeOf = require('image-size');




function renderCalenderAsMarkdown(req,res,next) {
  debug('renderCalenderAsMarkdown');

  var disablePrettify = false;
  var calenderLanguage = "DE";
  var sessionData = req.session.calenderTool;
  if (sessionData) {
    disablePrettify = sessionData.disablePrettify;
    calenderLanguage = sessionData.calenderLanguage;
  }


  parseEvent.calenderToMarkdown(calenderLanguage,function(err,result){
    if (err) return next(err);
    res.render('calenderAsMarkdown',{calenderAsMarkdown:result,
                                disablePrettify:disablePrettify,
                                calenderLanguage:calenderLanguage,
                                layout:res.rendervar.layout});  

  });
}
function postCalenderAsMarkdown(req,res,next) { //jshint ignore:line
  debug('postCalenderAsMarkdown');
  console.dir(req.body);
  var disablePrettify = (req.body.disablePrettify=="true");
  var calenderLanguage = req.body.calenderLanguage;
  req.session.calenderTool = {disablePrettify:disablePrettify,calenderLanguage:calenderLanguage};
  console.dir(req.session);
  res.redirect(config.getValue('htmlroot')+"/tool/calender2markdown");
}

function generateCCLicense(license,lang,author){
  debug("generateCCLicense");
  if (!license || license === "") license = "CC0";
  if (!lang || lang === "") lang = "EN";
  if (!author) author = "";  
  console.log(license);
  console.dir(licenses);
  var text = licenses[license][lang];
  if (typeof(text)=="undefined") text = licenses[license].EN;
  return text.replace("##author##",author);
} 

function renderPictureTool(req,res,next) { //jshint ignore:line
  debug('renderPictureTool');

  var pictureLanguage = "DE";
  var pictureURL = "";
  var pictureMarkup = "";
  var pictureAText = "";
  var pictureLicense = "CC0";
  var pictureAuthor = "[Author Name](LINK)";
  var sessionData = req.session.pictureTool;
  
  if (sessionData) {
    pictureLanguage = sessionData.pictureLanguage;
    pictureURL = sessionData.pictureURL;<commit_msg>Fill picture tool with sample variables for empty session.<commit_after>var debug = require('debug')('OSMBC:routes:tool');
var express = require('express');
var router = express.Router();
var config = require('../config.js');
var url = require('url');
var http = require('http');
var https = require('https');

var parseEvent = require('../model/parseEvent.js');

var articleModule = require('../model/article.js');

var licenses = require("../data/licenses.js");

var sizeOf = require('image-size');




function renderCalenderAsMarkdown(req,res,next) {
  debug('renderCalenderAsMarkdown');

  var disablePrettify = false;
  var calenderLanguage = "DE";
  var sessionData = req.session.calenderTool;
  if (sessionData) {
    disablePrettify = sessionData.disablePrettify;
    calenderLanguage = sessionData.calenderLanguage;
  }


  parseEvent.calenderToMarkdown(calenderLanguage,function(err,result){
    if (err) return next(err);
    res.render('calenderAsMarkdown',{calenderAsMarkdown:result,
                                disablePrettify:disablePrettify,
                                calenderLanguage:calenderLanguage,
                                layout:res.rendervar.layout});  

  });
}
function postCalenderAsMarkdown(req,res,next) { //jshint ignore:line
  debug('postCalenderAsMarkdown');
  console.dir(req.body);
  var disablePrettify = (req.body.disablePrettify=="true");
  var calenderLanguage = req.body.calenderLanguage;
  req.session.calenderTool = {disablePrettify:disablePrettify,calenderLanguage:calenderLanguage};
  console.dir(req.session);
  res.redirect(config.getValue('htmlroot')+"/tool/calender2markdown");
}

function generateCCLicense(license,lang,author){
  debug("generateCCLicense");
  if (!license || license === "") license = "CC0";
  if (!lang || lang === "") lang = "EN";
  if (!author) author = "";  
  console.log(license);
  console.dir(licenses);
  var text = licenses[license][lang];
  if (typeof(text)=="undefined") text = licenses[license].EN;
  return text.replace("##author##",author);
} 

function renderPictureTool(req,res,next) { //jshint ignore:line
  debug('renderPictureTool');

  var pictureLanguage = "DE";
  var pictureURL = "http://blog.openstreetmap.de/wp-content/themes/osmblog/images/headers/blog.png";
  var pictureMarkup = "Some cool markdown text with [^1^](#blog_article) superscript";
  var pictureAText = "Logo";
  var pictureLicense = "CC3";
  var pictureAuthor = "[Author Name](LINK)";
  var sessionData = req.session.pictureTool;
  
  if (sessionData) {
    pictureLanguage = sessionData.pictureLanguage;
    pictureURL = sessionData.pictureURL;
{'fraction_non_alphanumeric': 0.14548693586698339, 'fraction_numerical': 0.0013855898653998416, 'mean_word_length': 4.456803455723542, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3896372', 'n_tokens_mistral': 1541, 'n_tokens_neox': 1500, 'n_words': 282}