mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-07-15 07:28:10 +00:00
Switched to BBCode language for posts.
This commit is contained in:
README.md
assets
3rdparty
js-bbcode-parser
sceditor
formats
icons
jquery.sceditor.bbcode.min.jsjquery.sceditor.min.jsjquery.sceditor.xhtml.min.jsplugins
sceditor.min.jsthemes
js
system/config
289
assets/3rdparty/js-bbcode-parser/bbcode-config.js
vendored
Normal file
289
assets/3rdparty/js-bbcode-parser/bbcode-config.js
vendored
Normal file
@ -0,0 +1,289 @@
|
||||
/*
|
||||
* Javascript BBCode Parser Config Options
|
||||
* @author Philip Nicolcev
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
var parserColors = [ 'gray', 'silver', 'white', 'yellow', 'orange', 'red', 'fuchsia', 'blue', 'green', 'black', '#cd38d9' ];
|
||||
|
||||
var parserTags = {
|
||||
'b': {
|
||||
openTag: function(params,content) {
|
||||
return '<b>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</b>';
|
||||
}
|
||||
},
|
||||
'code': {
|
||||
openTag: function(params,content) {
|
||||
return '<code>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</code>';
|
||||
},
|
||||
noParse: true
|
||||
},
|
||||
'color': {
|
||||
openTag: function(params,content) {
|
||||
var colorCode = params.substr(1) || "inherit";
|
||||
BBCodeParser.regExpAllowedColors.lastIndex = 0;
|
||||
BBCodeParser.regExpValidHexColors.lastIndex = 0;
|
||||
if ( !BBCodeParser.regExpAllowedColors.test( colorCode ) ) {
|
||||
if ( !BBCodeParser.regExpValidHexColors.test( colorCode ) ) {
|
||||
colorCode = "inherit";
|
||||
} else {
|
||||
if (colorCode.substr(0,1) !== "#") {
|
||||
colorCode = "#" + colorCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '<span style="color:' + colorCode + '">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</span>';
|
||||
}
|
||||
},
|
||||
'i': {
|
||||
openTag: function(params,content) {
|
||||
return '<i>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</i>';
|
||||
}
|
||||
},
|
||||
'img': {
|
||||
openTag: function(params,content) {
|
||||
|
||||
var myUrl = content;
|
||||
|
||||
BBCodeParser.urlPattern.lastIndex = 0;
|
||||
if ( !BBCodeParser.urlPattern.test( myUrl ) ) {
|
||||
myUrl = "";
|
||||
}
|
||||
|
||||
return '<img class="bbCodeImage" src="' + myUrl + '">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '';
|
||||
},
|
||||
content: function(params,content) {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
'list': {
|
||||
openTag: function(params,content) {
|
||||
return '<ul>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</ul>';
|
||||
},
|
||||
restrictChildrenTo: ["*", "li"]
|
||||
},
|
||||
'noparse': {
|
||||
openTag: function(params,content) {
|
||||
return '';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '';
|
||||
},
|
||||
noParse: true
|
||||
},
|
||||
'quote': {
|
||||
openTag: function(params,content) {
|
||||
return '<q>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</q>';
|
||||
}
|
||||
},
|
||||
's': {
|
||||
openTag: function(params,content) {
|
||||
return '<s>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</s>';
|
||||
}
|
||||
},
|
||||
'size': {
|
||||
openTag: function(params,content) {
|
||||
var mySize = parseInt(params.substr(1),10) || 0;
|
||||
if (mySize < 10 || mySize > 20) {
|
||||
mySize = 'inherit';
|
||||
} else {
|
||||
mySize = mySize + 'px';
|
||||
}
|
||||
return '<span style="font-size:' + mySize + '">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</span>';
|
||||
}
|
||||
},
|
||||
'u': {
|
||||
openTag: function(params,content) {
|
||||
return '<span style="text-decoration:underline">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</span>';
|
||||
}
|
||||
},
|
||||
'url': {
|
||||
openTag: function(params,content) {
|
||||
|
||||
var myUrl;
|
||||
|
||||
if (!params) {
|
||||
myUrl = content.replace(/<.*?>/g,"");
|
||||
} else {
|
||||
myUrl = params.substr(1);
|
||||
}
|
||||
|
||||
BBCodeParser.urlPattern.lastIndex = 0;
|
||||
if ( !BBCodeParser.urlPattern.test( myUrl ) ) {
|
||||
myUrl = "#";
|
||||
}
|
||||
|
||||
BBCodeParser.urlPattern.lastIndex = 0;
|
||||
if ( !BBCodeParser.urlPattern.test( myUrl ) ) {
|
||||
myUrl = "";
|
||||
}
|
||||
|
||||
return '<a href="' + myUrl + '">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</a>';
|
||||
}
|
||||
},
|
||||
|
||||
//COMUNIC ADD BEGIN
|
||||
|
||||
'left': {
|
||||
openTag: function(params,content) {
|
||||
return '<p style="text-align: left;">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</p>';
|
||||
}
|
||||
},
|
||||
|
||||
'center': {
|
||||
openTag: function(params,content) {
|
||||
return '<p style="text-align: center;">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</p>';
|
||||
}
|
||||
},
|
||||
|
||||
'right': {
|
||||
openTag: function(params,content) {
|
||||
return '<p style="text-align: right;">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</p>';
|
||||
}
|
||||
},
|
||||
|
||||
'justify': {
|
||||
openTag: function(params,content) {
|
||||
return '<p style="text-align: justify;">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</p>';
|
||||
}
|
||||
},
|
||||
|
||||
'ul': {
|
||||
openTag: function(params,content) {
|
||||
return '<ul>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</ul>';
|
||||
}
|
||||
},
|
||||
|
||||
'ol': {
|
||||
openTag: function(params,content) {
|
||||
return '<ol>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</ol>';
|
||||
}
|
||||
},
|
||||
|
||||
'li': {
|
||||
openTag: function(params,content) {
|
||||
return '<li>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</li>';
|
||||
}
|
||||
},
|
||||
|
||||
'sup': {
|
||||
openTag: function(params,content) {
|
||||
return '<sup>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</sup>';
|
||||
}
|
||||
},
|
||||
|
||||
'sub': {
|
||||
openTag: function(params,content) {
|
||||
return '<sub>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</sub>';
|
||||
}
|
||||
},
|
||||
|
||||
'ltr': {
|
||||
openTag: function(params,content) {
|
||||
return '<div style="text-align: left;">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</div>';
|
||||
}
|
||||
},
|
||||
|
||||
'rtl': {
|
||||
openTag: function(params,content) {
|
||||
return '<div style="text-align: right;">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</div>';
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
'table': {
|
||||
openTag: function(params,content) {
|
||||
return '<table border="1" style="margin: auto;">';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</table>';
|
||||
}
|
||||
},
|
||||
|
||||
'tr': {
|
||||
openTag: function(params,content) {
|
||||
return '<tr>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</tr>';
|
||||
}
|
||||
},
|
||||
|
||||
'td': {
|
||||
openTag: function(params,content) {
|
||||
return '<td>';
|
||||
},
|
||||
closeTag: function(params,content) {
|
||||
return '</td>';
|
||||
}
|
||||
},
|
||||
|
||||
//COMUNIC ADD END
|
||||
};
|
152
assets/3rdparty/js-bbcode-parser/bbcode-parser.js
vendored
Normal file
152
assets/3rdparty/js-bbcode-parser/bbcode-parser.js
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Javascript BBCode Parser
|
||||
* @author Philip Nicolcev
|
||||
* @license MIT License
|
||||
*/
|
||||
|
||||
var BBCodeParser = (function(parserTags, parserColors) {
|
||||
'use strict';
|
||||
|
||||
var me = {},
|
||||
urlPattern = /^(?:https?|file|c):(?:\/{1,3}|\\{1})[-a-zA-Z0-9:;@#%&()~_?\+=\/\\\.]*$/,
|
||||
emailPattern = /[^\s@]+@[^\s@]+\.[^\s@]+/,
|
||||
fontFacePattern = /^([a-z][a-z0-9_]+|"[a-z][a-z0-9_\s]+")$/i,
|
||||
tagNames = [],
|
||||
tagNamesNoParse = [],
|
||||
regExpAllowedColors,
|
||||
regExpValidHexColors = /^#?[a-fA-F0-9]{6}$/,
|
||||
ii, tagName, len;
|
||||
|
||||
// create tag list and lookup fields
|
||||
for (tagName in parserTags) {
|
||||
if (!parserTags.hasOwnProperty(tagName))
|
||||
continue;
|
||||
|
||||
if (tagName === '*') {
|
||||
tagNames.push('\\' + tagName);
|
||||
} else {
|
||||
tagNames.push(tagName);
|
||||
if ( parserTags[tagName].noParse ) {
|
||||
tagNamesNoParse.push(tagName);
|
||||
}
|
||||
}
|
||||
|
||||
parserTags[tagName].validChildLookup = {};
|
||||
parserTags[tagName].validParentLookup = {};
|
||||
parserTags[tagName].restrictParentsTo = parserTags[tagName].restrictParentsTo || [];
|
||||
parserTags[tagName].restrictChildrenTo = parserTags[tagName].restrictChildrenTo || [];
|
||||
|
||||
len = parserTags[tagName].restrictChildrenTo.length;
|
||||
for (ii = 0; ii < len; ii++) {
|
||||
parserTags[tagName].validChildLookup[ parserTags[tagName].restrictChildrenTo[ii] ] = true;
|
||||
}
|
||||
len = parserTags[tagName].restrictParentsTo.length;
|
||||
for (ii = 0; ii < len; ii++) {
|
||||
parserTags[tagName].validParentLookup[ parserTags[tagName].restrictParentsTo[ii] ] = true;
|
||||
}
|
||||
}
|
||||
|
||||
regExpAllowedColors = new RegExp('^(?:' + parserColors.join('|') + ')$');
|
||||
|
||||
/*
|
||||
* Create a regular expression that captures the innermost instance of a tag in an array of tags
|
||||
* The returned RegExp captures the following in order:
|
||||
* 1) the tag from the array that was matched
|
||||
* 2) all (optional) parameters included in the opening tag
|
||||
* 3) the contents surrounded by the tag
|
||||
*
|
||||
* @param {type} tagsArray - the array of tags to capture
|
||||
* @returns {RegExp}
|
||||
*/
|
||||
function createInnermostTagRegExp(tagsArray) {
|
||||
var openingTag = '\\[(' + tagsArray.join('|') + ')\\b(?:[ =]([\\w"#\\-\\:\\/= ]*?))?\\]',
|
||||
notContainingOpeningTag = '((?:(?=([^\\[]+))\\4|\\[(?!\\1\\b(?:[ =](?:[\\w"#\\-\\:\\/= ]*?))?\\]))*?)',
|
||||
closingTag = '\\[\\/\\1\\]';
|
||||
|
||||
return new RegExp( openingTag + notContainingOpeningTag + closingTag, 'i');
|
||||
}
|
||||
|
||||
/*
|
||||
* Escape the contents of a tag and mark the tag with a null unicode character.
|
||||
* To be used in a loop with a regular expression that captures tags.
|
||||
* Marking the tag prevents it from being matched again.
|
||||
*
|
||||
* @param {type} matchStr - the full match, including the opening and closing tags
|
||||
* @param {type} tagName - the tag that was matched
|
||||
* @param {type} tagParams - parameters passed to the tag
|
||||
* @param {type} tagContents - everything between the opening and closing tags
|
||||
* @returns {String} - the full match with the tag contents escaped and the tag marked with \u0000
|
||||
*/
|
||||
function escapeInnerTags(matchStr, tagName, tagParams, tagContents) {
|
||||
tagParams = tagParams || "";
|
||||
tagContents = tagContents || "";
|
||||
tagContents = tagContents.replace(/\[/g, "[").replace(/\]/g, "]");
|
||||
return "[\u0000" + tagName + tagParams + "]" + tagContents + "[/\u0000" + tagName + "]";
|
||||
}
|
||||
|
||||
/*
|
||||
* Escape all BBCodes that are inside the given tags.
|
||||
*
|
||||
* @param {string} text - the text to search through
|
||||
* @param {string[]} tags - the tags to search for
|
||||
* @returns {string} - the full text with the required code escaped
|
||||
*/
|
||||
function escapeBBCodesInsideTags(text, tags) {
|
||||
var innerMostRegExp;
|
||||
if (tags.length === 0 || text.length < 7)
|
||||
return text;
|
||||
innerMostRegExp = createInnermostTagRegExp(tags);
|
||||
while (
|
||||
text !== (text = text.replace(innerMostRegExp, escapeInnerTags))
|
||||
);
|
||||
return text.replace(/\u0000/g,'');
|
||||
}
|
||||
|
||||
/*
|
||||
* Process a tag and its contents according to the rules provided in parserTags.
|
||||
*
|
||||
* @param {type} matchStr - the full match, including the opening and closing tags
|
||||
* @param {type} tagName - the tag that was matched
|
||||
* @param {type} tagParams - parameters passed to the tag
|
||||
* @param {type} tagContents - everything between the opening and closing tags
|
||||
* @returns {string} - the fully processed tag and its contents
|
||||
*/
|
||||
function replaceTagsAndContent(matchStr, tagName, tagParams, tagContents) {
|
||||
tagName = tagName.toLowerCase();
|
||||
tagParams = tagParams || "";
|
||||
tagContents = tagContents || "";
|
||||
return parserTags[tagName].openTag(tagParams, tagContents) + (parserTags[tagName].content ? parserTags[tagName].content(tagParams, tagContents) : tagContents) + parserTags[tagName].closeTag(tagParams, tagContents);
|
||||
}
|
||||
|
||||
function processTags(text, tagNames) {
|
||||
var innerMostRegExp;
|
||||
|
||||
if (tagNames.length === 0 || text.length < 7)
|
||||
return text;
|
||||
|
||||
innerMostRegExp = createInnermostTagRegExp(tagNames);
|
||||
|
||||
while (
|
||||
text !== (text = text.replace(innerMostRegExp, replaceTagsAndContent))
|
||||
);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/*
|
||||
* Public Methods and Properties
|
||||
*/
|
||||
me.process = function(text, config) {
|
||||
text = escapeBBCodesInsideTags(text, tagNamesNoParse);
|
||||
|
||||
return processTags(text, tagNames);
|
||||
};
|
||||
|
||||
me.allowedTags = tagNames;
|
||||
me.urlPattern = urlPattern;
|
||||
me.emailPattern = emailPattern;
|
||||
me.regExpAllowedColors = regExpAllowedColors;
|
||||
me.regExpValidHexColors = regExpValidHexColors;
|
||||
|
||||
return me;
|
||||
})(parserTags, parserColors);
|
Reference in New Issue
Block a user