本文整理汇总了Golang中github.com/kennygrant/sanitize.HTML函数的典型用法代码示例。如果您正苦于以下问题:Golang HTML函数的具体用法?Golang HTML怎么用?Golang HTML使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HTML函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ReviewedProduct
// ReviewedProduct returns the string of the reviewed thing in a best-effort way.
func (article *Article) ReviewedProduct() string {
if len(article.Front.Article.Products) == 0 {
return ""
}
if article.Front.Article.Products[0].Source.Value != "" {
return strings.TrimSpace(sanitize.HTML(article.Front.Article.Products[0].Source.Value))
}
// refs. #7111
if article.Front.Article.Products[0].StringName.Value != "" {
return strings.TrimSpace(sanitize.HTML(article.Front.Article.Products[0].StringName.Value))
}
return ""
}
开发者ID:ubleipzig,项目名称:span,代码行数:14,代码来源:jstor.go
示例2: listenDeploys
func listenDeploys(lastMarker string, commandMsgs chan<- models.Message, connector models.Connector) (nextMarker string) {
now := time.Now()
nextMarker = strconv.FormatInt(now.Unix(), 10) + "000"
if connector.Debug {
log.Print("Calling deploy results with last marker: " + lastMarker)
}
d := bambooapi.DeployResults(connector.Server, connector.Login, connector.Pass)
for _, de := range d {
for _, e := range de.Environmentstatuses {
buildTime := strconv.FormatInt(e.Deploymentresult.Finisheddate, 10)
if e.Deploymentresult.ID > 0 && buildTime > lastMarker {
var m models.Message
m.In.ConnectorType = connector.Type
m.In.ConnectorID = connector.ID
m.In.Tags = connector.Tags
m.In.Process = false
m.Out.Text = "Bamboo Deploy " + e.Deploymentresult.Deploymentversion.Planbranchname + " " + e.Deploymentresult.Deploymentversion.Name + " to " + e.Environment.Name + " " + e.Deploymentresult.Deploymentstate
m.Out.Detail = html.UnescapeString(sanitize.HTML(e.Deploymentresult.Reasonsummary))
m.Out.Link = "https://" + connector.Server + "/builds/deploy/viewDeploymentResult.action?deploymentResultId=" + strconv.Itoa(e.Deploymentresult.ID)
if e.Deploymentresult.Deploymentstate == "SUCCESS" {
m.Out.Status = "SUCCESS"
} else {
m.Out.Status = "FAIL"
}
commandMsgs <- m
}
}
}
return nextMarker
}
开发者ID:projectjane,项目名称:jane,代码行数:30,代码来源:bamboo.go
示例3: TutorialNouvCommHandler
// Public function
// permet d'ajouter un commenaire sur la page tutoriel
func TutorialNouvCommHandler(w http.ResponseWriter, r *http.Request) {
// Validation des données
// Si une des variables est vide, la func retourne un "error"
// ce qui fait afficher un message d'erreur
if r.PostFormValue("val_commentaire") == "" ||
r.PostFormValue("val_post_id") == "" ||
r.PostFormValue("val_auteur_id") == "" ||
r.PostFormValue("val_auteur_id") == "0" {
// envoie un message d'erreur
renderString(w, "error")
} else {
// initialise l'objet ForumPost et récupère les données du formulaire
var tp TutorialPost
tp.TutorialId, _ = ParseInt(r.PostFormValue("val_post_id"), 0, 64)
tp.UserId, _ = ParseInt(r.PostFormValue("val_auteur_id"), 0, 64)
tp.Text = sanitize.HTML(r.PostFormValue("val_commentaire"))
tp.IsOnline = 1
tp.Id = tp.Save()
// permet de récuprérer le nom de l'utilisateur
var u User
u.Id = tp.UserId
u = u.GetById()
// permet de convertir la date de la personne qui a posté la réponse
t := time.Now()
date := t.Format(dateLayout)
// String qui contient d'abord l'auteur du commentaire
// puis son commentaire complet, séparés par ":::"
commData := u.FirstName + " " + u.LastName + ":::" + date + ":::" + tp.Text + ":::" + Itoa(int(tp.Id))
renderString(w, commData)
}
}
开发者ID:konginteractive,项目名称:cme,代码行数:33,代码来源:tutorial.go
示例4: main
func main() {
flag.Usage = usage
flag.Parse()
args := flag.Args()
if len(args) != 1 {
usage()
}
url := args[0]
key := os.Getenv("READABILITY_PARSER_API_KEY")
if key == "" {
printMissingKeyMessage()
}
parser := readability.NewParserClient(key)
article, resp, err := parser.Parse(url)
if resp != nil && resp.StatusCode == 400 {
usage()
}
if err != nil {
printError(err)
}
content := sanitize.HTML(article.Content)
// remove vertical whitespace
r := regexp.MustCompile("[\n]{2,}")
content = r.ReplaceAllString(content, "")
// remove horizontal whitespace
content = strings.Replace(content, " ", "", -1)
fmt.Println(article.Title + "\n")
fmt.Println(strings.Replace(strings.TrimSpace(content), "\n", "\n\n", -1))
}
开发者ID:robinjmurphy,项目名称:rd,代码行数:29,代码来源:rd.go
示例5: Check
func (s *Service) Check(id string) (status string, err error) {
body, err := s.Downloader(s.URL, id)
if err != nil {
return
}
if s.Extractor != nil {
parts := s.Extractor.FindSubmatch(body)
if parts == nil {
return "", nil
}
status = string(parts[1])
} else {
doc, err := gokogiri.ParseHtml(body)
if err != nil {
return "", err
}
defer doc.Free()
res, err := doc.Search(s.XPath)
if err != nil {
return "", err
}
if len(res) < 1 {
return "", nil
}
status = sanitize.HTML(res[0].String())
status = replacer.ReplaceAllString(status, " ")
status = strings.TrimSpace(status)
}
return
}
开发者ID:drbig,项目名称:golang,代码行数:35,代码来源:kurier.go
示例6: Google
func (bot *Bot) Google(query, channel string) {
r, err := http.Get("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=1&q=" + query)
defer r.Body.Close()
if err != nil {
log.Println(err)
}
if r.StatusCode != http.StatusOK {
log.Println(r.Status)
}
//create a custom struct for the json response
//somehow Go magically transplants the response data into this
var google struct {
ResponseData struct {
Results []struct {
TitleNoFormatting string
Content string
URL string
}
}
}
//parse response body json to Go
dec := json.NewDecoder(r.Body)
dec.Decode(&google)
//output results to channel
for _, item := range google.ResponseData.Results {
//fixme: sending commands
content := sanitize.Accents(sanitize.HTML(item.Content))
bot.SendMessage(item.TitleNoFormatting+" "+item.URL+" "+content, channel)
}
}
开发者ID:Pent,项目名称:bot,代码行数:34,代码来源:bot.go
示例7: listenBuilds
func listenBuilds(lastMarker string, commandMsgs chan<- models.Message, connector models.Connector) (nextMarker string) {
var displayOnStart = 0
url := "https://" + connector.Login + ":" + connector.Pass + "@"
url += connector.Server + "/builds/plugins/servlet/streams?local=true"
feed, err := rss.Fetch(url)
if err != nil {
log.Print(err)
return
}
for i := len(feed.Items) - 1; i >= 0; i-- {
if connector.Debug {
log.Print("Bamboo " + connector.ID + " item #" + strconv.Itoa(i) + " marker " + feed.Items[i].Date.String())
}
if lastMarker == "" {
lastMarker = feed.Items[displayOnStart].Date.String()
}
item := feed.Items[i]
if item.Date.String() > lastMarker {
status := "NONE"
if strings.Contains(item.Title, "successful") {
status = "SUCCESS"
}
if strings.Contains(item.Title, "fail") {
status = "FAIL"
}
var m models.Message
m.In.ConnectorType = connector.Type
m.In.ConnectorID = connector.ID
m.In.Tags = connector.Tags
m.In.Process = false
m.Out.Text = "Bamboo Build " + html.UnescapeString(sanitize.HTML(item.Title))
m.Out.Detail = html.UnescapeString(sanitize.HTML(item.Content))
m.Out.Link = item.Link
m.Out.Status = status
commandMsgs <- m
if i == 0 {
lastMarker = item.Date.String()
}
}
}
nextMarker = lastMarker
return nextMarker
}
开发者ID:projectjane,项目名称:jane,代码行数:43,代码来源:bamboo.go
示例8: callRss
func callRss(lastMarker string, commandMsgs chan<- models.Message, connector models.Connector) (nextMarker string) {
var displayOnStart = 0
if connector.Debug {
log.Print("Starting rss feed fetch for " + connector.ID)
}
feed, err := rss.Fetch(connector.Server)
if err != nil {
log.Print(err)
return
}
if connector.Debug {
log.Print("Feed count for " + connector.ID + ": " + strconv.Itoa(len(feed.Items)))
}
for i := len(feed.Items) - 1; i >= 0; i-- {
if connector.Debug {
log.Print("Feed " + connector.ID + " item #" + strconv.Itoa(i) + " marker " + feed.Items[i].Date.String())
}
if lastMarker == "" {
lastMarker = feed.Items[displayOnStart].Date.String()
}
item := feed.Items[i]
if item.Date.String() > lastMarker {
var m models.Message
m.In.ConnectorType = connector.Type
m.In.ConnectorID = connector.ID
m.In.Tags = connector.Tags
m.In.Process = false
m.Out.Text = connector.ID + " " + html.UnescapeString(sanitize.HTML(item.Title))
m.Out.Detail = html.UnescapeString(sanitize.HTML(item.Content))
m.Out.Link = item.Link
commandMsgs <- m
if i == 0 {
lastMarker = item.Date.String()
}
}
}
nextMarker = lastMarker
if connector.Debug {
log.Print("Next marker for " + connector.ID + ": " + nextMarker)
}
return nextMarker
}
开发者ID:projectjane,项目名称:jane,代码行数:42,代码来源:rss.go
示例9: reader
func (c *connection) reader() {
for {
_, message, err := c.ws.ReadMessage()
if err != nil {
break
}
hello := strings.Split(sanitize.HTML(string(message)), "|")
ck.Put(hello[0], hello[1])
}
c.ws.Close()
}
开发者ID:jeffchan,项目名称:pushydb,代码行数:11,代码来源:conn.go
示例10: UPCreateAjaxHandler
// permet de créer un userProject à partir d'un formulaire HTML
// et permet d'uploader une image associée
// et permet de croper l'image en fonction de sa vignette
func UPCreateAjaxHandler(w http.ResponseWriter, r *http.Request) {
// création d'un user project
var up UserProject
// récupère l'id du user
UserId, err := ParseInt(r.PostFormValue("id_user"), 0, 64)
if err != nil {
// envoie un message d'erreur
renderString(w, "error")
}
up.UserId = UserId
// crécuprère l'id de la cat
up.UserProjectCategoryId, err = ParseInt(r.PostFormValue("id_cat"), 0, 64)
if err != nil {
// envoie un message d'erreur
renderString(w, "error")
}
// récupère le titre
up.Title = sanitize.HTML(r.PostFormValue("title"))
// récupère la description
up.Description = sanitize.HTML(r.PostFormValue("Description"))
// permet d'uploader l'image
up.Url, err = UploadImage(URL_PROJECT_IMAGES, r)
if err != nil {
// envoie un message d'erreur
renderString(w, "error")
}
// permet de cropper l'image qui viens d'être uploadée
err = CropImage(up.Url, 300, 300)
if err != nil {
// envoie un message d'erreur
renderString(w, "error")
}
// finit de créer l'objet
// définit le projet non visible
up.IsOnline = 0
// sauvegarde dans la base de donnée
up.Id = up.Save()
// retourne l'objet en JSON
renderJson(w, up)
}
开发者ID:konginteractive,项目名称:cme,代码行数:44,代码来源:user_project.go
示例11: loadTemplate
// loadTemplate load template from tpls/%s.tpl
func loadTemplate(Name string) *html.Template {
funcMap := html.FuncMap{
"html": func(val interface{}) html.HTML {
switch value := val.(type) {
case string:
{
return html.HTML(value)
}
case html.HTML:
{
return value
}
default:
return html.HTML("Unsupported type for HTML pipeline")
}
},
"typo": func(val string) string {
return typo.Typo(val)
},
"striptags": func(val string) string {
return sanitize.HTML(val)
},
// TODO: в разработке
/*"mod": func(args ...interface{}) interface{} {
if len(args) == 0 {
return ""
}
name := args[0].(string)
ctx := new(context.Context)
if len(args) > 1 {
ctx = args[1].(*context.Context)
}
modules := reflect.ValueOf(modules.Get())
mod := modules.MethodByName(name)
if (mod == reflect.Value{}) {
return ""
}
inputs := make([]reflect.Value, 0)
inputs = append(inputs, reflect.ValueOf(ctx))
ret := mod.Call(inputs)
return ret[0].Interface()
},*/
}
return html.Must(html.New("*").Funcs(funcMap).Delims("{{%", "%}}").ParseFiles("tpls/" + Name + ".tpl"))
}
开发者ID:x4rMa,项目名称:webapp,代码行数:54,代码来源:doc.go
示例12: getWords
func getWords(s string) []string {
// Remove all html tags and such
plainText := sanitize.HTML(s)
// Remove all weird characters such as `"^ and so on that are not alphanumeric or spaces
plainText = nonLetters.ReplaceAllString(plainText, "")
// Replace all whitespace with 1 regular space
plainText = whitespace.ReplaceAllString(plainText, " ")
// Split the plaintext via the single space
return strings.Split(plainText, " ")
}
开发者ID:sfro,项目名称:wordcloud,代码行数:13,代码来源:words.go
示例13: MinimalStandard
//MinimalStandard returns a cleaned up standard
func (item XMLLearningStandardItem) MinimalStandard() MinimalStandard {
standard := MinimalStandard{}
if len(item.StatementCodes) > 0 {
standard.Code = item.StatementCodes[0]
}
standard.Grades = item.GradeLevels
if len(item.Statements) > 0 {
standard.Text = sanitize.HTML(item.Statements[0])
}
return standard
}
开发者ID:Jwsonic,项目名称:CoreStandardsTools,代码行数:14,代码来源:corestandards.go
示例14: getCorrection
func getCorrection(engine string, queryString string, c chan correctionResult) {
resp, _ := http.Get(buildUrl(engine, queryString))
page, _ := ioutil.ReadAll(resp.Body)
doc, _ := gokogiri.ParseHtml(page)
suggestedTermResult, err := doc.Root().Search(searchEngines[engine].suggestedTermQuery)
suggestedTerm := "NULL"
if err == nil && len(suggestedTermResult) > 0 {
suggestedTerm = fmt.Sprintf("%v", suggestedTermResult[0])
} else if err != nil {
fmt.Println(err)
}
topLinkResult, err := doc.Root().Search(searchEngines[engine].topLinkQuery)
topLink := "NULL"
if err == nil && len(topLinkResult) > 0 {
topLink = fmt.Sprintf("%v", topLinkResult[0])
} else if err != nil {
fmt.Println(err)
}
topTitleResult, err := doc.Root().Search(searchEngines[engine].topTitleQuery)
topTitle := "NULL"
if err == nil && len(topTitleResult) > 0 {
topTitle = fmt.Sprintf("%v", topTitleResult[0])
} else if err != nil {
fmt.Println(err)
}
doc.Free()
c <- correctionResult{
engine: engine,
SuggestedTerm: sanitize.HTML(suggestedTerm),
TopLink: strings.TrimSpace(sanitize.HTML(topLink)),
TopTitle: strings.TrimSpace(sanitize.HTML(topTitle)),
StatusCode: resp.StatusCode,
}
}
开发者ID:charlieegan3,项目名称:sirjest,代码行数:38,代码来源:server.go
示例15: GetIdeas
func GetIdeas() []map[string]interface{} {
var (
id int
name string
email string
link string
content string
timestamp int
)
ideas := make([]map[string]interface{}, 0)
rows, _ := db.Query(`select id, name, email, link, content, strftime("%s", create_time) from idea order by id desc`)
defer rows.Close()
for rows.Next() {
err := rows.Scan(&id, &name, &email, &link, &content, ×tamp)
if err != nil {
log.Fatal(err)
}
name = sanitize.HTML(name)
email = sanitize.HTML(email)
link = sanitize.HTML(link)
content = sanitize.HTML(content)
log.Println("Original content: " + content)
html := string(blackfriday.MarkdownCommon([]byte(content)))
log.Println("Converted: " + html)
ideas = append(ideas, map[string]interface{}{
"id": id,
"name": name,
"email": email,
"link": link,
"content": content,
"html": html,
"timestamp": timestamp,
})
}
return ideas
}
开发者ID:imdreamrunner,项目名称:orz,代码行数:38,代码来源:main.go
示例16: Convert
// Export method from intermediate schema to solr 4/13 schema.
func (s *Solr4Vufind13v1) Convert(is finc.IntermediateSchema) error {
s.Allfields = is.Allfields()
s.Formats = append(s.Formats, is.Format)
s.Fullrecord = "blob:" + is.RecordID
s.Fulltext = is.Fulltext
s.HierarchyParentTitle = append(s.HierarchyParentTitle, is.JournalTitle)
s.ID = is.RecordID
s.Imprint = is.Imprint()
s.ISSN = is.ISSNList()
s.MegaCollections = append(s.MegaCollections, is.MegaCollection)
s.PublishDateSort = is.Date.Year()
s.Publishers = is.Publishers
s.RecordType = finc.AIRecordType
s.Series = append(s.Series, is.JournalTitle)
s.SourceID = is.SourceID
s.Subtitle = is.ArticleSubtitle
s.TitleSort = is.SortableTitle()
s.Topics = is.Subjects
s.URL = is.URL
classes := container.NewStringSet()
for _, s := range is.Subjects {
for _, class := range SubjectMapping.LookupDefault(s, []string{}) {
classes.Add(class)
}
}
s.FincClassFacet = classes.Values()
sanitized := sanitize.HTML(is.ArticleTitle)
s.Title, s.TitleFull, s.TitleShort = sanitized, sanitized, sanitized
for _, lang := range is.Languages {
s.Languages = append(s.Languages, LanguageMap.LookupDefault(lang, lang))
}
for _, author := range is.Authors {
s.SecondaryAuthors = append(s.SecondaryAuthors, author.String())
s.AuthorFacet = append(s.AuthorFacet, author.String())
}
if len(s.SecondaryAuthors) > 0 {
s.Author = s.SecondaryAuthors[0]
}
s.AccessFacet = AIAccessFacet
s.FormatDe15 = []string{FormatDe15.LookupDefault(is.Format, "")}
return nil
}
开发者ID:voxadam,项目名称:span,代码行数:50,代码来源:solr4vu13v1.go
示例17: Extract
// Extract Wesite Content
func Extract(url string) (bookmark *models.Bookmark, err error) {
c := make(chan string)
go extractTitle(url, c)
go extractReadableContent(url, c)
title, firstParagraph, readableContent := <-c, <-c, <-c
return &models.Bookmark{
URL: url,
Title: title,
FirstParagraph: firstParagraph,
ReadableContent: readableContent,
SearchableContent: sanitize.HTML(readableContent),
}, nil
}
开发者ID:marpio,项目名称:ownPocket,代码行数:16,代码来源:extractor.go
示例18: getArticleWithSentences
func getArticleWithSentences(uuid string) *ArticleWithSentences {
// article := capi.GetArticle(uuid)
article := content.GetArticle(uuid)
tidyBody := sanitize.HTML(article.Body)
sentences := splitTextIntoSentences(tidyBody)
// for _, s := range *sentences {
// fmt.Println("main: s=", s)
// }
aws := ArticleWithSentences{
article,
sentences,
}
return &aws
}
开发者ID:railsagainstignorance,项目名称:alignment,代码行数:18,代码来源:article.go
示例19: jeopardyCategory
func jeopardyCategory(echoReq *alexa.EchoRequest, session *JeopardySession) (*alexa.EchoResponse, *JeopardySession) {
msg := ""
echoResp := alexa.NewEchoResponse()
// Declare the category
category, err := echoReq.GetSlotValue("Category")
_, catExists := JeopardyCategories[category]
if err != nil || !catExists {
catNames := []string{}
for k, _ := range JeopardyCategories {
catNames = append(catNames, k)
}
category = getRandom(catNames)
msg = msg + getRandom(JeopardyCatSelect) + category + ". "
} else {
category = strings.ToLower(category)
}
clue, err := getJServiceClue(JeopardyCategories[category])
if err != nil {
clue, err = getJServiceClue(JeopardyCategories[category])
if err != nil {
echoResp := alexa.NewEchoResponse().OutputSpeech("I'm sorry, but I can't seem to get a question right now.").EndSession(true)
return echoResp, session
}
}
msg += "From " + category + " for " + strconv.Itoa(clue.Value) + ". " + clue.Question + ". I need your answer in the form of a question."
session.CurrentQuestion.Category = category
session.CurrentQuestion.Answer = sanitize.HTML(clue.Answer)
session.CurrentQuestion.Question = clue.Question
session.CurrentQuestion.Value = clue.Value
log.Println(session.CurrentQuestion.Question)
log.Println(session.CurrentQuestion.Answer)
echoResp.OutputSpeech(msg).Card("Question", msg).Reprompt("Times up. I need your answer in the form of a question.").EndSession(false)
return echoResp, session
}
开发者ID:mikeflynn,项目名称:go-alexa,代码行数:43,代码来源:jeopardy.go
示例20: injectDataToDisplay
// fonction privée
// Permet de retrouver le nombre de réponses pour chaque post
// Permet aussi de réduire la description du texte de desc à 250 caractères
func (pf PageForumList) injectDataToDisplay(forums []Forum) []Forum {
lenForum := len(forums)
for i := 0; i < lenForum; i++ {
id := forums[i].Id
// permet de réaliser des extraits si le texte est trop long
extrait := sanitize.HTML(forums[i].Text)
if len(extrait) > 250 {
extrait = extrait[0:250]
}
forums[i].Text = "<p>" + extrait + "</p>"
// permet de compter ne nombres de réponses
forums[i].PostNumb = forums[i].CountPost(id)
// permet de créer une url du lien
forums[i].Url = "/forum/post/" + Itoa(int(forums[i].Id))
}
return forums
}
开发者ID:konginteractive,项目名称:cme,代码行数:22,代码来源:forum_list.go
注:本文中的github.com/kennygrant/sanitize.HTML函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论