Added rate limiting and server security
Ton of little visual style tweaks and little up improvements for mobile
This commit is contained in:
@@ -26,6 +26,17 @@ ProcessText.stripBlankHtmlLines = (string) => {
|
||||
return string.replace(/\<p\>\<br\>\<\/p\>/g,'')
|
||||
}
|
||||
|
||||
//Remove Double Empty HTML lines from a string
|
||||
ProcessText.stripDoubleBlankLines = (string) => {
|
||||
|
||||
if(string == undefined || string == null || string.length == 0){
|
||||
return ''
|
||||
}
|
||||
|
||||
//Blank lines look like this -> <p><br></p>
|
||||
return string.replace(/\<p\>\<br\>\<\/p\>\<p\>\<br\>\<\/p\>/g,'')
|
||||
}
|
||||
|
||||
ProcessText.getUrlsFromString = (string) => {
|
||||
const urlPattern = /(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#/%=~_|$?!:,.]*\)|[A-Z0-9+&@#/%=~_|$])/igm
|
||||
return string.match(urlPattern)
|
||||
@@ -41,11 +52,16 @@ ProcessText.getUrlsFromString = (string) => {
|
||||
+ If note starts as a list, skip the title
|
||||
*/
|
||||
|
||||
ProcessText.deduceNoteTitle = (inString) => {
|
||||
ProcessText.deduceNoteTitle = (inTitle, inString) => {
|
||||
|
||||
let title = '' //Title of note
|
||||
let title = inTitle //Title of note
|
||||
let sub = '' //sub text below note
|
||||
|
||||
//Always return a title as a String
|
||||
if(title == null){
|
||||
title = ''
|
||||
}
|
||||
|
||||
if(!inString || inString == null || inString.length == 0){
|
||||
return {title, sub}
|
||||
}
|
||||
@@ -55,16 +71,17 @@ ProcessText.deduceNoteTitle = (inString) => {
|
||||
|
||||
const tagFreeLength = ProcessText.removeHtml(inString).length
|
||||
|
||||
if(tagFreeLength < 100){
|
||||
sub = ProcessText.stripBlankHtmlLines(inString)
|
||||
return {title, sub}
|
||||
//
|
||||
// Simplified attempt!
|
||||
// Remove tags, push caret if greater than 200 chars...thats it
|
||||
// Still needs, links to open in a new window.
|
||||
|
||||
sub = ProcessText.stripDoubleBlankLines(inString)
|
||||
if(tagFreeLength > 200){
|
||||
sub += '... <i class="green caret down icon"></i>'
|
||||
}
|
||||
|
||||
//Primare Case - Short notes
|
||||
if(tagFreeLength < 300){
|
||||
sub = ProcessText.stripBlankHtmlLines(inString)
|
||||
return {title, sub}
|
||||
}
|
||||
return {title, sub}
|
||||
|
||||
//Emergency ending tag if truncated. This will help regex find all the lines
|
||||
inString += '</end>'
|
||||
@@ -87,6 +104,7 @@ ProcessText.deduceNoteTitle = (inString) => {
|
||||
let charLimit = 400
|
||||
let listStart = false
|
||||
let noTitleJustList = false
|
||||
let appendCaret = false
|
||||
|
||||
for(let i=0; i < totalLines; i++){
|
||||
|
||||
@@ -167,8 +185,8 @@ ProcessText.deduceNoteTitle = (inString) => {
|
||||
if(cleanCutString.length == 0){
|
||||
cleanCutString = cutString
|
||||
}
|
||||
|
||||
finalLines.push(cleanCutString + '... <i class="green caret down icon"></i>')
|
||||
appendCaret = true
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -176,9 +194,13 @@ ProcessText.deduceNoteTitle = (inString) => {
|
||||
|
||||
}
|
||||
|
||||
if(tagFreeLength.length >= 300 || appendCaret){
|
||||
finalLines.push('... <i class="green caret down icon"></i>')
|
||||
}
|
||||
|
||||
//Pull out title if its not an empty string
|
||||
if(ProcessText.removeHtml(finalLines[0]).trim().replace(' ','').length > 0 && !noTitleJustList){
|
||||
// title = finalLines.shift()
|
||||
if(!noTitleJustList && title == ''){
|
||||
title = ProcessText.removeHtml( finalLines.shift() ).replace(' ','')
|
||||
}
|
||||
|
||||
sub = finalLines.join('')
|
||||
|
Reference in New Issue
Block a user