OLD | NEW |
1 package main | 1 package main |
2 | 2 |
3 import ( | 3 import ( |
4 "bytes" | 4 "bytes" |
5 "crypto/md5" | 5 "crypto/md5" |
6 "database/sql" | 6 "database/sql" |
7 "encoding/base64" | 7 "encoding/base64" |
8 "encoding/json" | 8 "encoding/json" |
9 "flag" | 9 "flag" |
10 "fmt" | 10 "fmt" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 os.Chdir(cwd) | 133 os.Chdir(cwd) |
134 | 134 |
135 codeTemplate, err = template.ParseFiles(filepath.Join(cwd, "templates/te
mplate.cpp")) | 135 codeTemplate, err = template.ParseFiles(filepath.Join(cwd, "templates/te
mplate.cpp")) |
136 if err != nil { | 136 if err != nil { |
137 panic(err) | 137 panic(err) |
138 } | 138 } |
139 indexTemplate, err = htemplate.ParseFiles( | 139 indexTemplate, err = htemplate.ParseFiles( |
140 filepath.Join(cwd, "templates/index.html"), | 140 filepath.Join(cwd, "templates/index.html"), |
141 filepath.Join(cwd, "templates/titlebar.html"), | 141 filepath.Join(cwd, "templates/titlebar.html"), |
142 filepath.Join(cwd, "templates/content.html"), | 142 filepath.Join(cwd, "templates/content.html"), |
| 143 filepath.Join(cwd, "templates/headercommon.html"), |
| 144 filepath.Join(cwd, "templates/footercommon.html"), |
143 ) | 145 ) |
144 if err != nil { | 146 if err != nil { |
145 panic(err) | 147 panic(err) |
146 } | 148 } |
147 iframeTemplate, err = htemplate.ParseFiles( | 149 iframeTemplate, err = htemplate.ParseFiles( |
148 filepath.Join(cwd, "templates/iframe.html"), | 150 filepath.Join(cwd, "templates/iframe.html"), |
149 filepath.Join(cwd, "templates/content.html"), | 151 filepath.Join(cwd, "templates/content.html"), |
| 152 filepath.Join(cwd, "templates/headercommon.html"), |
| 153 filepath.Join(cwd, "templates/footercommon.html"), |
150 ) | 154 ) |
151 if err != nil { | 155 if err != nil { |
152 panic(err) | 156 panic(err) |
153 } | 157 } |
154 recentTemplate, err = htemplate.ParseFiles( | 158 recentTemplate, err = htemplate.ParseFiles( |
155 filepath.Join(cwd, "templates/recent.html"), | 159 filepath.Join(cwd, "templates/recent.html"), |
156 filepath.Join(cwd, "templates/titlebar.html"), | 160 filepath.Join(cwd, "templates/titlebar.html"), |
| 161 filepath.Join(cwd, "templates/headercommon.html"), |
| 162 filepath.Join(cwd, "templates/footercommon.html"), |
157 ) | 163 ) |
158 if err != nil { | 164 if err != nil { |
159 panic(err) | 165 panic(err) |
160 } | 166 } |
161 workspaceTemplate, err = htemplate.ParseFiles( | 167 workspaceTemplate, err = htemplate.ParseFiles( |
162 filepath.Join(cwd, "templates/workspace.html"), | 168 filepath.Join(cwd, "templates/workspace.html"), |
163 filepath.Join(cwd, "templates/titlebar.html"), | 169 filepath.Join(cwd, "templates/titlebar.html"), |
164 filepath.Join(cwd, "templates/content.html"), | 170 filepath.Join(cwd, "templates/content.html"), |
| 171 filepath.Join(cwd, "templates/headercommon.html"), |
| 172 filepath.Join(cwd, "templates/footercommon.html"), |
165 ) | 173 ) |
166 if err != nil { | 174 if err != nil { |
167 panic(err) | 175 panic(err) |
168 } | 176 } |
169 | 177 |
170 // The git command returns output of the format: | 178 // The git command returns output of the format: |
171 // | 179 // |
172 // f672cead70404080a991ebfb86c38316a4589b23 2014-04-27 19:21:51 +0000 | 180 // f672cead70404080a991ebfb86c38316a4589b23 2014-04-27 19:21:51 +0000 |
173 // | 181 // |
174 logOutput, err := doCmd(`git log --format=%H%x20%ai HEAD^..HEAD`, true) | 182 logOutput, err := doCmd(`git log --format=%H%x20%ai HEAD^..HEAD`, true) |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 http.HandleFunc("/json/", tryInfoHandler) | 696 http.HandleFunc("/json/", tryInfoHandler) |
689 | 697 |
690 // Resources are served directly | 698 // Resources are served directly |
691 // TODO add support for caching/etags/gzip | 699 // TODO add support for caching/etags/gzip |
692 http.Handle("/res/", http.FileServer(http.Dir("./"))) | 700 http.Handle("/res/", http.FileServer(http.Dir("./"))) |
693 | 701 |
694 // TODO Break out /c/ as it's own handler. | 702 // TODO Break out /c/ as it's own handler. |
695 http.HandleFunc("/", mainHandler) | 703 http.HandleFunc("/", mainHandler) |
696 log.Fatal(http.ListenAndServe(*port, nil)) | 704 log.Fatal(http.ListenAndServe(*port, nil)) |
697 } | 705 } |
OLD | NEW |