A tool to migrate GitHub Repositories to Gitea including all issues
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.2 KiB

package web
import (
// BundledFS implements ServeFileSystem for packr.Box
type BundledFS struct {
// Exists returns true if filepath exists
func (fs *BundledFS) Exists(prefix string, filepath string) bool {
if p := strings.TrimPrefix(filepath, prefix); len(p) < len(filepath) {
return fs.Has(p)
return false
// ListFiles returns all files in FS
func (fs *BundledFS) ListFiles() (files []macaron.TemplateFile) {
for _, filename := range fs.List() {
files = append(files, &BundledFile{fs: fs, FileName: filename})
return files
// Get returns the content of filename
func (fs *BundledFS) Get(filename string) (io.Reader, error) {
return bytes.NewReader(fs.Bytes(filename)), nil
// BundledFile represents a file in a BundledFS
type BundledFile struct {
fs *BundledFS
FileName string
// Name represents the name of the file
func (b *BundledFile) Name() string {
return strings.TrimSuffix(b.FileName, path.Ext(b.FileName))
// Data returns the content of file
func (b *BundledFile) Data() []byte {
return b.fs.Bytes(b.FileName)
// Ext returns the file extension
func (b *BundledFile) Ext() string {
return path.Ext(b.FileName)