mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-03 19:17:29 -05:00 
			
		
		
		
	Merge branch 'master' of https://github.com/mholt/caddy
This commit is contained in:
		
						commit
						60690c78ae
					
				@ -20,7 +20,7 @@ const (
 | 
				
			|||||||
	Name = "Caddy"
 | 
						Name = "Caddy"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Version is the program version
 | 
						// Version is the program version
 | 
				
			||||||
	Version = "0.7.3"
 | 
						Version = "0.7.4"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										16
									
								
								dist/CHANGES.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								dist/CHANGES.txt
									
									
									
									
										vendored
									
									
								
							@ -1,12 +1,18 @@
 | 
				
			|||||||
CHANGES
 | 
					CHANGES
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<master>
 | 
					0.7.4 (July 30, 2015)
 | 
				
			||||||
- browse: Sort preference persisted in cookie
 | 
					- browse: Sorting preference persisted in cookie
 | 
				
			||||||
- browse: Added index.txt and default.txt to list of default files
 | 
					- browse: Added index.txt and default.txt to list of default files
 | 
				
			||||||
- markdown: Fix for large markdown files
 | 
					- browse: Template files may now use Caddy template actions
 | 
				
			||||||
- redir: Can use variables like log formats can
 | 
					- 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: 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)
 | 
					0.7.3 (July 15, 2015)
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								dist/README.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/README.txt
									
									
									
									
										vendored
									
									
								
							@ -1,4 +1,4 @@
 | 
				
			|||||||
CADDY 0.7.3
 | 
					CADDY 0.7.4
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Website
 | 
					Website
 | 
				
			||||||
	https://caddyserver.com
 | 
						https://caddyserver.com
 | 
				
			||||||
 | 
				
			|||||||
