aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-10-31 22:08:10 -0700
committerfriendica <info@friendica.com>2013-10-31 22:08:10 -0700
commit09ca39fd085595f791bec6f8e8c154b4a22d3b1e (patch)
treedce4b1fcbdcd2d6a1f40f8b524ad0699bb0b6163
parent3a7a6717385922fa10c92fe1027a123797639a4c (diff)
downloadvolse-hubzilla-09ca39fd085595f791bec6f8e8c154b4a22d3b1e.tar.gz
volse-hubzilla-09ca39fd085595f791bec6f8e8c154b4a22d3b1e.tar.bz2
volse-hubzilla-09ca39fd085595f791bec6f8e8c154b4a22d3b1e.zip
provide an html src converter
-rw-r--r--library/tinymce/jscripts/tiny_mce/plugins/bbcode/editor_plugin_src.js59
-rw-r--r--mod/rpost.php15
-rw-r--r--version.inc2
-rwxr-xr-xview/tpl/jot-header.tpl61
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 = /<span [^>]*class *= *[\"'](?:[^\"']* )*oembed(?: [^\"']*)*[\"'][^>]*>(.*?(?:<span[^>]*>(.*?)<\/span *>)*.*?)<\/span *>/ig;
while (f = find_spanc.exec(match)) {
@@ -124,11 +73,8 @@ commenting out for now
s = _h2b_cb(s);
}
- /* /oembed */
-
-
// example: <strong> to [b]
- rep(/<a class=\"bookmark\" href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[bookmark=$1]$2[/bookmark]");
+
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
@@ -222,7 +168,6 @@ commenting out for now
rep(/\[u\]/gi,"<u>");
rep(/\[\/u\]/gi,"</u>");
rep(/\[hr\]/gi,"<hr />");
- rep(/\[bookmark=([^\]]+)\](.*?)\[\/bookmark\]/gi,"<a class=\"bookmark\" href=\"$1\">$2</a>");
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
rep(/\[img=(.*?)x(.*?)\](.*?)\[\/img\]/gi,"<img width=\"$1\" height=\"$2\" src=\"$3\" />");
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' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
- '$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' => '&nbsp;', // t('Visible to <strong>everybody</strong>'),
+// '$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.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
+ rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
+ rep(/<span style=\"color:(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
+ rep(/<font>(.*?)<\/font>/gi,"$1");
+ rep(/<img.*?width=\"(.*?)\".*?height=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$1x$2]$3[/img]");
+ rep(/<img.*?height=\"(.*?)\".*?width=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img=$2x$1]$3[/img]");
+ rep(/<img.*?src=\"(.*?)\".*?height=\"(.*?)\".*?width=\"(.*?)\".*?\/>/gi,"[img=$3x$2]$1[/img]");
+ rep(/<img.*?src=\"(.*?)\".*?width=\"(.*?)\".*?height=\"(.*?)\".*?\/>/gi,"[img=$2x$3]$1[/img]");
+ rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
+
+
+ rep(/<ul class=\"listbullet\" style=\"list-style-type\: circle\;\">(.*?)<\/ul>/gi,"[list]$1[/list]");
+ rep(/<ul class=\"listnone\" style=\"list-style-type\: none\;\">(.*?)<\/ul>/gi,"[list=]$1[/list]");
+ rep(/<ul class=\"listdecimal\" style=\"list-style-type\: decimal\;\">(.*?)<\/ul>/gi,"[list=1]$1[/list]");
+ rep(/<ul class=\"listlowerroman\" style=\"list-style-type\: lower-roman\;\">(.*?)<\/ul>/gi,"[list=i]$1[/list]");
+ rep(/<ul class=\"listupperroman\" style=\"list-style-type\: upper-roman\;\">(.*?)<\/ul>/gi,"[list=I]$1[/list]");
+ rep(/<ul class=\"listloweralpha\" style=\"list-style-type\: lower-alpha\;\">(.*?)<\/ul>/gi,"[list=a]$1[/list]");
+ rep(/<ul class=\"listupperalpha\" style=\"list-style-type\: upper-alpha\;\">(.*?)<\/ul>/gi,"[list=A]$1[/list]");
+ rep(/<li>(.*?)<\/li>/gi,"[li]$1[/li]");
+
+ rep(/<code>(.*?)<\/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 style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");
+ rep(/<u>/gi,"[u]");
+ rep(/<blockquote[^>]*>/gi,"[quote]");
+ rep(/<\/blockquote>/gi,"[/quote]");
+ rep(/<hr \/>/gi,"[hr]");
+ rep(/<br (.*?)\/>/gi,"\n");
+ rep(/<br\/>/gi,"\n");
+ rep(/<br>/gi,"\n");
+ rep(/<p>/gi,"");
+ rep(/<\/p>/gi,"\n");
+ rep(/&nbsp;/gi," ");
+ rep(/&quot;/gi,"\"");
+ rep(/&lt;/gi,"<");
+ rep(/&gt;/gi,">");
+ rep(/&amp;/gi,"&");
+
+ return y;
+ };
+
+
{{$geotag}}
</script>