本文整理汇总了Golang中github.com/spf13/hugo/helpers.GetRelativePath函数的典型用法代码示例。如果您正苦于以下问题:Golang GetRelativePath函数的具体用法?Golang GetRelativePath怎么用?Golang GetRelativePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetRelativePath函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: server
func server(cmd *cobra.Command, args []string) {
InitializeConfig()
if cmd.Flags().Lookup("disableLiveReload").Changed {
viper.Set("DisableLiveReload", disableLiveReload)
}
if serverWatch {
viper.Set("Watch", true)
}
if viper.GetBool("watch") {
serverWatch = true
}
l, err := net.Listen("tcp", net.JoinHostPort(serverInterface, strconv.Itoa(serverPort)))
if err == nil {
l.Close()
} else {
jww.ERROR.Println("port", serverPort, "already in use, attempting to use an available port")
sp, err := helpers.FindAvailablePort()
if err != nil {
jww.ERROR.Println("Unable to find alternative port to use")
jww.ERROR.Fatalln(err)
}
serverPort = sp.Port
}
viper.Set("port", serverPort)
BaseURL, err := fixURL(BaseURL)
if err != nil {
jww.ERROR.Fatal(err)
}
viper.Set("BaseURL", BaseURL)
if err := memStats(); err != nil {
jww.ERROR.Println("memstats error:", err)
}
build(serverWatch)
// Watch runs its own server as part of the routine
if serverWatch {
watched := getDirList()
workingDir := helpers.AbsPathify(viper.GetString("WorkingDir"))
for i, dir := range watched {
watched[i], _ = helpers.GetRelativePath(dir, workingDir)
}
unique := strings.Join(helpers.RemoveSubpaths(watched), ",")
jww.FEEDBACK.Printf("Watching for changes in %s/{%s}\n", workingDir, unique)
err := NewWatcher(serverPort)
if err != nil {
fmt.Println(err)
}
}
serve(serverPort)
}
开发者ID:heidthecamp,项目名称:hugo,代码行数:60,代码来源:server.go
示例2: NewFileFromAbs
func NewFileFromAbs(base, fullpath string, content io.Reader) (f *File, err error) {
var name string
if name, err = helpers.GetRelativePath(fullpath, base); err != nil {
return nil, err
}
return NewFileWithContents(name, content), nil
}
开发者ID:yanwushuang,项目名称:pango,代码行数:8,代码来源:file.go
示例3: RelPermalink
func (p *Page) RelPermalink() (string, error) {
link, err := p.permalink()
if err != nil {
return "", err
}
if viper.GetBool("CanonifyURLs") {
// replacements for relpermalink with baseURL on the form http://myhost.com/sub/ will fail later on
// have to return the URL relative from baseURL
relpath, err := helpers.GetRelativePath(link.String(), string(p.Site.BaseURL))
if err != nil {
return "", err
}
return "/" + filepath.ToSlash(relpath), nil
}
link.Scheme = ""
link.Host = ""
link.User = nil
link.Opaque = ""
return link.String(), nil
}
开发者ID:JTrembl1,项目名称:hugo,代码行数:22,代码来源:page.go
示例4: getRelativePath
func (f *Filesystem) getRelativePath(name string) (final string, err error) {
return helpers.GetRelativePath(name, f.Base)
}
开发者ID:yanwushuang,项目名称:pango,代码行数:3,代码来源:filesystem.go
示例5: server
func server(cmd *cobra.Command, args []string) error {
if err := InitializeConfig(serverCmd); err != nil {
return err
}
if cmd.Flags().Lookup("disableLiveReload").Changed {
viper.Set("DisableLiveReload", disableLiveReload)
}
if serverWatch {
viper.Set("Watch", true)
}
if viper.GetBool("watch") {
serverWatch = true
watchConfig()
}
l, err := net.Listen("tcp", net.JoinHostPort(serverInterface, strconv.Itoa(serverPort)))
if err == nil {
l.Close()
} else {
jww.ERROR.Println("port", serverPort, "already in use, attempting to use an available port")
sp, err := helpers.FindAvailablePort()
if err != nil {
return newSystemError("Unable to find alternative port to use:", err)
}
serverPort = sp.Port
}
viper.Set("port", serverPort)
BaseURL, err := fixURL(BaseURL)
if err != nil {
return err
}
viper.Set("BaseURL", BaseURL)
if err := memStats(); err != nil {
jww.ERROR.Println("memstats error:", err)
}
// If a Destination is provided via flag write to disk
if Destination != "" {
renderToDisk = true
}
// Hugo writes the output to memory instead of the disk
if !renderToDisk {
hugofs.DestinationFS = new(afero.MemMapFs)
// Rendering to memoryFS, publish to Root regardless of publishDir.
viper.Set("PublishDir", "/")
}
if serverCmd.Flags().Lookup("noTimes").Changed {
viper.Set("NoTimes", NoTimes)
}
if err := build(serverWatch); err != nil {
return err
}
// Watch runs its own server as part of the routine
if serverWatch {
watchDirs := getDirList()
baseWatchDir := viper.GetString("WorkingDir")
for i, dir := range watchDirs {
watchDirs[i], _ = helpers.GetRelativePath(dir, baseWatchDir)
}
rootWatchDirs := strings.Join(helpers.UniqueStrings(helpers.ExtractRootPaths(watchDirs)), ",")
jww.FEEDBACK.Printf("Watching for changes in %s%s{%s}\n", baseWatchDir, helpers.FilePathSeparator, rootWatchDirs)
err := NewWatcher(serverPort)
if err != nil {
return err
}
}
serve(serverPort)
return nil
}
开发者ID:mayah,项目名称:hugo,代码行数:84,代码来源:server.go
示例6: server
func server(cmd *cobra.Command, args []string) {
InitializeConfig()
if cmd.Flags().Lookup("disableLiveReload").Changed {
viper.Set("DisableLiveReload", disableLiveReload)
}
if serverWatch {
viper.Set("Watch", true)
}
if viper.GetBool("watch") {
serverWatch = true
watchConfig()
}
l, err := net.Listen("tcp", net.JoinHostPort(serverInterface, strconv.Itoa(serverPort)))
if err == nil {
l.Close()
} else {
jww.ERROR.Println("port", serverPort, "already in use, attempting to use an available port")
sp, err := helpers.FindAvailablePort()
if err != nil {
jww.ERROR.Println("Unable to find alternative port to use")
jww.ERROR.Fatalln(err)
}
serverPort = sp.Port
}
viper.Set("port", serverPort)
BaseURL, err := fixURL(BaseURL)
if err != nil {
jww.ERROR.Fatal(err)
}
viper.Set("BaseURL", BaseURL)
if err := memStats(); err != nil {
jww.ERROR.Println("memstats error:", err)
}
// If a Destination is provided via flag write to disk
if Destination != "" {
renderToDisk = true
}
// Hugo writes the output to memory instead of the disk
if !renderToDisk {
hugofs.DestinationFS = new(afero.MemMapFs)
// Rendering to memoryFS, publish to Root regardless of publishDir.
viper.Set("PublishDir", "/")
}
build(serverWatch)
// Watch runs its own server as part of the routine
if serverWatch {
watched := getDirList()
workingDir := helpers.AbsPathify(viper.GetString("WorkingDir"))
for i, dir := range watched {
watched[i], _ = helpers.GetRelativePath(dir, workingDir)
}
unique := strings.Join(helpers.RemoveSubpaths(watched), ",")
jww.FEEDBACK.Printf("Watching for changes in %s/{%s}\n", workingDir, unique)
err := NewWatcher(serverPort)
if err != nil {
fmt.Println(err)
}
}
serve(serverPort)
}
开发者ID:BarbUk,项目名称:hugo,代码行数:73,代码来源:server.go
注:本文中的github.com/spf13/hugo/helpers.GetRelativePath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论