Exemple #1
0
// replaceLinks replaces fedwiki style links with regular HTML links
func replaceLinks(s string) template.HTML {
	s = rxInternal.ReplaceAllStringFunc(s, func(s string) string {
		s = strings.Trim(s, "[]")
		return fmt.Sprintf(`<a href="%s">%s</a>`, fedwiki.Slugify(s), s)
	})
	s = rxExternal.ReplaceAllString(s, `<a href="$1">$2</a>`)
	return template.HTML(s)
}
Exemple #2
0
// Discards any errors that happen in sub-stores
func (store *Store) List() ([]*fedwiki.PageHeader, error) {
	list, err := ioutil.ReadDir(store.Dir)
	err = pagestore.ConvertOSError(err)
	if err != nil {
		return nil, err
	}

	headers := []*fedwiki.PageHeader{}
	for _, info := range list {
		filename := filepath.Join(store.Dir, info.Name())

		slug := fedwiki.Slugify(filepath.Base(filename))

		header, err := pagestore.LoadHeader(filename, slug)
		err = pagestore.ConvertOSError(err)
		//TODO: maybe ignore this error?
		if err != nil {
			return nil, err
		}

		headers = append(headers, header)
	}
	return headers, nil
}