Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
540a651f
Commit
540a651f
authored
Sep 19, 2015
by
Matt Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #250 from hacdias/master
browse: User defined variables (for templates)
parents
ee893325
8120e578
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
middleware/browse/browse.go
middleware/browse/browse.go
+7
-2
No files found.
middleware/browse/browse.go
View file @
540a651f
...
...
@@ -32,6 +32,7 @@ type Browse struct {
// Config is a configuration for browsing in a particular path.
type
Config
struct
{
PathScope
string
Variables
interface
{}
Template
*
template
.
Template
}
...
...
@@ -55,6 +56,9 @@ type Listing struct {
// And which order
Order
string
// User defined costum variables
User
interface
{}
middleware
.
Context
}
...
...
@@ -143,7 +147,7 @@ var IndexPages = []string{
"default.txt"
,
}
func
directoryListing
(
files
[]
os
.
FileInfo
,
r
*
http
.
Request
,
canGoUp
bool
,
root
string
,
ignoreIndexes
bool
)
(
Listing
,
error
)
{
func
directoryListing
(
files
[]
os
.
FileInfo
,
r
*
http
.
Request
,
canGoUp
bool
,
root
string
,
ignoreIndexes
bool
,
vars
interface
{}
)
(
Listing
,
error
)
{
var
fileinfos
[]
FileInfo
var
urlPath
=
r
.
URL
.
Path
for
_
,
f
:=
range
files
{
...
...
@@ -184,6 +188,7 @@ func directoryListing(files []os.FileInfo, r *http.Request, canGoUp bool, root s
Req
:
r
,
URL
:
r
.
URL
,
},
User
:
vars
,
},
nil
}
...
...
@@ -237,7 +242,7 @@ func (b Browse) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {
}
}
// Assemble listing of directory contents
listing
,
err
:=
directoryListing
(
files
,
r
,
canGoUp
,
b
.
Root
,
b
.
IgnoreIndexes
)
listing
,
err
:=
directoryListing
(
files
,
r
,
canGoUp
,
b
.
Root
,
b
.
IgnoreIndexes
,
bc
.
Variables
)
if
err
!=
nil
{
// directory isn't browsable
continue
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment