5991a21818
* First batch of changes for the refactor Added the support of gin in routes and other services/utils Begining implementation of JetHTML * Remove os folder * Move scrapers to own repo * Second batch of changes All .jet.html are the working templates. You can now test this PR, the index Page and upload works. If you want to complete the other html templates, you're welcome * Move captcha to util * Move uploadService to utils * Use govalidator instead of regex * Third batch of changes All the front end should as previously. I also fixed some minor things unrelated to the refactor (mostly style issues on static pages) Now errors can be accessed by importing the "errors" helpers and using the `yield errors(name="xxx")` command in templates. Same for infos. Templates are now more hierarchized with a base template "base.jet.html" which is extended depending on the context in "index_site" or "index_admin" layouts. Those layouts are extended than in every pages. Other helpers are captcha to render a captcha `yield captcha(captchaid="xxx")` And also csrf, with the command `yield csrf_field()` To translate, you don't have anymore to do `call $.T "xxx"`, you just have to do `T("xxx")`. Pages for the website part are in folders in the folder "templates/site". Pages for the admin part are in "templates/admin". Layouts are separated in "templates/layouts". Helpers and menu are in "templates/layouts/helpers" and "templates/layouts/menu". Error pages should be put in "templates/errors" * Added test on templates When adding a new template, you have to tell to template_test.go, the context of the new template (if it doesn't use the common context) * Panel admin works Now the templating part should work. The PR can now be fully tested. I think we should push the templating PR and do the routes/controllers/removal of services in another branch. So we know that this one is functional * Updated dependencies * Fixed test for modelhelper * Fix testing for commentlist * Fix travis :') * Just renamed router and removed network * Applying same SEO fix * Update form_validator.go * Added back regexp package
59 lignes
5,2 Kio
Go
59 lignes
5,2 Kio
Go
package validator
|
|
|
|
import "regexp"
|
|
|
|
const (
|
|
alphaRegexString = "^[a-zA-Z]+$"
|
|
alphaNumericRegexString = "^[a-zA-Z0-9]+$"
|
|
numericRegexString = "^[-+]?[0-9]+(?:\\.[0-9]+)?$"
|
|
numberRegexString = "^[0-9]+$"
|
|
hexadecimalRegexString = "^[0-9a-fA-F]+$"
|
|
hexcolorRegexString = "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"
|
|
rgbRegexString = "^rgb\\(\\s*(?:(?:0|[1-9]\\d?|1\\d\\d?|2[0-4]\\d|25[0-5])\\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?:[a-zA-Z]|[\\x{00A0}-\\x{D7FF}\\x{F900}-\\x{FDCF}\\x{FDF0}-\\x{FFEF}])))\\.?$"
|
|
base64RegexString = "^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=|[A-Za-z0-9+\\/]{4})$"
|
|
iSBN10RegexString = "^(?:[0-9]{9}X|[0-9]{10})$"
|
|
iSBN13RegexString = "^(?:(?:97(?:8|9))[0-9]{10})$"
|
|
uUID3RegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-3[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}$"
|
|
uUID4RegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
uUID5RegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
uUIDRegexString = "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
|
|
aSCIIRegexString = "^[\x00-\x7F]*$"
|
|
printableASCIIRegexString = "^[\x20-\x7E]*$"
|
|
multibyteRegexString = "[^\x00-\x7F]"
|
|
dataURIRegexString = "^data:.+\\/(.+);base64$"
|
|
latitudeRegexString = "^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)$"
|
|
longitudeRegexString = "^[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"
|
|
sSNRegexString = `^\d{3}[- ]?\d{2}[- ]?\d{4}$`
|
|
)
|
|
|
|
var (
|
|
alphaRegex = regexp.MustCompile(alphaRegexString)
|
|
alphaNumericRegex = regexp.MustCompile(alphaNumericRegexString)
|
|
numericRegex = regexp.MustCompile(numericRegexString)
|
|
numberRegex = regexp.MustCompile(numberRegexString)
|
|
hexadecimalRegex = regexp.MustCompile(hexadecimalRegexString)
|
|
hexcolorRegex = regexp.MustCompile(hexcolorRegexString)
|
|
rgbRegex = regexp.MustCompile(rgbRegexString)
|
|
rgbaRegex = regexp.MustCompile(rgbaRegexString)
|
|
hslRegex = regexp.MustCompile(hslRegexString)
|
|
hslaRegex = regexp.MustCompile(hslaRegexString)
|
|
emailRegex = regexp.MustCompile(emailRegexString)
|
|
base64Regex = regexp.MustCompile(base64RegexString)
|
|
iSBN10Regex = regexp.MustCompile(iSBN10RegexString)
|
|
iSBN13Regex = regexp.MustCompile(iSBN13RegexString)
|
|
uUID3Regex = regexp.MustCompile(uUID3RegexString)
|
|
uUID4Regex = regexp.MustCompile(uUID4RegexString)
|
|
uUID5Regex = regexp.MustCompile(uUID5RegexString)
|
|
uUIDRegex = regexp.MustCompile(uUIDRegexString)
|
|
aSCIIRegex = regexp.MustCompile(aSCIIRegexString)
|
|
printableASCIIRegex = regexp.MustCompile(printableASCIIRegexString)
|
|
multibyteRegex = regexp.MustCompile(multibyteRegexString)
|
|
dataURIRegex = regexp.MustCompile(dataURIRegexString)
|
|
latitudeRegex = regexp.MustCompile(latitudeRegexString)
|
|
longitudeRegex = regexp.MustCompile(longitudeRegexString)
|
|
sSNRegex = regexp.MustCompile(sSNRegexString)
|
|
)
|