| 254 | } |
| 255 | |
| 256 | func newGenerator(outputDir string) (*generator, error) { |
| 257 | categoryTemplate, err := template.ParseFiles( |
| 258 | filepath.Join("../../xbarapp.com", "templates", "_layout.html"), |
| 259 | filepath.Join("../../xbarapp.com", "templates", "category.html"), |
| 260 | ) |
| 261 | if err != nil { |
| 262 | return nil, err |
| 263 | } |
| 264 | pluginTemplate, err := template.ParseFiles( |
| 265 | filepath.Join("../../xbarapp.com", "templates", "_layout.html"), |
| 266 | filepath.Join("../../xbarapp.com", "templates", "plugin.html"), |
| 267 | ) |
| 268 | if err != nil { |
| 269 | return nil, err |
| 270 | } |
| 271 | indexTemplate, err := template.ParseFiles( |
| 272 | filepath.Join("../../xbarapp.com", "templates", "_layout.html"), |
| 273 | filepath.Join("../../xbarapp.com", "templates", "index.html"), |
| 274 | ) |
| 275 | if err != nil { |
| 276 | return nil, err |
| 277 | } |
| 278 | contributorTemplate, err := template.ParseFiles( |
| 279 | filepath.Join("../../xbarapp.com", "templates", "_layout.html"), |
| 280 | filepath.Join("../../xbarapp.com", "templates", "contributor.html"), |
| 281 | ) |
| 282 | if err != nil { |
| 283 | return nil, err |
| 284 | } |
| 285 | contributorsTemplate, err := template.ParseFiles( |
| 286 | filepath.Join("../../xbarapp.com", "templates", "_layout.html"), |
| 287 | filepath.Join("../../xbarapp.com", "templates", "contributors.html"), |
| 288 | ) |
| 289 | if err != nil { |
| 290 | return nil, err |
| 291 | } |
| 292 | g := &generator{ |
| 293 | outputDir: outputDir, |
| 294 | pluginsDir: filepath.Join(outputDir, "plugins"), |
| 295 | authorsDir: filepath.Join(outputDir, "contributors"), |
| 296 | |
| 297 | categoryTemplate: categoryTemplate, |
| 298 | pluginTemplate: pluginTemplate, |
| 299 | indexTemplate: indexTemplate, |
| 300 | contributorTemplate: contributorTemplate, |
| 301 | contributorsTemplate: contributorsTemplate, |
| 302 | } |
| 303 | return g, nil |
| 304 | } |
| 305 | |
| 306 | func (g *generator) mkdirall() error { |
| 307 | if err := os.MkdirAll(g.outputDir, 0777); err != nil { |