@ -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 {
 | 
					func (fi FileInfo) HumanSize() string {
 | 
				
			||||||
	return humanize.Bytes(uint64(fi.Size))
 | 
						return humanize.IBytes(uint64(fi.Size))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// HumanModTime returns the modified time of the file as a human-readable string.
 | 
					// HumanModTime returns the modified time of the file as a human-readable string.
 | 
				
			||||||
 | 
				
			|||||||
@ -6,6 +6,7 @@ import (
 | 
				
			|||||||
	"net"
 | 
						"net"
 | 
				
			||||||
	"net/http"
 | 
						"net/http"
 | 
				
			||||||
	"net/url"
 | 
						"net/url"
 | 
				
			||||||
 | 
						"strings"
 | 
				
			||||||
	"text/template"
 | 
						"text/template"
 | 
				
			||||||
	"time"
 | 
						"time"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@ -13,7 +14,7 @@ import (
 | 
				
			|||||||
// This file contains the context and functions available for
 | 
					// This file contains the context and functions available for
 | 
				
			||||||
// use in the templates.
 | 
					// 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 {
 | 
					type Context struct {
 | 
				
			||||||
	Root http.FileSystem
 | 
						Root http.FileSystem
 | 
				
			||||||
	Req  *http.Request
 | 
						Req  *http.Request
 | 
				
			||||||
@ -48,8 +49,8 @@ func (c Context) Include(filename string) (string, error) {
 | 
				
			|||||||
	return buf.String(), nil
 | 
						return buf.String(), nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Date returns the current timestamp in the specified format
 | 
					// Now returns the current timestamp in the specified format.
 | 
				
			||||||
func (c Context) Date(format string) string {
 | 
					func (c Context) Now(format string) string {
 | 
				
			||||||
	return time.Now().Format(format)
 | 
						return time.Now().Format(format)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -114,3 +115,17 @@ func (c Context) Method() string {
 | 
				
			|||||||
func (c Context) PathMatches(pattern string) bool {
 | 
					func (c Context) PathMatches(pattern string) bool {
 | 
				
			||||||
	return Path(c.Req.URL.Path).Matches(pattern)
 | 
						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)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -55,7 +55,7 @@ func TestMarkdown(t *testing.T) {
 | 
				
			|||||||
						Title:   "first",
 | 
											Title:   "first",
 | 
				
			||||||
						Summary: "",
 | 
											Summary: "",
 | 
				
			||||||
						Date:    time.Now(),
 | 
											Date:    time.Now(),
 | 
				
			||||||
						Url:     "/og/first.md",
 | 
											URL:     "/og/first.md",
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
@ -191,8 +191,8 @@ func getTrue() bool {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	for i, c := range md.Configs {
 | 
						for i, c := range md.Configs {
 | 
				
			||||||
		log.Printf("Test number: %d, configuration links: %v, config: %v", i, c.Links, c)
 | 
							log.Printf("Test number: %d, configuration links: %v, config: %v", i, c.Links, c)
 | 
				
			||||||
		if c.Links[0].Url != expectedLinks[i] {
 | 
							if c.Links[0].URL != expectedLinks[i] {
 | 
				
			||||||
			t.Fatalf("Expected %v got %v", expectedLinks[i], c.Links[0].Url)
 | 
								t.Fatalf("Expected %v got %v", expectedLinks[i], c.Links[0].URL)
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,7 @@
 | 
				
			|||||||
package markdown
 | 
					package markdown
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"bytes"
 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"path/filepath"
 | 
						"path/filepath"
 | 
				
			||||||
@ -16,8 +17,8 @@ const (
 | 
				
			|||||||
	// Date format YYYY-MM-DD HH:MM:SS
 | 
						// Date format YYYY-MM-DD HH:MM:SS
 | 
				
			||||||
	timeLayout = `2006-01-02 15:04:05`
 | 
						timeLayout = `2006-01-02 15:04:05`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Length of page summary.
 | 
						// Maximum length of page summary.
 | 
				
			||||||
	summaryLen = 150
 | 
						summaryLen = 500
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// PageLink represents a statically generated markdown page.
 | 
					// PageLink represents a statically generated markdown page.
 | 
				
			||||||
@ -25,7 +26,7 @@ type PageLink struct {
 | 
				
			|||||||
	Title   string
 | 
						Title   string
 | 
				
			||||||
	Summary string
 | 
						Summary string
 | 
				
			||||||
	Date    time.Time
 | 
						Date    time.Time
 | 
				
			||||||
	Url     string
 | 
						URL     string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// byDate sorts PageLink by newest date to oldest.
 | 
					// byDate sorts PageLink by newest date to oldest.
 | 
				
			||||||
@ -99,15 +100,22 @@ func (l *linkGen) generateLinks(md Markdown, cfg *Config) {
 | 
				
			|||||||
					return err
 | 
										return err
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									// truncate summary to maximum length
 | 
				
			||||||
				if len(summary) > summaryLen {
 | 
									if len(summary) > summaryLen {
 | 
				
			||||||
					summary = summary[:summaryLen]
 | 
										summary = summary[:summaryLen]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
										// trim to nearest word
 | 
				
			||||||
 | 
										lastSpace := bytes.LastIndex(summary, []byte(" "))
 | 
				
			||||||
 | 
										if lastSpace != -1 {
 | 
				
			||||||
 | 
											summary = summary[:lastSpace]
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				metadata := parser.Metadata()
 | 
									metadata := parser.Metadata()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				cfg.Links = append(cfg.Links, PageLink{
 | 
									cfg.Links = append(cfg.Links, PageLink{
 | 
				
			||||||
					Title:   metadata.Title,
 | 
										Title:   metadata.Title,
 | 
				
			||||||
					Url:     reqPath,
 | 
										URL:     reqPath,
 | 
				
			||||||
					Date:    metadata.Date,
 | 
										Date:    metadata.Date,
 | 
				
			||||||
					Summary: string(blackfriday.Markdown(summary, PlaintextRenderer{}, 0)),
 | 
										Summary: string(blackfriday.Markdown(summary, PlaintextRenderer{}, 0)),
 | 
				
			||||||
				})
 | 
									})
 | 
				
			||||||
 | 
				
			|||||||
@ -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) 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) {
 | 
					func (r PlaintextRenderer) DoubleEmphasis(out *bytes.Buffer, text []byte) {
 | 
				
			||||||
	out.Write(text)
 | 
						out.Write(text)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user