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
a3f3bc67
Commit
a3f3bc67
authored
Jan 08, 2016
by
Matthew Holt
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'browse-tpl'
parents
5f6a0a4c
62b210b5
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
286 additions
and
121 deletions
+286
-121
caddy/letsencrypt/letsencrypt.go
caddy/letsencrypt/letsencrypt.go
+13
-0
caddy/setup/browse.go
caddy/setup/browse.go
+227
-116
middleware/browse/browse.go
middleware/browse/browse.go
+46
-5
No files found.
caddy/letsencrypt/letsencrypt.go
View file @
a3f3bc67
...
@@ -124,6 +124,19 @@ func Activate(configs []server.Config) ([]server.Config, error) {
...
@@ -124,6 +124,19 @@ func Activate(configs []server.Config) ([]server.Config, error) {
errMsg
+=
"["
+
domain
+
"] failed to get certificate: "
+
obtainErr
.
Error
()
+
"
\n
"
errMsg
+=
"["
+
domain
+
"] failed to get certificate: "
+
obtainErr
.
Error
()
+
"
\n
"
}
}
// Save the certs we did obtain, though, before leaving
if
err
:=
saveCertsAndKeys
(
certificates
);
err
==
nil
{
if
len
(
certificates
)
>
0
{
var
certList
[]
string
for
_
,
cert
:=
range
certificates
{
certList
=
append
(
certList
,
cert
.
Domain
)
}
errMsg
+=
"Saved certificates for: "
+
strings
.
Join
(
certList
,
", "
)
+
"
\n
"
}
}
else
{
errMsg
+=
"Unable to save obtained certificates: "
+
err
.
Error
()
+
"
\n
"
}
return
configs
,
errors
.
New
(
errMsg
)
return
configs
,
errors
.
New
(
errMsg
)
}
}
...
...
caddy/setup/browse.go
View file @
a3f3bc67
This diff is collapsed.
Click to expand it.
middleware/browse/browse.go
View file @
a3f3bc67
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"bytes"
"bytes"
"encoding/json"
"encoding/json"
"errors"
"errors"
"fmt"
"net/http"
"net/http"
"net/url"
"net/url"
"os"
"os"
...
@@ -36,7 +37,7 @@ type Config struct {
...
@@ -36,7 +37,7 @@ type Config struct {
Template
*
template
.
Template
Template
*
template
.
Template
}
}
// A Listing is used to fill out a template.
// A Listing is
the context
used to fill out a template.
type
Listing
struct
{
type
Listing
struct
{
// The name of the directory (the last element of the path)
// The name of the directory (the last element of the path)
Name
string
Name
string
...
@@ -50,6 +51,12 @@ type Listing struct {
...
@@ -50,6 +51,12 @@ type Listing struct {
// The items (files and folders) in the path
// The items (files and folders) in the path
Items
[]
FileInfo
Items
[]
FileInfo
// The number of directories in the listing
NumDirs
int
// The number of files (items that aren't directories) in the listing
NumFiles
int
// Which sorting order is used
// Which sorting order is used
Sort
string
Sort
string
...
@@ -62,6 +69,33 @@ type Listing struct {
...
@@ -62,6 +69,33 @@ type Listing struct {
middleware
.
Context
middleware
.
Context
}
}
// LinkedPath returns l.Path where every element is a clickable
// link to the path up to that point so far.
func
(
l
Listing
)
LinkedPath
()
string
{
if
len
(
l
.
Path
)
==
0
{
return
""
}
// skip trailing slash
lpath
:=
l
.
Path
if
lpath
[
len
(
lpath
)
-
1
]
==
'/'
{
lpath
=
lpath
[
:
len
(
lpath
)
-
1
]
}
parts
:=
strings
.
Split
(
lpath
,
"/"
)
var
result
string
for
i
,
part
:=
range
parts
{
if
i
==
0
&&
part
==
""
{
// Leading slash (root)
result
+=
`<a href="/">/</a>`
continue
}
result
+=
fmt
.
Sprintf
(
`<a href="%s/">%s</a>/`
,
strings
.
Join
(
parts
[
:
i
+
1
],
"/"
),
part
)
}
return
result
}
// FileInfo is the info about a particular file or directory
// FileInfo is the info about a particular file or directory
type
FileInfo
struct
{
type
FileInfo
struct
{
IsDir
bool
IsDir
bool
...
@@ -140,7 +174,9 @@ func (fi FileInfo) HumanModTime(format string) string {
...
@@ -140,7 +174,9 @@ func (fi FileInfo) HumanModTime(format string) string {
func
directoryListing
(
files
[]
os
.
FileInfo
,
r
*
http
.
Request
,
canGoUp
bool
,
root
string
,
ignoreIndexes
bool
,
vars
interface
{})
(
Listing
,
error
)
{
func
directoryListing
(
files
[]
os
.
FileInfo
,
r
*
http
.
Request
,
canGoUp
bool
,
root
string
,
ignoreIndexes
bool
,
vars
interface
{})
(
Listing
,
error
)
{
var
fileinfos
[]
FileInfo
var
fileinfos
[]
FileInfo
var
dirCount
,
fileCount
int
var
urlPath
=
r
.
URL
.
Path
var
urlPath
=
r
.
URL
.
Path
for
_
,
f
:=
range
files
{
for
_
,
f
:=
range
files
{
name
:=
f
.
Name
()
name
:=
f
.
Name
()
...
@@ -155,6 +191,9 @@ func directoryListing(files []os.FileInfo, r *http.Request, canGoUp bool, root s
...
@@ -155,6 +191,9 @@ func directoryListing(files []os.FileInfo, r *http.Request, canGoUp bool, root s
if
f
.
IsDir
()
{
if
f
.
IsDir
()
{
name
+=
"/"
name
+=
"/"
dirCount
++
}
else
{
fileCount
++
}
}
url
:=
url
.
URL
{
Path
:
name
}
url
:=
url
.
URL
{
Path
:
name
}
...
@@ -170,10 +209,12 @@ func directoryListing(files []os.FileInfo, r *http.Request, canGoUp bool, root s
...
@@ -170,10 +209,12 @@ func directoryListing(files []os.FileInfo, r *http.Request, canGoUp bool, root s
}
}
return
Listing
{
return
Listing
{
Name
:
path
.
Base
(
urlPath
),
Name
:
path
.
Base
(
urlPath
),
Path
:
urlPath
,
Path
:
urlPath
,
CanGoUp
:
canGoUp
,
CanGoUp
:
canGoUp
,
Items
:
fileinfos
,
Items
:
fileinfos
,
NumDirs
:
dirCount
,
NumFiles
:
fileCount
,
Context
:
middleware
.
Context
{
Context
:
middleware
.
Context
{
Root
:
http
.
Dir
(
root
),
Root
:
http
.
Dir
(
root
),
Req
:
r
,
Req
:
r
,
...
...
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