f7942b42ac
Trying to add support for Travis CI. Added the NullUserStore for tests. Moved more text out of the templates. Removed an unnecessary dependency for Cosora. Fixed a few more bugs in the MSSQL Adapter. Disabled upserts for now, as it isn't working on MySQL. Refactored the scheduled group logic to reduce the number of potential bugs and to stop using upserts. Fixed many bugs in the Markdown Plugin. Added the ability to escape Markdown. Fixed a number of tests, commented unneccesary ones, and added new ones to probe for new problems. Added the wink smiley. Cleaned up some of the JavaScript. Refactored the permissions logic to use transactions and avoid duplicating logic. Added the ChangeRank method to the Group struct. Added the ChangeGroup method to the User struct. Added the currently unused LogWarning function. Added the transaction versions of the builder methods. Better ones coming up soon! The IsBanned flag is always set to false on mod and admin groups now. Refactored the group creation logic to use transactions. Fixed a bug in the group creator where new groups aren't visible to Exists(). The installer now drops tables for MySQL Databases, if they already exist to make it easier for us to run automated tests. Added more ARIA Attributes.
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
//+build experiment
|
|
|
|
// ! EXPERIMENTAL
|
|
package main
|
|
|
|
import (
|
|
"errors"
|
|
"regexp"
|
|
)
|
|
|
|
var tagFinder *regexp.Regexp
|
|
|
|
func init() {
|
|
tagFinder = regexp.MustCompile(`(?s)\{\{(.*)\}\}`)
|
|
}
|
|
|
|
func icecreamSoup(tmpl string) error {
|
|
tagIndices := tagFinder.FindAllStringIndex(tmpl, -1)
|
|
if tagIndices != nil && len(tagIndices) > 0 {
|
|
|
|
if tagIndices[0][0] == 0 {
|
|
return errors.New("We don't support tags in the outermost layer yet")
|
|
}
|
|
for _, tagIndex := range tagIndices {
|
|
var nestingLayer = 0
|
|
for i := tagIndex[0]; i > 0; i-- {
|
|
switch tmpl[i] {
|
|
case '>':
|
|
i, closeTag, err := tasteTagToLeft(tmpl, i)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if closeTag {
|
|
nestingLayer++
|
|
}
|
|
case '<':
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func tasteTagToLeft(tmpl string, index int) (indexOut int, closeTag bool, err error) {
|
|
var foundLeftBrace = false
|
|
for ; index > 0; index-- {
|
|
// What if the / isn't adjacent to the < but has a space instead? Is that even valid?
|
|
if index >= 1 && tmpl[index] == '/' && tmpl[index-1] == '<' {
|
|
closeTag = true
|
|
break
|
|
} else if tmpl[index] == '<' {
|
|
foundLeftBrace = true
|
|
}
|
|
}
|
|
if !foundLeftBrace {
|
|
return errors.New("The left portion of the tag is missing")
|
|
}
|
|
return index, closeTag, nil
|
|
}
|