Beispiel #1
0
func (b *ListController) Prepare() {
	website = conf.GetConf().WebSite

	b.Ctx.Request.Header.Add("Access-Control-Allow-Origin", "*")

	// 验证是否来自合法域名访问
	if !b.IsAllowHost() {
		b.Ctx.WriteString(`<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=` +
			website.HostUrl + string([]byte(b.Ctx.Input.URL())[4:]) + `" /></head></html>`)
		b.StopRun()
	}

	b.Data["WebSite"] = website
	b.Data["HostUrl"] = website.HostUrl
	b.SetPageTitle(website.Title)
	b.SetDescript(website.Description)
	b.AddKeyWord(website.Keywords...)

	b.Data["Metes"] = ""
	b.AddCustomCssStyle("//cdn.bootcss.com/bootstrap/3.3.5/css/", "bootstrap.min.css", "bootstrap-theme.min.css")
	b.AddCustomCssStyle("//cdn.bootcss.com/font-awesome/4.4.0/css/", "font-awesome.min.css")
	b.AddCssStyle("style.css")
	//	b.AddCustomCssStyle("http://fonts.useso.com/", "css?family=Open+Sans:300,400,600&subset=latin,latin-ext")

	b.AddCustomJsScript("//cdn.bootcss.com/jquery/2.1.4/", "jquery.min.js")
	b.AddCustomJsScript("//cdn.bootcss.com/bootstrap/3.3.5/css/", "bootstrap.min.js")
	b.AddCustomCssStyle("//cdn.bootcss.com/jquery-migrate/1.2.1/", "jquery-migrate.min.js")
	b.AddCustomJsScript("//cdn.bootcss.com/wow/1.1.2/", "wow.min.js")

	b.Data["Tail"] = `Download your use my life`

	b.LayoutSections = make(map[string]string)

	b.Layout = "layout/index.html"
}
Beispiel #2
0
func init() {
	conf.LoadConf("conf/v2.json")

	err := modules.LoadBlogs(conf.GetConf().BlogDir)
	if err != nil {
		log.Error(err)
	}
}
Beispiel #3
0
func (w *WebHook) Done(script string) {
	log.Debug("Run Script: ", script)
	out, err := exec.Command("bash", "-c", script).Output()
	if err != nil {
		log.Errorf("Script Error. %s", err)
		return
	}
	log.Noticef("Out. %s", out)
	modules.ReLoadBlogs(conf.GetConf().BlogDir)
}
Beispiel #4
0
// 检查是否应该触发
func (w *WebHook) Check() (ok bool) {
	h := conf.GetConf().WebHook
	if h.Repos != w.Repos {
		return false
	}
	for _, m := range h.Monitors {
		if m.Branch != w.Branch && m.Branch != "" {
			continue
		}
		if m.User != w.User && m.User != "" {
			continue
		}
		if m.Script != "" {
			w.Script = m.Script
			return true
		}
	}

	return false
}
Beispiel #5
0
func DoWebhook(res http.ResponseWriter, req *http.Request) {
	hook := &WebHook{}
	hook.Config = conf.GetConf().WebHook
	hook.HookHandle(res, req)
}
Beispiel #6
0
package controllers

import (
	_ "container/list"

	"fmt"
	"strings"

	"github.com/ckeyer/goblog/conf"
	"github.com/ckeyer/goblog/models"
)

var (
	website = conf.GetConf().WebSite
)

type BaseController struct {
	Controller
}

func (this *BaseController) Prepare() {
	this.Ctx.Request.Header.Add("Access-Control-Allow-Origin", "*")

	// 验证是否来自合法域名访问
	if !this.isAllowHost() {
		this.Ctx.WriteString(`<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0; url=` +
			website.HostUrl + string([]byte(this.Ctx.Input.Url())[4:]) + `" /></head></html>`)
		this.StopRun()
	}

	this.Data["WebSite"] = website
Beispiel #7
0
package models

import (
	"time"

	"github.com/astaxie/beego/orm"
	"github.com/ckeyer/goblog/conf"
	"github.com/ckeyer/goblog/lib/logging"
	//	"github.com/go-redis/redis"
	_ "github.com/go-sql-driver/mysql"
	redis "gopkg.in/redis.v3"
)

var (
	config  = conf.GetConf()
	rc      *redis.Client
	log     = logging.GetLogger()
	db_str  string
	force   = false // force create tables
	verbose = true  // show sql
)

func init() {
	db_str = config.Mysql.GetConnStr() //"root:root@tcp(d.local:3306)/db_blog?charset=utf8"

	if rc == nil || rc.Ping().Err() != nil {
		rc = redis.NewClient(&redis.Options{
			Addr:     config.Redis.GetConnStr(),
			Password: config.Redis.Password,
			DB:       config.Redis.Database,
		})
Beispiel #8
0
package controllers

import (
	"github.com/ckeyer/goblog/conf"
	"github.com/ckeyer/goblog/lib/webhook"
)

type WebHookController struct {
	Controller
}

var (
	config = conf.GetConf().WebHook
)

// Post 接受WebHook
func (w *WebHookController) Post() {
	webhook.HookHandle(w.Ctx.ResponseWriter, w.Ctx.Request)
}