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
60690c78
Commit
60690c78
authored
Jul 30, 2015
by
Maxime
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/mholt/caddy
parents
4b92808b
73397a09
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
20 deletions
+54
-20
app/app.go
app/app.go
+1
-1
dist/CHANGES.txt
dist/CHANGES.txt
+11
-5
dist/README.txt
dist/README.txt
+1
-1
middleware/browse/browse.go
middleware/browse/browse.go
+3
-2
middleware/context.go
middleware/context.go
+18
-3
middleware/markdown/markdown_test.go
middleware/markdown/markdown_test.go
+3
-3
middleware/markdown/page.go
middleware/markdown/page.go
+12
-4
middleware/markdown/renderer.go
middleware/markdown/renderer.go
+5
-1
No files found.
app/app.go
View file @
60690c78
...
...
@@ -20,7 +20,7 @@ const (
Name
=
"Caddy"
// Version is the program version
Version
=
"0.7.
3
"
Version
=
"0.7.
4
"
)
var
(
...
...
dist/CHANGES.txt
View file @
60690c78
CHANGES
<master>
- browse: Sort preference persisted in cookie
0.7.4 (July 30, 2015)
- browse: Sort
ing
preference persisted in cookie
- browse: Added index.txt and default.txt to list of default files
- markdown: Fix for large markdown files
- redir: Can use variables like log formats can
- browse: Template files may now use Caddy template actions
- markdown: Template files may now use Caddy template actions
- markdown: Several bug fixes, especially for large and empty Markdown files
- markdown: Generate index pages to link to markdown pages (sitegen only)
- markdown: Flatten structure of front matter, changed template variables
- redir: Can use variables (placeholders) like log formats can
- redir: Catch-all redirects no longer preserve path; use {uri} instead
- redir: Create redirect tables by opening a redir block
- redir: Syntax supports redirect tables by opening a block
- templates: Renamed .Date to .Now and added .Truncate, .Replace actions
- Other minor internal improvements and more tests
0.7.3 (July 15, 2015)
...
...
dist/README.txt
View file @
60690c78
CADDY 0.7.
3
CADDY 0.7.
4
Website
https://caddyserver.com
...
...
middleware/browse/browse.go
View file @
60690c78
...
...
@@ -120,9 +120,10 @@ func (l Listing) applySort() {
}
}
// HumanSize returns the size of the file as a human-readable string.
// HumanSize returns the size of the file as a human-readable string
// in IEC format (i.e. power of 2 or base 1024).
func
(
fi
FileInfo
)
HumanSize
()
string
{
return
humanize
.
Bytes
(
uint64
(
fi
.
Size
))
return
humanize
.
I
Bytes
(
uint64
(
fi
.
Size
))
}
// HumanModTime returns the modified time of the file as a human-readable string.
...
...
middleware/context.go
View file @
60690c78
...
...
@@ -6,6 +6,7 @@ import (
"net"
"net/http"
"net/url"
"strings"
"text/template"
"time"
)
...
...
@@ -13,7 +14,7 @@ import (
// This file contains the context and functions available for
// use in the templates.
//
context is the context with which
templates are executed.
//
Context is the context with which Caddy
templates are executed.
type
Context
struct
{
Root
http
.
FileSystem
Req
*
http
.
Request
...
...
@@ -48,8 +49,8 @@ func (c Context) Include(filename string) (string, error) {
return
buf
.
String
(),
nil
}
//
Date returns the current timestamp in the specified format
func
(
c
Context
)
Date
(
format
string
)
string
{
//
Now returns the current timestamp in the specified format.
func
(
c
Context
)
Now
(
format
string
)
string
{
return
time
.
Now
()
.
Format
(
format
)
}
...
...
@@ -114,3 +115,17 @@ func (c Context) Method() string {
func
(
c
Context
)
PathMatches
(
pattern
string
)
bool
{
return
Path
(
c
.
Req
.
URL
.
Path
)
.
Matches
(
pattern
)
}
// Truncate truncates the input string to the given length. If
// input is shorter than length, the entire string is returned.
func
(
c
Context
)
Truncate
(
input
string
,
length
int
)
string
{
if
len
(
input
)
>
length
{
return
input
[
:
length
]
}
return
input
}
// Replace replaces instances of find in input with replacement.
func
(
c
Context
)
Replace
(
input
,
find
,
replacement
string
)
string
{
return
strings
.
Replace
(
input
,
find
,
replacement
,
-
1
)
}
middleware/markdown/markdown_test.go
View file @
60690c78
...
...
@@ -55,7 +55,7 @@ func TestMarkdown(t *testing.T) {
Title
:
"first"
,
Summary
:
""
,
Date
:
time
.
Now
(),
U
rl
:
"/og/first.md"
,
U
RL
:
"/og/first.md"
,
},
},
},
...
...
@@ -191,8 +191,8 @@ func getTrue() bool {
for
i
,
c
:=
range
md
.
Configs
{
log
.
Printf
(
"Test number: %d, configuration links: %v, config: %v"
,
i
,
c
.
Links
,
c
)
if
c
.
Links
[
0
]
.
U
rl
!=
expectedLinks
[
i
]
{
t
.
Fatalf
(
"Expected %v got %v"
,
expectedLinks
[
i
],
c
.
Links
[
0
]
.
U
rl
)
if
c
.
Links
[
0
]
.
U
RL
!=
expectedLinks
[
i
]
{
t
.
Fatalf
(
"Expected %v got %v"
,
expectedLinks
[
i
],
c
.
Links
[
0
]
.
U
RL
)
}
}
...
...
middleware/markdown/page.go
View file @
60690c78
package
markdown
import
(
"bytes"
"io/ioutil"
"os"
"path/filepath"
...
...
@@ -16,8 +17,8 @@ const (
// Date format YYYY-MM-DD HH:MM:SS
timeLayout
=
`2006-01-02 15:04:05`
//
L
ength of page summary.
summaryLen
=
15
0
//
Maximum l
ength of page summary.
summaryLen
=
50
0
)
// PageLink represents a statically generated markdown page.
...
...
@@ -25,7 +26,7 @@ type PageLink struct {
Title
string
Summary
string
Date
time
.
Time
U
rl
string
U
RL
string
}
// byDate sorts PageLink by newest date to oldest.
...
...
@@ -99,15 +100,22 @@ func (l *linkGen) generateLinks(md Markdown, cfg *Config) {
return
err
}
// truncate summary to maximum length
if
len
(
summary
)
>
summaryLen
{
summary
=
summary
[
:
summaryLen
]
// trim to nearest word
lastSpace
:=
bytes
.
LastIndex
(
summary
,
[]
byte
(
" "
))
if
lastSpace
!=
-
1
{
summary
=
summary
[
:
lastSpace
]
}
}
metadata
:=
parser
.
Metadata
()
cfg
.
Links
=
append
(
cfg
.
Links
,
PageLink
{
Title
:
metadata
.
Title
,
U
rl
:
reqPath
,
U
RL
:
reqPath
,
Date
:
metadata
.
Date
,
Summary
:
string
(
blackfriday
.
Markdown
(
summary
,
PlaintextRenderer
{},
0
)),
})
...
...
middleware/markdown/renderer.go
View file @
60690c78
...
...
@@ -48,7 +48,11 @@ func (r PlaintextRenderer) TitleBlock(out *bytes.Buffer, text []byte) {}
func
(
r
PlaintextRenderer
)
AutoLink
(
out
*
bytes
.
Buffer
,
link
[]
byte
,
kind
int
)
{}
func
(
r
PlaintextRenderer
)
CodeSpan
(
out
*
bytes
.
Buffer
,
text
[]
byte
)
{}
func
(
r
PlaintextRenderer
)
CodeSpan
(
out
*
bytes
.
Buffer
,
text
[]
byte
)
{
out
.
Write
([]
byte
(
"`"
))
out
.
Write
(
text
)
out
.
Write
([]
byte
(
"`"
))
}
func
(
r
PlaintextRenderer
)
DoubleEmphasis
(
out
*
bytes
.
Buffer
,
text
[]
byte
)
{
out
.
Write
(
text
)
...
...
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