From 09ca39fd085595f791bec6f8e8c154b4a22d3b1e Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 31 Oct 2013 22:08:10 -0700 Subject: provide an html src converter --- .../tiny_mce/plugins/bbcode/editor_plugin_src.js | 59 +-------------------- mod/rpost.php | 15 +++--- version.inc | 2 +- view/tpl/jot-header.tpl | 61 ++++++++++++++++++++++ 4 files changed, 71 insertions(+), 66 deletions(-) diff --git a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js index f94fbc5d7..387ccdd59 100644 --- a/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js +++ b/library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js @@ -45,63 +45,12 @@ s = tinymce.trim(s); function rep(re, str) { - - -s = s.replace(re,str); - - //modify code to keep stuff intact within [code][/code] blocks - //Waitman Gobble NO WARRANTY - -/* This doesn't seem to work well with -[code]line1 -line2[/code] -commenting out for now -*/ - -/* - var o = new Array(); - var x = s.split("[code]"); - var i = 0; - - var si = ""; - si = x.shift(); - si = si.replace(re,str); - o.push(si); - - for (i = 0; i < x.length; i++) { - var no = new Array(); - var j = x.shift(); - var g = j.split("[/code]"); - no.push(g.shift()); - si = g.shift(); - si = si.replace(re,str); - no.push(si); - o.push(no.join("[/code]")); - } - - s = o.join("[code]"); -*/ + s = s.replace(re,str); }; - - /* oembed */ function _h2b_cb(match) { - /* - function s_h2b(data) { - match = data; - } - $.ajax({ - type:"POST", - url: 'oembed/h2b', - data: {text: match}, - async: false, - success: s_h2b, - dataType: 'html' - }); - */ - var f, g, tof = [], tor = []; var find_spanc = /]*class *= *[\"'](?:[^\"']* )*oembed(?: [^\"']*)*[\"'][^>]*>(.*?(?:]*>(.*?)<\/span *>)*.*?)<\/span *>/ig; while (f = find_spanc.exec(match)) { @@ -124,11 +73,8 @@ commenting out for now s = _h2b_cb(s); } - /* /oembed */ - - // example: to [b] - rep(/(.*?)<\/a>/gi,"[bookmark=$1]$2[/bookmark]"); + rep(/(.*?)<\/a>/gi,"[url=$1]$2[/url]"); rep(/(.*?)<\/span>/gi,"[size=$1]$2[/size]"); rep(/(.*?)<\/span>/gi,"[color=$1]$2[/color]"); @@ -222,7 +168,6 @@ commenting out for now rep(/\[u\]/gi,""); rep(/\[\/u\]/gi,""); rep(/\[hr\]/gi,"
"); - rep(/\[bookmark=([^\]]+)\](.*?)\[\/bookmark\]/gi,"
$2"); rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"$2"); rep(/\[url\](.*?)\[\/url\]/gi,"$1"); rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,""); diff --git a/mod/rpost.php b/mod/rpost.php index 6173ca5e2..820799218 100644 --- a/mod/rpost.php +++ b/mod/rpost.php @@ -20,7 +20,6 @@ require_once('include/zot.php'); * remote_return= absolute URL to return after posting is finished * type= choices are 'html' or 'bbcode', default is 'bbcode' * - * currently content type is Red Matrix bbcode, though HTML is possible. This is left as an exercise for future developers */ @@ -85,13 +84,13 @@ function rpost_content(&$a) { )); - $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array( - '$baseurl' => $a->get_baseurl(), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), - '$ispublic' => ' ', // t('Visible to everybody'), - '$geotag' => $geotag, - '$nickname' => $channel['channel_address'] - )); +// $a->page['htmlhead'] .= replace_macros(get_markup_template('jot-header.tpl'), array( +// '$baseurl' => $a->get_baseurl(), +// '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), +// '$ispublic' => ' ', // t('Visible to everybody'), +// '$geotag' => $geotag, +// '$nickname' => $channel['channel_address'] +// )); diff --git a/version.inc b/version.inc index 49580e13c..e00c683b5 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2013-10-30.482 +2013-10-31.483 diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 810ec866f..527db4e4f 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -284,6 +284,13 @@ function enableOnUser(){ $('#profile-nolocation-wrapper').hide(); } + + function addhtmltext(data) { + data = h2b(data); + addeditortext(data); + } + + function addeditortext(data) { if(plaintext == 'none') { var currentText = $("#profile-jot-text").val(); @@ -293,6 +300,60 @@ function enableOnUser(){ tinyMCE.execCommand('mceInsertRawHTML',false,data); } + function h2b(s) { + var y = s; + function rep(re, str) { + y = y.replace(re,str); + }; + + rep(/(.*?)<\/a>/gi,"[url=$1]$2[/url]"); + rep(/(.*?)<\/span>/gi,"[size=$1]$2[/size]"); + rep(/(.*?)<\/span>/gi,"[color=$1]$2[/color]"); + rep(/(.*?)<\/font>/gi,"$1"); + rep(//gi,"[img=$1x$2]$3[/img]"); + rep(//gi,"[img=$2x$1]$3[/img]"); + rep(//gi,"[img=$3x$2]$1[/img]"); + rep(//gi,"[img=$2x$3]$1[/img]"); + rep(//gi,"[img]$1[/img]"); + + + rep(/
    (.*?)<\/ul>/gi,"[list]$1[/list]"); + rep(/
      (.*?)<\/ul>/gi,"[list=]$1[/list]"); + rep(/
        (.*?)<\/ul>/gi,"[list=1]$1[/list]"); + rep(/
          (.*?)<\/ul>/gi,"[list=i]$1[/list]"); + rep(/
            (.*?)<\/ul>/gi,"[list=I]$1[/list]"); + rep(/
              (.*?)<\/ul>/gi,"[list=a]$1[/list]"); + rep(/
                (.*?)<\/ul>/gi,"[list=A]$1[/list]"); + rep(/
              • (.*?)<\/li>/gi,"[li]$1[/li]"); + + rep(/(.*?)<\/code>/gi,"[code]$1[/code]"); + rep(/<\/(strong|b)>/gi,"[/b]"); + rep(/<(strong|b)>/gi,"[b]"); + rep(/<\/(em|i)>/gi,"[/i]"); + rep(/<(em|i)>/gi,"[i]"); + rep(/<\/u>/gi,"[/u]"); + + + rep(/(.*?)<\/span>/gi,"[u]$1[/u]"); + rep(//gi,"[u]"); + rep(/]*>/gi,"[quote]"); + rep(/<\/blockquote>/gi,"[/quote]"); + rep(/
                /gi,"[hr]"); + rep(/
                /gi,"\n"); + rep(//gi,"\n"); + rep(/
                /gi,"\n"); + rep(/

                /gi,""); + rep(/<\/p>/gi,"\n"); + rep(/ /gi," "); + rep(/"/gi,"\""); + rep(/</gi,"<"); + rep(/>/gi,">"); + rep(/&/gi,"&"); + + return y; + }; + + {{$geotag}} -- cgit v1.2.3