Пример #1
0
func pageShow(w http.ResponseWriter, r *http.Request, p httprouter.Params) *httphelper.HandlerError {
	l := httphelper.NewHandlerLogEntry(r)

	etype := p.ByName("type")
	project := p.ByName("project")

	l.Debug("Type: ", etype)
	l.Debug("Project: ", project)

	projects, err := helper.ProjectNamesFromArgs(dataStore, []string{project}, false)
	if err != nil {
		return httphelper.NewHandlerErrorDef(errgo.Notef(err, "can not get list of projects"))
	}

	err = dataStore.PopulateProjects(&projects)
	if err != nil {
		return httphelper.NewHandlerErrorDef(errgo.Notef(err, "can not populate projects with entries"))
	}

	buffer := new(bytes.Buffer)
	formatting.Projects(buffer, "Entries", 0, &projects)

	err = asciiDoctor(buffer, w)
	if err != nil {
		return httphelper.NewHandlerErrorDef(errgo.Notef(err, "can not format entries with asciidoctor"))
	}

	return nil
}
Пример #2
0
func runCmdShowEntries(cmd *cobra.Command, args []string) error {
	store, err := helper.DefaultStore(flagDataDir)
	if err != nil {
		return errgo.Notef(err, "can not get data store")
	}

	projects, err := helper.ProjectNamesFromArgs(store, args, flagShowArchive)
	if err != nil {
		return errgo.Notef(err, "can not get list of projects")
	}

	err = store.PopulateProjects(&projects)
	if err != nil {
		return errgo.Notef(err, "can not populate projects with entries")
	}

	formatting.Projects(os.Stdout, "Entries", 0, &projects)

	return nil
}