| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -6,7 +6,6 @@ import ( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						"time" | 
					 | 
					 | 
					 | 
						"time" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						"github.com/gohugoio/hugo/deps" | 
					 | 
					 | 
					 | 
						"github.com/gohugoio/hugo/deps" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						"github.com/gohugoio/hugo/hugofs" | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						"github.com/gohugoio/hugo/hugolib" | 
					 | 
					 | 
					 | 
						"github.com/gohugoio/hugo/hugolib" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						"github.com/spf13/afero" | 
					 | 
					 | 
					 | 
						"github.com/spf13/afero" | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -18,35 +17,54 @@ const ( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						WebsocketFileTicker  = 1 * time.Second | 
					 | 
					 | 
					 | 
						WebsocketFileTicker  = 1 * time.Second | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					) | 
					 | 
					 | 
					 | 
					) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					type HugoInteractor interface { | 
					 | 
					 | 
					 | 
					// Publish really renders new content into the public directory
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						Render(srcdir, workdir string) HugoRenderer | 
					 | 
					 | 
					 | 
					func (ch *CaddyHugo) Publish() error { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						err := ch.persistAllEdits() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						if err != nil { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							return err | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					type HugoRenderer interface { | 
					 | 
					 | 
					 | 
						err = buildSite(ch.HugoSites) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						WriteContent(contents string) error | 
					 | 
					 | 
					 | 
						if err != nil { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						Start() error | 
					 | 
					 | 
					 | 
							return err | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						Stop() error | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					func HugoInternalProcessConfig(ch *CaddyHugo, es *editSession, touchFn func()) (idleshut.Config, error) { | 
					 | 
					 | 
					 | 
						return nil | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					func buildSite(sites *hugolib.HugoSites) error { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						err := sites.Build(hugolib.BuildCfg{ResetState: true}) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						if err != nil { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							return fmt.Errorf("caddy-hugo: building site: %v", err) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						return err | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					func (ch *CaddyHugo) configWithFs(fs afero.Fs) (*hugolib.HugoSites, *deps.DepsCfg, error) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						var err error | 
					 | 
					 | 
					 | 
						var err error | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						hugoCfg := &deps.DepsCfg{Fs: hugofs.NewFrom(es.tmpfs, ch.HugoCfg.Cfg)} | 
					 | 
					 | 
					 | 
						cfg := &deps.DepsCfg{} | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						fmt.Println(ch.Dir) | 
					 | 
					 | 
					 | 
						cfgPath := path.Join(ch.Dir, "config.toml") | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						hugoCfg.Cfg, err = hugolib.LoadConfig(es.tmpfs, "", path.Join(ch.Dir, "config.toml")) | 
					 | 
					 | 
					 | 
						cfg.Cfg, err = hugolib.LoadConfig(fs, "", cfgPath) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						if err != nil { | 
					 | 
					 | 
					 | 
						if err != nil { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							return idleshut.Config{}, fmt.Errorf("caddy-hugo: loading site configuration: %v", err) | 
					 | 
					 | 
					 | 
							return nil, cfg, fmt.Errorf("caddy-hugo: loading site configuration: %v", err) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						cfg.Cfg.Set("workingDir", ch.Dir) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						hugoCfg.Cfg.Set("workingDir", ch.Dir) | 
					 | 
					 | 
					 | 
						sites, err := hugolib.NewHugoSites(*cfg) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						hugoSites, err := hugolib.NewHugoSites(*hugoCfg) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						if err != nil { | 
					 | 
					 | 
					 | 
						if err != nil { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							return idleshut.Config{}, fmt.Errorf("caddy-hugo: initializing site: %v", err) | 
					 | 
					 | 
					 | 
							return nil, cfg, fmt.Errorf("caddy-hugo: initializing site: %v", err) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						err = hugoSites.Build(hugolib.BuildCfg{ResetState: true}) | 
					 | 
					 | 
					 | 
						err = buildSite(sites) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						return sites, cfg, err | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					func HugoInternalProcessConfig(ch *CaddyHugo, es *editSession, touchFn func()) (idleshut.Config, error) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						hugoSites, _, err := ch.configWithFs(es.tmpfs) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						if err != nil { | 
					 | 
					 | 
					 | 
						if err != nil { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							return idleshut.Config{}, fmt.Errorf("caddy-hugo: building site: %v", err) | 
					 | 
					 | 
					 | 
							return idleshut.Config{}, fmt.Errorf("caddy-hugo: loading site configuration: %v", err) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						return idleshut.Config{ | 
					 | 
					 | 
					 | 
						return idleshut.Config{ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |