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
604c8abb
Commit
604c8abb
authored
Jul 25, 2015
by
Maxime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove debug line, add file name as default title
parent
ef4a4b0a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
12 deletions
+8
-12
middleware/markdown/markdown.go
middleware/markdown/markdown.go
+0
-2
middleware/markdown/process.go
middleware/markdown/process.go
+8
-10
No files found.
middleware/markdown/markdown.go
View file @
604c8abb
...
...
@@ -3,7 +3,6 @@
package
markdown
import
(
"fmt"
"io/ioutil"
"net/http"
"os"
...
...
@@ -126,7 +125,6 @@ func (md Markdown) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error
URL
:
r
.
URL
,
}
html
,
err
:=
md
.
Process
(
m
,
fpath
,
body
,
ctx
)
fmt
.
Printf
(
"%v"
,
html
)
if
err
!=
nil
{
return
http
.
StatusInternalServerError
,
err
}
...
...
middleware/markdown/process.go
View file @
604c8abb
...
...
@@ -68,7 +68,13 @@ func (md Markdown) Process(c Config, requestPath string, b []byte, ctx middlewar
// set it as body for template
metadata
.
Variables
[
"body"
]
=
string
(
markdown
)
metadata
.
Variables
[
"title"
]
=
metadata
.
Title
title
:=
metadata
.
Title
if
title
==
""
{
title
=
filepath
.
Base
(
requestPath
)
var
extension
=
filepath
.
Ext
(
requestPath
)
title
=
title
[
0
:
len
(
title
)
-
len
(
extension
)]
}
metadata
.
Variables
[
"title"
]
=
title
return
md
.
processTemplate
(
c
,
requestPath
,
tmpl
,
metadata
,
ctx
)
}
...
...
@@ -160,15 +166,7 @@ func defaultTemplate(c Config, metadata Metadata, requestPath string) []byte {
}
// Title is first line (length-limited), otherwise filename
title
:=
metadata
.
Title
if
title
==
""
{
title
=
filepath
.
Base
(
requestPath
)
if
body
,
_
:=
metadata
.
Variables
[
"body"
]
.
([]
byte
);
len
(
body
)
>
128
{
title
=
string
(
body
[
:
128
])
}
else
if
len
(
body
)
>
0
{
title
=
string
(
body
)
}
}
title
,
_
:=
metadata
.
Variables
[
"title"
]
.
(
string
)
html
:=
[]
byte
(
htmlTemplate
)
html
=
bytes
.
Replace
(
html
,
[]
byte
(
"{{title}}"
),
[]
byte
(
title
),
1
)
...
...
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