Browse Source

Update from current git.txt

master
Dashie der otter 1 year ago
parent
commit
6813e53cae
Signed by: Dashie <dashie@sigpipe.me> GPG Key ID: C2D57B325840B755
100 changed files with 6115 additions and 1121 deletions
  1. 298
    0
      Gopkg.lock
  2. 134
    0
      Gopkg.toml
  3. 0
    99
      Jenkinsfile
  4. 0
    95
      Jenkinsfile.gdsl
  5. 19
    0
      LICENSE.gogs
  6. 1
    1
      cmd/cmd.go
  7. 156
    9
      cmd/web.go
  8. 4
    13
      conf/app.ini
  9. 4
    3
      conf/locale/locale_en-US.ini
  10. 146
    0
      conf/locale/locale_fr-FR.ini
  11. 3
    0
      context/auth.go
  12. 43
    40
      context/context.go
  13. 1
    5
      context/user.go
  14. 0
    120
      glide.lock
  15. 0
    50
      glide.yaml
  16. 0
    0
      i18n.py
  17. 12
    149
      models/error.go
  18. 0
    18
      models/errors/repo.go
  19. 6
    13
      models/errors/user.go
  20. 20
    9
      models/models.go
  21. 1
    1
      models/models_sqlite.go
  22. 40
    37
      models/user.go
  23. 7
    7
      myapp.go
  24. 0
    50
      pkg/form/gitxt.go
  25. 7
    6
      routers/admin/admin.go
  26. 2
    7
      routers/hub.go
  27. 43
    39
      routers/user/auth.go
  28. 6
    4
      routers/user/setting.go
  29. 0
    166
      routes/routes.go
  30. 43
    21
      setting/setting.go
  31. 0
    159
      static/css/custom.css
  32. 108
    0
      static/highlight/agate.css
  33. 66
    0
      static/highlight/androidstudio.css
  34. 88
    0
      static/highlight/arduino-light.css
  35. 73
    0
      static/highlight/arta.css
  36. 45
    0
      static/highlight/ascetic.css
  37. 83
    0
      static/highlight/atelier-cave-dark.css
  38. 85
    0
      static/highlight/atelier-cave-light.css
  39. 69
    0
      static/highlight/atelier-dune-dark.css
  40. 69
    0
      static/highlight/atelier-dune-light.css
  41. 84
    0
      static/highlight/atelier-estuary-dark.css
  42. 84
    0
      static/highlight/atelier-estuary-light.css
  43. 69
    0
      static/highlight/atelier-forest-dark.css
  44. 69
    0
      static/highlight/atelier-forest-light.css
  45. 69
    0
      static/highlight/atelier-heath-dark.css
  46. 69
    0
      static/highlight/atelier-heath-light.css
  47. 69
    0
      static/highlight/atelier-lakeside-dark.css
  48. 69
    0
      static/highlight/atelier-lakeside-light.css
  49. 84
    0
      static/highlight/atelier-plateau-dark.css
  50. 84
    0
      static/highlight/atelier-plateau-light.css
  51. 84
    0
      static/highlight/atelier-savanna-dark.css
  52. 84
    0
      static/highlight/atelier-savanna-light.css
  53. 69
    0
      static/highlight/atelier-seaside-dark.css
  54. 69
    0
      static/highlight/atelier-seaside-light.css
  55. 69
    0
      static/highlight/atelier-sulphurpool-dark.css
  56. 69
    0
      static/highlight/atelier-sulphurpool-light.css
  57. 96
    0
      static/highlight/atom-one-dark.css
  58. 96
    0
      static/highlight/atom-one-light.css
  59. 64
    0
      static/highlight/brown-paper.css
  60. BIN
      static/highlight/brown-papersq.png
  61. 60
    0
      static/highlight/codepen-embed.css
  62. 71
    0
      static/highlight/color-brewer.css
  63. 77
    0
      static/highlight/darcula.css
  64. 63
    0
      static/highlight/dark.css
  65. 6
    0
      static/highlight/darkula.css
  66. 99
    0
      static/highlight/default.css
  67. 97
    0
      static/highlight/docco.css
  68. 76
    0
      static/highlight/dracula.css
  69. 71
    0
      static/highlight/far.css
  70. 88
    0
      static/highlight/foundation.css
  71. 71
    0
      static/highlight/github-gist.css
  72. 99
    0
      static/highlight/github.css
  73. 89
    0
      static/highlight/googlecode.css
  74. 101
    0
      static/highlight/grayscale.css
  75. 108
    0
      static/highlight/gruvbox-dark.css
  76. 108
    0
      static/highlight/gruvbox-light.css
  77. 83
    0
      static/highlight/hopscotch.css
  78. 102
    0
      static/highlight/hybrid.css
  79. 97
    0
      static/highlight/idea.css
  80. 73
    0
      static/highlight/ir-black.css
  81. 74
    0
      static/highlight/kimbie.dark.css
  82. 74
    0
      static/highlight/kimbie.light.css
  83. 70
    0
      static/highlight/magula.css
  84. 59
    0
      static/highlight/mono-blue.css
  85. 83
    0
      static/highlight/monokai-sublime.css
  86. 70
    0
      static/highlight/monokai.css
  87. 88
    0
      static/highlight/obsidian.css
  88. 74
    0
      static/highlight/ocean.css
  89. 72
    0
      static/highlight/paraiso-dark.css
  90. 72
    0
      static/highlight/paraiso-light.css
  91. 83
    0
      static/highlight/pojoaque.css
  92. BIN
      static/highlight/pojoaque.jpg
  93. 96
    0
      static/highlight/purebasic.css
  94. 83
    0
      static/highlight/qtcreator_dark.css
  95. 83
    0
      static/highlight/qtcreator_light.css
  96. 106
    0
      static/highlight/railscasts.css
  97. 85
    0
      static/highlight/rainbow.css
  98. 72
    0
      static/highlight/school-book.css
  99. BIN
      static/highlight/school-book.png
  100. 0
    0
      static/highlight/solarized-dark.css

+ 298
- 0
Gopkg.lock View File

@@ -0,0 +1,298 @@
1
+# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
2
+
3
+
4
+[[projects]]
5
+  name = "github.com/Unknwon/com"
6
+  packages = ["."]
7
+  revision = "28b053d5a2923b87ce8c5a08f3af779894a72758"
8
+  version = "v1"
9
+
10
+[[projects]]
11
+  branch = "master"
12
+  name = "github.com/Unknwon/i18n"
13
+  packages = ["."]
14
+  revision = "b64d336589669d317928070e70ba0ae558f16633"
15
+
16
+[[projects]]
17
+  name = "github.com/certifi/gocertifi"
18
+  packages = ["."]
19
+  revision = "deb3ae2ef2610fde3330947281941c562861188b"
20
+  version = "2018.01.18"
21
+
22
+[[projects]]
23
+  branch = "master"
24
+  name = "github.com/denisenkom/go-mssqldb"
25
+  packages = [
26
+    ".",
27
+    "internal/cp"
28
+  ]
29
+  revision = "e32faac87a2220f9342289f2c3b567d1424b8ec5"
30
+
31
+[[projects]]
32
+  name = "github.com/fatih/color"
33
+  packages = ["."]
34
+  revision = "507f6050b8568533fb3f5504de8e5205fa62a114"
35
+  version = "v1.6.0"
36
+
37
+[[projects]]
38
+  branch = "master"
39
+  name = "github.com/getsentry/raven-go"
40
+  packages = ["."]
41
+  revision = "d1470f50d3a3a38533355a9fab7393e25a3b4226"
42
+
43
+[[projects]]
44
+  branch = "master"
45
+  name = "github.com/go-macaron/binding"
46
+  packages = ["."]
47
+  revision = "ac54ee249c27dca7e76fad851a4a04b73bd1b183"
48
+
49
+[[projects]]
50
+  branch = "master"
51
+  name = "github.com/go-macaron/cache"
52
+  packages = ["."]
53
+  revision = "56173531277692bc2925924d51fda1cd0a6b8178"
54
+
55
+[[projects]]
56
+  branch = "master"
57
+  name = "github.com/go-macaron/csrf"
58
+  packages = ["."]
59
+  revision = "428b7c62d7d0034b048b1cd43ba60d87857f5253"
60
+
61
+[[projects]]
62
+  branch = "master"
63
+  name = "github.com/go-macaron/i18n"
64
+  packages = ["."]
65
+  revision = "ef57533c3b0fc2d8581deda14937e52f11a203ab"
66
+
67
+[[projects]]
68
+  branch = "master"
69
+  name = "github.com/go-macaron/inject"
70
+  packages = ["."]
71
+  revision = "d8a0b8677191f4380287cfebd08e462217bac7ad"
72
+
73
+[[projects]]
74
+  branch = "master"
75
+  name = "github.com/go-macaron/session"
76
+  packages = ["."]
77
+  revision = "b8e286a0dba8f4999042d6b258daf51b31d08938"
78
+
79
+[[projects]]
80
+  branch = "master"
81
+  name = "github.com/go-macaron/toolbox"
82
+  packages = ["."]
83
+  revision = "6766b8f16d1b135b250f09ba4dc4e24ab65b1107"
84
+
85
+[[projects]]
86
+  name = "github.com/go-sql-driver/mysql"
87
+  packages = ["."]
88
+  revision = "a0583e0143b1624142adab07e0e97fe106d99561"
89
+  version = "v1.3"
90
+
91
+[[projects]]
92
+  name = "github.com/go-xorm/builder"
93
+  packages = ["."]
94
+  revision = "a9b7ffcca3f0c6445c4e3b1bf72c01578817a6c3"
95
+  version = "v0.1.0"
96
+
97
+[[projects]]
98
+  name = "github.com/go-xorm/core"
99
+  packages = ["."]
100
+  revision = "f43c33d9a48db006417a7ac4c16b08897e3e1458"
101
+  version = "v0.5.8"
102
+
103
+[[projects]]
104
+  name = "github.com/go-xorm/xorm"
105
+  packages = ["."]
106
+  revision = "fc1b13e0d8e240788213230aa5747eb557f80f41"
107
+  version = "v0.6.6"
108
+
109
+[[projects]]
110
+  name = "github.com/gogits/cron"
111
+  packages = ["."]
112
+  revision = "b024fc5ea0e34bc3f83d9941c8d60b0622bfaca4"
113
+  version = "v1"
114
+
115
+[[projects]]
116
+  branch = "master"
117
+  name = "github.com/gopherjs/gopherjs"
118
+  packages = ["js"]
119
+  revision = "e14987c0ef06db387b90fec85e8d06dc05598e24"
120
+
121
+[[projects]]
122
+  branch = "master"
123
+  name = "github.com/jaytaylor/html2text"
124
+  packages = ["."]
125
+  revision = "64a82a6d140778896f13303121a49d8cb8007034"
126
+
127
+[[projects]]
128
+  name = "github.com/jtolds/gls"
129
+  packages = ["."]
130
+  revision = "77f18212c9c7edc9bd6a33d383a7b545ce62f064"
131
+  version = "v4.2.1"
132
+
133
+[[projects]]
134
+  branch = "master"
135
+  name = "github.com/lib/pq"
136
+  packages = [
137
+    ".",
138
+    "oid"
139
+  ]
140
+  revision = "d34b9ff171c21ad295489235aec8b6626023cd04"
141
+
142
+[[projects]]
143
+  name = "github.com/mattn/go-colorable"
144
+  packages = ["."]
145
+  revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
146
+  version = "v0.0.9"
147
+
148
+[[projects]]
149
+  name = "github.com/mattn/go-isatty"
150
+  packages = ["."]
151
+  revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
152
+  version = "v0.0.3"
153
+
154
+[[projects]]
155
+  name = "github.com/mattn/go-runewidth"
156
+  packages = ["."]
157
+  revision = "9e777a8366cce605130a531d2cd6363d07ad7317"
158
+  version = "v0.0.2"
159
+
160
+[[projects]]
161
+  name = "github.com/mattn/go-sqlite3"
162
+  packages = ["."]
163
+  revision = "6c771bb9887719704b210e87e934f08be014bdb1"
164
+  version = "v1.6.0"
165
+
166
+[[projects]]
167
+  branch = "master"
168
+  name = "github.com/microcosm-cc/bluemonday"
169
+  packages = ["."]
170
+  revision = "995366fdf961d03629cd17361bddd32745718e2c"
171
+
172
+[[projects]]
173
+  branch = "master"
174
+  name = "github.com/olekukonko/tablewriter"
175
+  packages = ["."]
176
+  revision = "b8a9be070da40449e501c3c4730a889e42d87a9e"
177
+
178
+[[projects]]
179
+  name = "github.com/pkg/errors"
180
+  packages = ["."]
181
+  revision = "645ef00459ed84a119197bfb8d8205042c6df63d"
182
+  version = "v0.8.0"
183
+
184
+[[projects]]
185
+  name = "github.com/russross/blackfriday"
186
+  packages = ["."]
187
+  revision = "cadec560ec52d93835bf2f15bd794700d3a2473b"
188
+  version = "v2.0.0"
189
+
190
+[[projects]]
191
+  branch = "master"
192
+  name = "github.com/shurcooL/sanitized_anchor_name"
193
+  packages = ["."]
194
+  revision = "86672fcb3f950f35f2e675df2240550f2a50762f"
195
+
196
+[[projects]]
197
+  name = "github.com/smartystreets/assertions"
198
+  packages = [
199
+    ".",
200
+    "internal/go-render/render",
201
+    "internal/oglematchers"
202
+  ]
203
+  revision = "7678a5452ebea5b7090a6b163f844c133f523da2"
204
+  version = "1.8.3"
205
+
206
+[[projects]]
207
+  name = "github.com/smartystreets/goconvey"
208
+  packages = [
209
+    "convey",
210
+    "convey/gotest",
211
+    "convey/reporting"
212
+  ]
213
+  revision = "9e8dc3f972df6c8fcc0375ef492c24d0bb204857"
214
+  version = "1.6.3"
215
+
216
+[[projects]]
217
+  branch = "master"
218
+  name = "github.com/ssor/bom"
219
+  packages = ["."]
220
+  revision = "6386211fdfcf24c0bfbdaceafd02849ed9a8a509"
221
+
222
+[[projects]]
223
+  name = "github.com/urfave/cli"
224
+  packages = ["."]
225
+  revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1"
226
+  version = "v1.20.0"
227
+
228
+[[projects]]
229
+  branch = "master"
230
+  name = "golang.org/x/crypto"
231
+  packages = [
232
+    "md4",
233
+    "pbkdf2"
234
+  ]
235
+  revision = "d6449816ce06963d9d136eee5a56fca5b0616e7e"
236
+
237
+[[projects]]
238
+  branch = "master"
239
+  name = "golang.org/x/net"
240
+  packages = [
241
+    "html",
242
+    "html/atom"
243
+  ]
244
+  revision = "a35a21de978d84ffc92f010a153705b170b2f9d1"
245
+
246
+[[projects]]
247
+  branch = "master"
248
+  name = "golang.org/x/sys"
249
+  packages = ["unix"]
250
+  revision = "2f57af4873d00d535c5c9028850aa2152e6a5566"
251
+
252
+[[projects]]
253
+  name = "golang.org/x/text"
254
+  packages = [
255
+    "internal/gen",
256
+    "internal/tag",
257
+    "language",
258
+    "unicode/cldr"
259
+  ]
260
+  revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
261
+  version = "v0.3.0"
262
+
263
+[[projects]]
264
+  branch = "v3"
265
+  name = "gopkg.in/alexcesaro/quotedprintable.v3"
266
+  packages = ["."]
267
+  revision = "2caba252f4dc53eaf6b553000885530023f54623"
268
+
269
+[[projects]]
270
+  name = "gopkg.in/clog.v1"
271
+  packages = ["."]
272
+  revision = "8492a6faa632c31ba82f562b53b4a6e5eacf2732"
273
+  version = "v1.1.1"
274
+
275
+[[projects]]
276
+  name = "gopkg.in/gomail.v2"
277
+  packages = ["."]
278
+  revision = "41f3572897373c5538c50a2402db15db079fa4fd"
279
+  version = "2.0.0"
280
+
281
+[[projects]]
282
+  name = "gopkg.in/ini.v1"
283
+  packages = ["."]
284
+  revision = "ace140f73450505f33e8b8418216792275ae82a7"
285
+  version = "v1.35.0"
286
+
287
+[[projects]]
288
+  name = "gopkg.in/macaron.v1"
289
+  packages = ["."]
290
+  revision = "c1be95e6d21e769e44e1ec33cec9da5837861c10"
291
+  version = "v1.3.1"
292
+
293
+[solve-meta]
294
+  analyzer-name = "dep"
295
+  analyzer-version = 1
296
+  inputs-digest = "eb8e54ebf2d03d2bd7d62d7204249c16c509eba8fb728c59f5c0aec72130cf73"
297
+  solver-name = "gps-cdcl"
298
+  solver-version = 1

+ 134
- 0
Gopkg.toml View File

@@ -0,0 +1,134 @@
1
+# Gopkg.toml example
2
+#
3
+# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
4
+# for detailed Gopkg.toml documentation.
5
+#
6
+# required = ["github.com/user/thing/cmd/thing"]
7
+# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
8
+#
9
+# [[constraint]]
10
+#   name = "github.com/user/project"
11
+#   version = "1.0.0"
12
+#
13
+# [[constraint]]
14
+#   name = "github.com/user/project2"
15
+#   branch = "dev"
16
+#   source = "github.com/myfork/project2"
17
+#
18
+# [[override]]
19
+#   name = "github.com/x/y"
20
+#   version = "2.4.0"
21
+#
22
+# [prune]
23
+#   non-go = false
24
+#   go-tests = true
25
+#   unused-packages = true
26
+
27
+
28
+[[constraint]]
29
+  name = "github.com/Unknwon/com"
30
+  version = "1.0.0"
31
+
32
+[[constraint]]
33
+  branch = "master"
34
+  name = "github.com/denisenkom/go-mssqldb"
35
+
36
+[[constraint]]
37
+  branch = "master"
38
+  name = "github.com/getsentry/raven-go"
39
+
40
+[[constraint]]
41
+  branch = "master"
42
+  name = "github.com/go-macaron/binding"
43
+
44
+[[constraint]]
45
+  branch = "master"
46
+  name = "github.com/go-macaron/cache"
47
+
48
+[[constraint]]
49
+  branch = "master"
50
+  name = "github.com/go-macaron/csrf"
51
+
52
+[[constraint]]
53
+  branch = "master"
54
+  name = "github.com/go-macaron/i18n"
55
+
56
+[[constraint]]
57
+  branch = "master"
58
+  name = "github.com/go-macaron/session"
59
+
60
+[[constraint]]
61
+  branch = "master"
62
+  name = "github.com/go-macaron/toolbox"
63
+
64
+[[constraint]]
65
+  name = "github.com/go-sql-driver/mysql"
66
+  version = "1.3.0"
67
+
68
+[[constraint]]
69
+  name = "github.com/go-xorm/core"
70
+  version = "0.5.8"
71
+
72
+[[constraint]]
73
+  name = "github.com/go-xorm/xorm"
74
+  version = "0.6.6"
75
+
76
+[[constraint]]
77
+  name = "github.com/gogits/cron"
78
+  version = "1.0.0"
79
+
80
+[[constraint]]
81
+  branch = "master"
82
+  name = "github.com/jaytaylor/html2text"
83
+
84
+[[constraint]]
85
+  branch = "master"
86
+  name = "github.com/lib/pq"
87
+
88
+[[constraint]]
89
+  name = "github.com/mattn/go-sqlite3"
90
+  version = "1.6.0"
91
+
92
+[[constraint]]
93
+  branch = "master"
94
+  name = "github.com/microcosm-cc/bluemonday"
95
+
96
+[[constraint]]
97
+  name = "github.com/russross/blackfriday"
98
+  version = "2.0.0"
99
+
100
+[[constraint]]
101
+  name = "github.com/smartystreets/goconvey"
102
+  version = "1.6.3"
103
+
104
+[[constraint]]
105
+  name = "github.com/urfave/cli"
106
+  version = "1.20.0"
107
+
108
+[[constraint]]
109
+  branch = "master"
110
+  name = "golang.org/x/crypto"
111
+
112
+[[constraint]]
113
+  branch = "master"
114
+  name = "golang.org/x/net"
115
+
116
+[[constraint]]
117
+  name = "gopkg.in/clog.v1"
118
+  version = "1.1.1"
119
+
120
+[[constraint]]
121
+  name = "gopkg.in/gomail.v2"
122
+  version = "2.0.0"
123
+
124
+[[constraint]]
125
+  name = "gopkg.in/ini.v1"
126
+  version = "1.35.0"
127
+
128
+[[constraint]]
129
+  name = "gopkg.in/macaron.v1"
130
+  version = "1.3.1"
131
+
132
+[prune]
133
+  go-tests = true
134
+  unused-packages = true

+ 0
- 99
Jenkinsfile View File

@@ -1,99 +0,0 @@
1
-#!/usr/bin/env groovy
2
-
3
-// http://www.asciiarmor.com/post/99010893761/jenkins-now-with-more-gopher
4
-// https://medium.com/@reynn/automate-cross-platform-golang-builds-with-jenkins-ef7b07f1366e
5
-// http://grugrut.hatenablog.jp/entry/2017/04/10/201607
6
-// https://gist.github.com/wavded/5e6b0d5016c2a3c05237
7
-
8
-node('linux && x86_64 && go') {
9
-    // Install the desired Go version
10
-    def root = tool name: 'Go 1.8.3', type: 'go'
11
-
12
-    ws("${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_ID}/src/dev.sigpipe.me/dashie/myapp") {
13
-        // Export environment variables pointing to the directory where Go was installed
14
-        env.GOROOT="${root}"
15
-        env.GOPATH="${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_ID}/"
16
-        env.PATH="${GOPATH}/bin:$PATH"
17
-
18
-        stage('Requirements') {
19
-            sh 'go version'
20
-
21
-            sh 'go get -u github.com/golang/lint/golint'
22
-            sh 'go get -u github.com/tebeka/go2xunit'
23
-            sh 'go get github.com/Masterminds/glide'
24
-        }
25
-
26
-        stage('Checkout') {
27
-        //    git url: 'https://dev.sigpipe.me/dashie/myapp.git'
28
-            checkout scm
29
-        }
30
-
31
-        String applicationName = "myapp"
32
-        String appVersion = sh (
33
-            script: "cat myapp.go | awk -F'\"' '/const APP_VER/ { print \$2 }'",
34
-            returnStdout: true
35
-            ).trim()
36
-        String buildNumber = "${appVersion}-${env.BUILD_NUMBER}"
37
-
38
-        stage('Install dependencies') {
39
-            sh 'glide install'
40
-        }
41
-
42
-        stage('Test') {
43
-            // Static check and publish warnings
44
-            sh 'golint $(go list ./... | grep -v /vendor/) > lint.txt'
45
-            warnings canComputeNew: false, canResolveRelativePaths: false, defaultEncoding: '', excludePattern: '', healthy: '', includePattern: '', messagesPattern: '', parserConfigurations: [[parserName: 'Go Lint', pattern: 'lint.txt']], unHealthy: ''
46
-
47
-            // The real tests then publish the results
48
-            try {
49
-                // broken due to some go /vendor directory crap
50
-                sh 'go test -v $(go list ./... | grep -v /vendor/) > tests.txt'
51
-            } catch (err) {
52
-                if (currentBuild.result == 'UNSTABLE')
53
-                    currentBuild.result = 'FAILURE'
54
-                throw err
55
-            } finally {
56
-                sh 'cat tests.txt | go2xunit -output tests.xml'
57
-                step([$class: 'JUnitResultArchiver', testResults: 'tests.xml', healthScaleFactor: 1.0])
58
-                //No such DSL method 'publishHTML'
59
-                //publishHTML (target: [
60
-                //    allowMissing: false,
61
-                //    alwaysLinkToLastBuild: false,
62
-                //    keepAll: true,
63
-                //    reportDir: 'coverage',
64
-                //    reportFiles: 'index.html',
65
-                //    reportName: "Junit Report"
66
-                //])
67
-            }
68
-        }
69
-
70
-        stage('Build') {
71
-            // Darwin/amd64
72
-            //sh "make build GOOS=darwin GOARCH=amd64 BUILD_FLAGS='-o binaries/amd64/${buildNumber}/darwin/${applicationName}-${buildNumber}.darwin.amd6'"
73
-            // Windows/amd64
74
-            //sh "make build GOOS=windows GOARCH=amd64 BUILD_FLAGS='-o binaries/amd64/${buildNumber}/windows/${applicationName}-${buildNumber}.windows.amd64.exe'"
75
-            // Linux/amd64
76
-            sh "make build GOOS=linux GOARCH=amd64 BUILD_FLAGS='-o binaries/amd64/${buildNumber}/linux/${applicationName}-${buildNumber}.linux.amd64'"
77
-        }
78
-
79
-        stage('Archivate Artifacts') {
80
-            // this doesn't works
81
-            //zip dir: '${env.WORKSPACE}/', zipFile: "${env.WORKSPACE}/myapp.linux-${buildNumber}.zip", glob: 'binaries/**,conf,LICENSE*,README*,lint.txt,tests.txt', archive: true
82
-            sh 'ls'
83
-            sh """
84
-            mkdir myapp.linux-${buildNumber}
85
-            cp binaries/amd64/${buildNumber}/linux/${applicationName}-${buildNumber}.linux.amd64 myapp.linux-${buildNumber}
86
-            cp -r conf myapp.linux-${buildNumber}
87
-            cp LICENSE* myapp.linux-${buildNumber}
88
-            cp README.md myapp.linux-${buildNumber}
89
-            cp lint.txt tests.txt myapp.linux-${buildNumber}
90
-            zip -r myapp.linux-${buildNumber}.zip myapp.linux-${buildNumber}
91
-            rm -rf myapp.linux-${buildNumber}
92
-            """
93
-
94
-            archiveArtifacts artifacts: 'binaries/**,conf,LICENSE*,README*', fingerprint: true
95
-            archiveArtifacts artifacts: 'lint.txt,tests.txt', fingerprint: true
96
-            archiveArtifacts artifacts: "myapp.linux-${buildNumber}.zip", fingerprint: true
97
-        }
98
-    } // ws
99
-} // node

+ 0
- 95
Jenkinsfile.gdsl
File diff suppressed because it is too large
View File


+ 19
- 0
LICENSE.gogs View File

@@ -0,0 +1,19 @@
1
+Copyright (c) The Gogs Authors
2
+
3
+Permission is hereby granted, free of charge, to any person obtaining a copy
4
+of this software and associated documentation files (the "Software"), to deal
5
+in the Software without restriction, including without limitation the rights
6
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+copies of the Software, and to permit persons to whom the Software is
8
+furnished to do so, subject to the following conditions:
9
+
10
+The above copyright notice and this permission notice shall be included in
11
+all copies or substantial portions of the Software.
12
+
13
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+THE SOFTWARE.

+ 1
- 1
cmd/cmd.go View File

@@ -34,4 +34,4 @@ func durationFlag(name string, value time.Duration, usage string) cli.DurationFl
34 34
 		Value: value,
35 35
 		Usage: usage,
36 36
 	}
37
-}
37
+}

+ 156
- 9
cmd/web.go View File

@@ -1,18 +1,35 @@
1 1
 package cmd
2 2
 
3 3
 import (
4
+	"dev.sigpipe.me/dashie/myapp/context"
5
+	"dev.sigpipe.me/dashie/myapp/models"
6
+	"dev.sigpipe.me/dashie/myapp/routers"
7
+	"dev.sigpipe.me/dashie/myapp/routers/admin"
8
+	"dev.sigpipe.me/dashie/myapp/routers/user"
4 9
 	"dev.sigpipe.me/dashie/myapp/setting"
10
+	"dev.sigpipe.me/dashie/myapp/stuff/cron"
11
+	"dev.sigpipe.me/dashie/myapp/stuff/form"
12
+	"dev.sigpipe.me/dashie/myapp/stuff/mailer"
13
+	"dev.sigpipe.me/dashie/myapp/stuff/template"
5 14
 	"fmt"
15
+	"github.com/go-macaron/binding"
16
+	"github.com/go-macaron/cache"
17
+	"github.com/go-macaron/csrf"
18
+	"github.com/go-macaron/i18n"
19
+	"github.com/go-macaron/session"
20
+	"github.com/go-macaron/toolbox"
6 21
 	"github.com/urfave/cli"
7 22
 	log "gopkg.in/clog.v1"
23
+	"gopkg.in/macaron.v1"
8 24
 	"net"
9 25
 	"net/http"
10 26
 	"net/http/fcgi"
11 27
 	"os"
28
+	"path"
12 29
 	"strings"
13
-	"dev.sigpipe.me/dashie/myapp/routes"
14 30
 )
15 31
 
32
+// Web command
16 33
 var Web = cli.Command{
17 34
 	Name:        "web",
18 35
 	Usage:       "Start web server",
@@ -24,15 +41,145 @@ var Web = cli.Command{
24 41
 	},
25 42
 }
26 43
 
44
+func newMacaron() *macaron.Macaron {
45
+	m := macaron.New()
46
+	if !setting.DisableRouterLog {
47
+		m.Use(macaron.Logger())
48
+	}
49
+
50
+	m.Use(macaron.Recovery())
51
+
52
+	if setting.Protocol == setting.SchemeFCGI {
53
+		m.SetURLPrefix(setting.AppSubURL)
54
+	}
55
+
56
+	m.Use(macaron.Static(
57
+		path.Join(setting.StaticRootPath, "static"),
58
+		macaron.StaticOptions{
59
+			SkipLogging: setting.DisableRouterLog,
60
+		},
61
+	))
62
+
63
+	funcMap := template.NewFuncMap()
64
+	m.Use(macaron.Renderer(macaron.RenderOptions{
65
+		Directory:  path.Join(setting.StaticRootPath, "templates"),
66
+		Funcs:      funcMap,
67
+		IndentJSON: macaron.Env != macaron.PROD,
68
+	}))
69
+	mailer.InitMailRender(path.Join(setting.StaticRootPath, "templates/mail"), funcMap)
70
+
71
+	m.Use(i18n.I18n(i18n.Options{
72
+		SubURL: setting.AppSubURL,
73
+		//Files:           localFiles,
74
+		Langs:       setting.Langs,
75
+		Names:       setting.Names,
76
+		DefaultLang: "en-US",
77
+		Redirect:    true,
78
+	}))
79
+
80
+	m.Use(cache.Cacher(cache.Options{
81
+		Adapter:       setting.CacheAdapter,
82
+		AdapterConfig: setting.CacheConn,
83
+		Interval:      setting.CacheInterval,
84
+	}))
85
+
86
+	m.Use(session.Sessioner(setting.SessionConfig))
87
+
88
+	m.Use(csrf.Csrfer(csrf.Options{
89
+		Secret:     setting.SecretKey,
90
+		Cookie:     setting.CSRFCookieName,
91
+		SetCookie:  true,
92
+		Header:     "X-Csrf-Token",
93
+		CookiePath: setting.AppSubURL,
94
+	}))
95
+
96
+	m.Use(toolbox.Toolboxer(m, toolbox.Options{
97
+		HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{
98
+			&toolbox.HealthCheckFuncDesc{
99
+				Desc: "Database connection",
100
+				Func: models.Ping,
101
+			},
102
+		},
103
+	}))
104
+
105
+	m.Use(context.Contexter())
106
+
107
+	return m
108
+
109
+}
110
+
27 111
 func runWeb(ctx *cli.Context) error {
28 112
 	if ctx.IsSet("config") {
29 113
 		setting.CustomConf = ctx.String("config")
30 114
 	}
31 115
 
32
-	routes.GlobalInit()
116
+	setting.InitConfig()
117
+	models.InitDb()
118
+	cron.NewContext()
119
+	mailer.NewContext()
120
+
121
+	m := newMacaron()
122
+
123
+	if setting.ProdMode {
124
+		macaron.Env = macaron.PROD
125
+		macaron.ColorLog = false
126
+	} else {
127
+		macaron.Env = macaron.DEV
128
+	}
129
+	log.Info("Run Mode: %s", strings.Title(macaron.Env))
130
+
131
+	reqSignIn := context.Toggle(&context.ToggleOptions{SignInRequired: true})
132
+	reqSignOut := context.Toggle(&context.ToggleOptions{SignOutRequired: true})
133
+
134
+	bindIgnErr := binding.BindIgnErr
135
+
136
+	m.Get("/", func(ctx *context.Context) {})
137
+
138
+	m.Group("/user", func() {
139
+		m.Group("/login", func() {
140
+			m.Combo("").Get(user.Login).Post(bindIgnErr(form.Login{}), user.LoginPost)
141
+		})
142
+		m.Get("/register", user.Register)
143
+		m.Post("/register", csrf.Validate, bindIgnErr(form.Register{}), user.RegisterPost)
144
+		m.Get("/reset_password", user.ResetPasswd)
145
+		m.Post("/reset_password", user.ResetPasswdPost)
146
+	}, reqSignOut)
147
+
148
+	m.Group("/user/settings", func() {
149
+		m.Get("", user.Settings)
150
+		m.Post("", csrf.Validate, bindIgnErr(form.UpdateSettingsProfile{}), user.SettingsPost)
151
+	}, reqSignIn, func(ctx *context.Context) {
152
+		ctx.Data["PageIsUserSettings"] = true
153
+	})
154
+
155
+	m.Group("/user", func() {
156
+		m.Get("/logout", user.Logout)
157
+	}, reqSignIn)
158
+
159
+	m.Group("/user", func() {
160
+		m.Get("/forget_password", user.ForgotPasswd)
161
+		m.Post("/forget_password", user.ForgotPasswdPost)
162
+	})
163
+
164
+	// END USER
165
+
166
+	/* Admin part */
167
+
168
+	adminReq := context.Toggle(&context.ToggleOptions{SignInRequired: true, AdminRequired: true})
169
+	m.Group("/admin", func() {
170
+		m.Get("", adminReq, admin.Dashboard)
171
+	}, adminReq)
172
+
173
+	// robots.txt
174
+	m.Get("/robots.txt", func(ctx *context.Context) {
175
+		if setting.HasRobotsTxt {
176
+			ctx.ServeFileContent(setting.RobotsTxtPath)
177
+		} else {
178
+			ctx.Error(404)
179
+		}
180
+	})
33 181
 
34
-	m := routes.NewMacaron()
35
-	routes.RegisterRoutes(m)
182
+	m.NotFound(routers.NotFound)
36 183
 
37 184
 	if ctx.IsSet("port") {
38 185
 		setting.AppURL = strings.Replace(setting.AppURL, setting.HTTPPort, ctx.String("port"), 1)
@@ -40,7 +187,7 @@ func runWeb(ctx *cli.Context) error {
40 187
 	}
41 188
 
42 189
 	var listenAddr string
43
-	if setting.Protocol == setting.SCHEME_UNIX_SOCKET {
190
+	if setting.Protocol == setting.SchemeUnixSocket {
44 191
 		listenAddr = fmt.Sprintf("%s", setting.HTTPAddr)
45 192
 	} else {
46 193
 		listenAddr = fmt.Sprintf("%s:%s", setting.HTTPAddr, setting.HTTPPort)
@@ -49,13 +196,13 @@ func runWeb(ctx *cli.Context) error {
49 196
 
50 197
 	var err error
51 198
 	switch setting.Protocol {
52
-	case setting.SCHEME_HTTP:
199
+	case setting.SchemeHTTP:
53 200
 		err = http.ListenAndServe(listenAddr, m)
54
-	case setting.SCHEME_HTTPS:
201
+	case setting.SchemeHTTPS:
55 202
 		log.Fatal(2, "https not supported")
56
-	case setting.SCHEME_FCGI:
203
+	case setting.SchemeFCGI:
57 204
 		err = fcgi.Serve(nil, m)
58
-	case setting.SCHEME_UNIX_SOCKET:
205
+	case setting.SchemeUnixSocket:
59 206
 		os.Remove(listenAddr)
60 207
 
61 208
 		var listener *net.UnixListener

+ 4
- 13
conf/app.ini View File

@@ -20,7 +20,7 @@ STATIC_ROOT_PATH =
20 20
 ; Either "mysql", "postgres" or "sqlite3", you can connect to TiDB with MySQL protocol
21 21
 DB_TYPE = sqlite3
22 22
 HOST = 127.0.0.1:3306
23
-NAME = myapp
23
+NAME = gittxt
24 24
 USER = root
25 25
 PASSWD =
26 26
 ; For "postgres" only, either "disable", "require" or "verify-full"
@@ -28,15 +28,6 @@ SSL_MODE = disable
28 28
 ; For "sqlite3" and "tidb", use absolute path when you start as service
29 29
 PATH = myapp.db
30 30
 
31
-[repository]
32
-; Root path for storing repositories's data, default is "~/<username>/gitxt-repositories"
33
-ROOT =
34
-; If you want to disable cloning using HTTP
35
-DISABLE_HTTP_GIT = false
36
-; You can specify full path to git if non-standard
37
-; Git binary is only used for HTTP git upload-pack (checkout over HTTP)
38
-GIT_BINARY = git
39
-
40 31
 [log]
41 32
 ROOT_PATH =
42 33
 
@@ -121,8 +112,8 @@ ENABLE_LOGIN_STATUS_COOKIE = false
121 112
 LOGIN_STATUS_COOKIE_NAME = login_status
122 113
 
123 114
 [i18n]
124
-LANGS = en-US
125
-NAMES = English
115
+LANGS = en-US,fr-FR
116
+NAMES = English,Français
126 117
 
127 118
 [cron]
128 119
 ; Enable running cron tasks periodically.
@@ -181,4 +172,4 @@ FROM =
181 172
 USER =
182 173
 PASSWD =
183 174
 ; Use text/plain as format of content
184
-USE_PLAIN_TEXT = false
175
+USE_PLAIN_TEXT = false

+ 4
- 3
conf/locale/locale_en-US.ini View File

@@ -48,7 +48,7 @@ unknown_error = Unknown error:
48 48
 title = "User settings"
49 49
 update_profile_success = "Profile saved successfully"
50 50
 sidebar.profile = "Profile"
51
-reset_password = "Reset Password"
51
+sidebar.ssh_keys = "SSH Keys"
52 52
 sidebar.reset_password = "Reset Password"
53 53
 
54 54
 [settings_profile]
@@ -130,10 +130,11 @@ version = version
130 130
 page = page
131 131
 template = template
132 132
 sources = Sources
133
+gitxts = Gitxts
134
+managed = managed
133 135
 
134 136
 [header]
135 137
 toggle_nav = Toggle navigation
136
-my_whatever = My whatever
137 138
 settings = Settings
138 139
 admin = Admin
139 140
 logout = Logout
@@ -142,4 +143,4 @@ login = Login
142 143
 
143 144
 [page]
144 145
 next = Next
145
-previous = Previous
146
+previous = Previous

+ 146
- 0
conf/locale/locale_fr-FR.ini View File

@@ -0,0 +1,146 @@
1
+[login]
2
+title = "Se logguer"
3
+sign_in = "Se logguer"
4
+username = "Pseudo"
5
+username_placeholder = "Votre pseudo."
6
+email = "Email"
7
+email_placeholder = "Votre email."
8
+password = "Mot de passe"
9
+password_placeholder = "Votre mot de passe."
10
+repeat_password_placeholder = "Et le même ici."
11
+remember_me = "Se souvenir de moi"
12
+
13
+[register]
14
+title = "S'enregistrer"
15
+register = "S'enregistrer"
16
+not_allowed = "Enregistrement désactivé"
17
+successfull = Enregistrement réussis
18
+password = "Mot de passe"
19
+password_placeholder = "Un bon mot de passe."
20
+
21
+[form]
22
+password_not_match = "Les mots de passes ne correspondent pas"
23
+username_password_incorrect = "Nom d'utilisateur ou mot de passe invalide"
24
+username_been_taken = "Nom d'utilisateur déjà pris"
25
+username_reserved = "Nom d'utilisateur réservé, veuillez en choisir un autre"
26
+username_pattern_not_allowed = "Format de nom d'utilisateur invalide"
27
+save = "Sauver les modifications"
28
+Email = "Email: "
29
+Password = "Mot de passe: "
30
+Description = "Description"
31
+ExpiryHours = "Expiration"
32
+UserName = "Nom d'utilisateur"
33
+
34
+require_error = ` ne peut être vide.`
35
+alpha_dash_error = ` doit être de format alphanumerique ou caractères _ et -.`
36
+alpha_dash_dot_error = ` doit être de format alphanumerique ou caractères _, - ou un point.`
37
+alpha_dash_dot_slash_error = ` doit être de format alphanumerique ou caractères _, -, / ou un point.`
38
+size_error  = ` doit être de taille %s.`
39
+min_size_error = ` doit contenir au minimum %s caracteres.`
40
+max_size_error = ` doit contenir au maximum %s caracteres.`
41
+email_error = "Format d'email invalide"
42
+url_error = ` n'est pas une URL valide.`
43
+include_error = ` doit contenir '%s'.`
44
+in_error = " doit être l'un de: %s"
45
+unknown_error = Erreur inconnue:
46
+
47
+[settings]
48
+title = "Paramètres utilisateur"
49
+update_profile_success = "Profile sauvé avec succès"
50
+sidebar.profile = "Profile"
51
+sidebar.ssh_keys = "Clés SSH"
52
+sidebar.reset_password = "Changer de mot de passe"
53
+
54
+[settings_profile]
55
+title = "Paramtètres utilisateur"
56
+you_are_admin = "Vous êtes admin."
57
+
58
+[user]
59
+unauthorized = Non autorisé
60
+
61
+[admin]
62
+dashboard.system_status=État du système
63
+dashboard.title = Tableau de bord
64
+dashboard.server_uptime=Uptime du serveur
65
+dashboard.current_goroutine=Goroutines actuelles
66
+dashboard.current_memory_usage=Utilisation Mémoire actuelle
67
+dashboard.total_memory_allocated=Mémoire totale allouée
68
+dashboard.memory_obtained=Mémoire obtenue
69
+dashboard.pointer_lookup_times=Nombre de Consultations Pointeur
70
+dashboard.memory_allocate_times=Nombre d'Allocation Mémoire
71
+dashboard.memory_free_times=Nombre de Libération Mémoire
72
+dashboard.current_heap_usage=Utilisation Tas (Heap)
73
+dashboard.heap_memory_obtained=Mémoire Tas (Heap) obtenue
74
+dashboard.heap_memory_idle=Mémoire Tas (Heap) au Repos
75
+dashboard.heap_memory_in_use=Utilisation Mémoire Tas (Heap)
76
+dashboard.heap_memory_released=Mémoire Tas (Heap) libérée
77
+dashboard.heap_objects=Objets Tas (Heap)
78
+dashboard.bootstrap_stack_usage=Utilisation Pile Bootstrap
79
+dashboard.stack_memory_obtained=Mémoire Pile obtenue
80
+dashboard.mspan_structures_usage=Utilisation des Structures MSpan
81
+dashboard.mspan_structures_obtained=Structures MSpan obtenues
82
+dashboard.mcache_structures_usage=Utilisation des Structures MCache
83
+dashboard.mcache_structures_obtained=Structures MCache obtenues
84
+dashboard.profiling_bucket_hash_table_obtained=Profilage de Seau de Table de Hashage obtenu
85
+dashboard.gc_metadata_obtained=Métadonnées GC obtenues
86
+dashboard.other_system_allocation_obtained=Allocation de l'autre Système obtenue
87
+dashboard.next_gc_recycle=Traitement GC suivant
88
+dashboard.last_gc_time=Depuis le dernier GC
89
+dashboard.total_gc_time=Pause GC totale
90
+dashboard.total_gc_pause=Pause GC
91
+dashboard.last_gc_pause=Dernière Pause GC
92
+dashboard.gc_times=Nombres de GC
93
+
94
+monitor.cron=Tâches Cron
95
+monitor.name=Nom
96
+monitor.schedule=Planification
97
+monitor.next=Suivant
98
+monitor.previous=Précédent
99
+monitor.execute_time=Heure d'Éxécution
100
+
101
+[auth]
102
+disable_register_mail=Désolé, la confirmation par e-mail des enregistrements a été désactivée.
103
+forgot_password=Mot de passe oublié
104
+forget_password=Mot de passe oublié ?
105
+confirmation_mail_sent_prompt=Un nouveau mail de confirmation à été envoyé à <b>%s</b>. Veuillez vérifier votre boîte de réception dans un délai de %d heures pour compléter votre enregistrement.
106
+resent_limit_prompt=Désolé, vos tentatives d'activation sont trop fréquentes. Veuillez réessayer dans 3 minutes.
107
+send_reset_mail=Re-envoyer le mail de réinitialisation
108
+reset_password=Réinitialiser le mot de passe
109
+invalid_code=Désolé, votre code de confirmation est invalide ou a expiré.
110
+reset_password_helper=Cliquez ici pour réinitialiser votre mot de passe
111
+password_too_short=Le mot de passe doit contenir 6 caractères minimum.
112
+needs_password_reset = "Besoin de changer votre mot de passe ?"
113
+
114
+[error]
115
+page_not_found = Page non trouvée
116
+internal_server_error = Erreur interne du serveur
117
+error_404_not_found = "Erreur: 404 introuvable"
118
+app_version = "Version d'application: %s"
119
+if_error_app = "Si vous pensez que c'ést une erreur d'application, veuillez ouvrir une issue."
120
+error_occured = "Une erreur est apparue."
121
+error_msg = "Une erreur est apparue : %s"
122
+
123
+[mail]
124
+activate_account = Veuillez activer votre compte
125
+activate_email = Vérifiez votre addresse mail
126
+reset_password = Changez votre mot de passe
127
+
128
+[footer]
129
+version = version
130
+page = page
131
+template = gabarit
132
+sources = Sources
133
+gitxts = Gitxts
134
+managed = gérés
135
+
136
+[header]
137
+toggle_nav = Toggle navigation
138
+settings = Paramètres
139
+admin = Admin
140
+logout = Déconnexion
141
+register = S'enregistrer
142
+login = Connexion
143
+
144
+[page]
145
+next = Suivant
146
+previous = Précédent

+ 3
- 0
context/auth.go View File

@@ -8,13 +8,16 @@ import (
8 8
 	"net/url"
9 9
 )
10 10
 
11
+// ToggleOptions struct
11 12
 type ToggleOptions struct {
12 13
 	SignInRequired  bool
13 14
 	SignOutRequired bool
14 15
 	AdminRequired   bool
15 16
 	DisableCSRF     bool
17
+	AnonymousCreate bool
16 18
 }
17 19
 
20
+// Toggle options
18 21
 func Toggle(options *ToggleOptions) macaron.Handler {
19 22
 	return func(ctx *Context) {
20 23
 		// Redirect non-login pages from logged in user

+ 43
- 40
context/context.go View File

@@ -2,9 +2,9 @@ package context
2 2
 
3 3
 import (
4 4
 	"dev.sigpipe.me/dashie/myapp/models"
5
-	"dev.sigpipe.me/dashie/myapp/pkg/auth"
6
-	"dev.sigpipe.me/dashie/myapp/pkg/form"
7 5
 	"dev.sigpipe.me/dashie/myapp/setting"
6
+	"dev.sigpipe.me/dashie/myapp/stuff/auth"
7
+	"dev.sigpipe.me/dashie/myapp/stuff/form"
8 8
 	"fmt"
9 9
 	"github.com/go-macaron/cache"
10 10
 	"github.com/go-macaron/csrf"
@@ -44,9 +44,9 @@ func (c *Context) PageIs(name string) {
44 44
 }
45 45
 
46 46
 // HTML responses template with given status.
47
-func (ctx *Context) HTML(status int, name string) {
47
+func (c *Context) HTML(status int, name string) {
48 48
 	log.Trace("Template: %s", name)
49
-	ctx.Context.HTML(status, name)
49
+	c.Context.HTML(status, name)
50 50
 }
51 51
 
52 52
 // Success responses template with status http.StatusOK.
@@ -60,45 +60,46 @@ func (c *Context) JSONSuccess(data interface{}) {
60 60
 }
61 61
 
62 62
 // HasError returns true if error occurs in form validation.
63
-func (ctx *Context) HasError() bool {
64
-	hasErr, ok := ctx.Data["HasError"]
63
+func (c *Context) HasError() bool {
64
+	hasErr, ok := c.Data["HasError"]
65 65
 	if !ok {
66 66
 		return false
67 67
 	}
68
-	ctx.Flash.ErrorMsg = ctx.Data["ErrorMsg"].(string)
69
-	ctx.Data["Flash"] = ctx.Flash
68
+	c.Flash.ErrorMsg = c.Data["ErrorMsg"].(string)
69
+	c.Data["Flash"] = c.Flash
70 70
 	return hasErr.(bool)
71 71
 }
72 72
 
73 73
 // RenderWithErr used for page has form validation but need to prompt error to users.
74
-func (ctx *Context) RenderWithErr(msg, tpl string, f interface{}) {
74
+func (c *Context) RenderWithErr(msg, tpl string, f interface{}) {
75 75
 	if f != nil {
76
-		form.Assign(f, ctx.Data)
76
+		form.Assign(f, c.Data)
77 77
 	}
78
-	ctx.Flash.ErrorMsg = msg
79
-	ctx.Data["Flash"] = ctx.Flash
80
-	ctx.HTML(http.StatusOK, tpl)
78
+	c.Flash.ErrorMsg = msg
79
+	c.Data["Flash"] = c.Flash
80
+	c.HTML(http.StatusOK, tpl)
81 81
 }
82 82
 
83 83
 // Handle handles and logs error by given status.
84
-func (ctx *Context) Handle(status int, title string, err error) {
84
+func (c *Context) Handle(status int, title string, err error) {
85 85
 	switch status {
86 86
 	case http.StatusNotFound:
87
-		ctx.Data["Title"] = ctx.Tr("error.page_not_found")
87
+		c.Data["Title"] = c.Tr("error.page_not_found")
88 88
 	case http.StatusInternalServerError:
89
-		ctx.Data["Title"] = ctx.Tr("internal_server_error")
89
+		c.Data["Title"] = c.Tr("error.internal_server_error")
90 90
 		log.Error(2, "%s: %v", title, err)
91 91
 	}
92
-	ctx.HTML(status, fmt.Sprintf("status/%d", status))
92
+	c.HTML(status, fmt.Sprintf("status/%d", status))
93 93
 }
94 94
 
95
-func (ctx *Context) HandleText(status int, title string) {
96
-	ctx.PlainText(status, []byte(title))
95
+// HandleText only
96
+func (c *Context) HandleText(status int, title string) {
97
+	c.PlainText(status, []byte(title))
97 98
 }
98 99
 
99 100
 // NotFound renders the 404 page.
100
-func (ctx *Context) NotFound() {
101
-	ctx.Handle(http.StatusNotFound, "", nil)
101
+func (c *Context) NotFound() {
102
+	c.Handle(http.StatusNotFound, "", nil)
102 103
 }
103 104
 
104 105
 // ServerError renders the 500 page.
@@ -106,7 +107,7 @@ func (c *Context) ServerError(title string, err error) {
106 107
 	c.Handle(http.StatusInternalServerError, title, err)
107 108
 }
108 109
 
109
-// SubURLRedirect responses redirection wtih given location and status.
110
+// SubURLRedirect responses redirection with given location and status.
110 111
 // It prepends setting.AppSubURL to the location string.
111 112
 func (c *Context) SubURLRedirect(location string, status ...int) {
112 113
 	c.Redirect(setting.AppSubURL + location)
@@ -123,7 +124,8 @@ func (c *Context) NotFoundOrServerError(title string, errck func(error) bool, er
123 124
 	c.ServerError(title, err)
124 125
 }
125 126
 
126
-func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{}) {
127
+// ServeContent headers
128
+func (c *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{}) {
127 129
 	modtime := time.Now()
128 130
 	for _, p := range params {
129 131
 		switch v := p.(type) {
@@ -131,17 +133,18 @@ func (ctx *Context) ServeContent(name string, r io.ReadSeeker, params ...interfa
131 133
 			modtime = v
132 134
 		}
133 135
 	}
134
-	ctx.Resp.Header().Set("Content-Description", "File Transfer")
135
-	ctx.Resp.Header().Set("Content-Type", "application/octet-stream")
136
-	ctx.Resp.Header().Set("Content-Disposition", "attachment; filename="+name)
137
-	ctx.Resp.Header().Set("Content-Transfer-Encoding", "binary")
138
-	ctx.Resp.Header().Set("Expires", "0")
139
-	ctx.Resp.Header().Set("Cache-Control", "must-revalidate")
140
-	ctx.Resp.Header().Set("Pragma", "public")
141
-	http.ServeContent(ctx.Resp, ctx.Req.Request, name, modtime, r)
142
-}
143
-
144
-func (ctx *Context) ServeContentNoDownload(name string, mime string, r io.ReadSeeker, params ...interface{}) {
136
+	c.Resp.Header().Set("Content-Description", "File Transfer")
137
+	c.Resp.Header().Set("Content-Type", "application/octet-stream")
138
+	c.Resp.Header().Set("Content-Disposition", "attachment; filename="+name)
139
+	c.Resp.Header().Set("Content-Transfer-Encoding", "binary")
140
+	c.Resp.Header().Set("Expires", "0")
141
+	c.Resp.Header().Set("Cache-Control", "must-revalidate")
142
+	c.Resp.Header().Set("Pragma", "public")
143
+	http.ServeContent(c.Resp, c.Req.Request, name, modtime, r)
144
+}
145
+
146
+// ServeContentNoDownload headers
147
+func (c *Context) ServeContentNoDownload(name string, mime string, r io.ReadSeeker, params ...interface{}) {
145 148
 	modtime := time.Now()
146 149
 	for _, p := range params {
147 150
 		switch v := p.(type) {
@@ -149,12 +152,12 @@ func (ctx *Context) ServeContentNoDownload(name string, mime string, r io.ReadSe
149 152
 			modtime = v
150 153
 		}
151 154
 	}
152
-	ctx.Resp.Header().Set("Content-Description", "File Content")
153
-	ctx.Resp.Header().Set("Content-Type", mime)
154
-	ctx.Resp.Header().Set("Expires", "0")
155
-	ctx.Resp.Header().Set("Cache-Control", "must-revalidate")
156
-	ctx.Resp.Header().Set("Pragma", "public")
157
-	http.ServeContent(ctx.Resp, ctx.Req.Request, name, modtime, r)
155
+	c.Resp.Header().Set("Content-Description", "File Content")
156
+	c.Resp.Header().Set("Content-Type", mime)
157
+	c.Resp.Header().Set("Expires", "0")
158
+	c.Resp.Header().Set("Cache-Control", "must-revalidate")
159
+	c.Resp.Header().Set("Pragma", "public")
160
+	http.ServeContent(c.Resp, c.Req.Request, name, modtime, r)
158 161
 }
159 162
 
160 163
 // Contexter initializes a classic context for a request.

+ 1
- 5
context/user.go View File

@@ -6,15 +6,11 @@ import (
6 6
 	"gopkg.in/macaron.v1"
7 7
 )
8 8
 
9
+// AssignUser to context
9 10
 func AssignUser() macaron.Handler {
10 11
 	return func(ctx *Context) {
11 12
 		userName := ctx.Params("user")
12 13
 
13
-		// Anonymous user doesn't really exists, that's nil
14
-		if userName == "anonymous" {
15
-			return
16
-		}
17
-
18 14
 		_, err := models.GetUserByName(userName)
19 15
 		if err != nil {
20 16
 			if errors.IsUserNotExist(err) {

+ 0
- 120
glide.lock View File

@@ -1,120 +0,0 @@
1
-hash: 755f0d6db77aac14878a3881b2ea6d7912a3a0d7af95bf2b52aa9e6e00a5deb4
2
-updated: 2017-07-30T20:56:34.253279011+02:00
3
-imports:
4
-- name: github.com/certifi/gocertifi
5
-  version: a9c833d2837d3b16888d55d5aafa9ffe9afb22b0
6
-- name: github.com/denisenkom/go-mssqldb
7
-  version: f77039e4e9bc788cb0406a666f410abee0ca1580
8
-- name: github.com/fatih/color
9
-  version: 62e9147c64a1ed519147b62a56a14e83e2be02c1
10
-- name: github.com/getsentry/raven-go
11
-  version: 4fa2ac0d29f801e79a063c0da82d37b5ff2873b2
12
-- name: github.com/go-macaron/binding
13
-  version: 1513c901915731e941815f60ede6a9c21c69a550
14
-- name: github.com/go-macaron/cache
15
-  version: 56173531277692bc2925924d51fda1cd0a6b8178
16
-- name: github.com/go-macaron/csrf
17
-  version: 428b7c62d7d0034b048b1cd43ba60d87857f5253
18
-- name: github.com/go-macaron/i18n
19
-  version: ef57533c3b0fc2d8581deda14937e52f11a203ab
20
-- name: github.com/go-macaron/inject
21
-  version: d8a0b8677191f4380287cfebd08e462217bac7ad
22
-- name: github.com/go-macaron/session
23
-  version: b8e286a0dba8f4999042d6b258daf51b31d08938
24
-- name: github.com/go-macaron/toolbox
25
-  version: 6766b8f16d1b135b250f09ba4dc4e24ab65b1107
26
-- name: github.com/go-sql-driver/mysql
27
-  version: a0583e0143b1624142adab07e0e97fe106d99561
28
-- name: github.com/go-xorm/builder
29
-  version: c8871c857d2555fbfbd8524f895be5386d3d8836
30
-- name: github.com/go-xorm/core
31
-  version: 5bf745d7d163f4380e6c2bba8c4afa60534dd087
32
-- name: github.com/go-xorm/xorm
33
-  version: 3c8314e91603f0bfa6a228c1a0fea8a9e298f6d9
34
-- name: github.com/gogits/cron
35
-  version: c803a08f3bd6f5d5f0281e5ef6a5e09b28488ed7
36
-- name: github.com/jaytaylor/html2text
37
-  version: 7c7a33a7a158a5ce395c803d2b6a209b2bbc14c8
38
-- name: github.com/lib/pq
39
-  version: 91f10e40ba0dd2d0bf9f93ec1d4077711a78df88
40
-  subpackages:
41
-  - oid
42
-- name: github.com/mattn/go-colorable
43
-  version: 5411d3eea5978e6cdc258b30de592b60df6aba96
44
-  repo: https://github.com/mattn/go-colorable
45
-- name: github.com/mattn/go-isatty
46
-  version: 57fdcb988a5c543893cc61bce354a6e24ab70022
47
-  repo: https://github.com/mattn/go-isatty
48
-- name: github.com/mattn/go-runewidth
49
-  version: 97311d9f7767e3d6f422ea06661bc2c7a19e8a5d
50
-- name: github.com/mattn/go-sqlite3
51
-  version: ca5e3819723d8eeaf170ad510e7da1d6d2e94a08
52
-- name: github.com/microcosm-cc/bluemonday
53
-  version: e79763773ab6222ca1d5a7cbd9d62d83c1f77081
54
-- name: github.com/olekukonko/tablewriter
55
-  version: febf2d34b54a69ce7530036c7503b1c9fbfdf0bb
56
-- name: github.com/rakyll/magicmime
57
-  version: 9b99294d6b2216897632b9734769d8ce4568681e
58
-- name: github.com/russross/blackfriday
59
-  version: 0b647d0506a698cca42caca173e55559b12a69f2
60
-- name: github.com/shurcooL/sanitized_anchor_name
61
-  version: 541ff5ee47f1dddf6a5281af78307d921524bcb5
62
-- name: github.com/ssor/bom
63
-  version: 6ed919a936d5ab554e4b40bc51f7c522488122c6
64
-- name: github.com/Unknwon/com
65
-  version: 0db4a625e949e956314d7d1adea9bf82384cc10c
66
-- name: github.com/Unknwon/i18n
67
-  version: 8372b908b5876d26cfa46a85fc4851b981dad102
68
-- name: github.com/Unknwon/paginater
69
-  version: 45e5d631308ea359946e761484147982c978d0df
70
-- name: github.com/urfave/cli
71
-  version: 0bdeddeeb0f650497d603c4ad7b20cfe685682f6
72
-- name: golang.org/x/crypto
73
-  version: e1a4589e7d3ea14a3352255d04b6f1a418845e5e
74
-  subpackages:
75
-  - md4
76
-  - pbkdf2
77
-- name: golang.org/x/net
78
-  version: 3da985ce5951d99de868be4385f21ea6c2b22f24
79
-  subpackages:
80
-  - context
81
-  - html
82
-  - html/atom
83
-- name: golang.org/x/sys
84
-  version: e24f485414aeafb646f6fca458b0bf869c0880a1
85
-  repo: https://go.googlesource.com/sys
86
-  subpackages:
87
-  - unix
88
-- name: golang.org/x/text
89
-  version: 4ee4af566555f5fbe026368b75596286a312663a
90
-  subpackages:
91
-  - internal/tag
92
-  - language
93
-- name: gopkg.in/alexcesaro/quotedprintable.v3
94
-  version: 2caba252f4dc53eaf6b553000885530023f54623
95
-- name: gopkg.in/clog.v1
96
-  version: 8492a6faa632c31ba82f562b53b4a6e5eacf2732
97
-- name: gopkg.in/gomail.v2
98
-  version: 81ebce5c23dfd25c6c67194b37d3dd3f338c98b1
99
-- name: gopkg.in/ini.v1
100
-  version: d3de07a94d22b4a0972deb4b96d790c2c0ce8333
101
-- name: gopkg.in/macaron.v1
102
-  version: a325110f8b392bce3e5cdeb8c44bf98078ada3be
103
-testImports:
104
-- name: github.com/gopherjs/gopherjs
105
-  version: 7cde3d36aea3e1b3be7827c4dcbe6bbae73d012e
106
-  subpackages:
107
-  - js
108
-- name: github.com/jtolds/gls
109
-  version: 77f18212c9c7edc9bd6a33d383a7b545ce62f064
110
-- name: github.com/smartystreets/assertions
111
-  version: 8d53f0381cdc56c7e0f06f4995d21cd04c5a53a8
112
-  subpackages:
113
-  - internal/go-render/render
114
-  - internal/oglematchers
115
-- name: github.com/smartystreets/goconvey
116
-  version: d4c757aa9afd1e2fc1832aaab209b5794eb336e1
117
-  subpackages:
118
-  - convey
119
-  - convey/gotest
120
-  - convey/reporting

+ 0
- 50
glide.yaml View File

@@ -1,50 +0,0 @@
1
-package: dev.sigpipe.me/dashie/myapp
2
-import:
3
-- package: github.com/Unknwon/com
4
-  version: master
5
-- package: github.com/Unknwon/paginater
6
-- package: github.com/denisenkom/go-mssqldb
7
-- package: github.com/getsentry/raven-go
8
-- package: github.com/go-macaron/binding
9
-- package: github.com/go-macaron/cache
10
-- package: github.com/go-macaron/csrf
11
-- package: github.com/go-macaron/i18n
12
-- package: github.com/go-macaron/session
13
-- package: github.com/go-macaron/toolbox
14
-- package: github.com/go-sql-driver/mysql
15
-  version: ^1.3.0
16
-- package: github.com/go-xorm/core
17
-  version: ^0.5.6
18
-- package: github.com/go-xorm/xorm
19
-  version: ^0.6.2
20
-- package: github.com/gogits/cron
21
-  version: master
22
-- package: github.com/jaytaylor/html2text
23
-- package: github.com/lib/pq
24
-- package: github.com/mattn/go-sqlite3
25
-  version: ^1.2.0
26
-- package: github.com/microcosm-cc/bluemonday
27
-- package: github.com/rakyll/magicmime
28
-- package: github.com/russross/blackfriday
29
-  version: ^1.4.0
30
-- package: github.com/urfave/cli
31
-  version: ^1.19.1
32
-- package: golang.org/x/crypto
33
-  subpackages:
34
-  - pbkdf2
35
-- package: golang.org/x/net
36
-  subpackages:
37
-  - html
38
-- package: gopkg.in/clog.v1
39
-  version: master
40
-- package: gopkg.in/gomail.v2
41
-  version: master
42
-- package: gopkg.in/ini.v1
43
-  version: master
44
-- package: gopkg.in/macaron.v1
45
-  version: master
46
-testImport:
47
-- package: github.com/smartystreets/goconvey
48
-  version: ^1.6.2
49
-  subpackages:
50
-  - convey

+ 0
- 0
i18n.py View File


+ 12
- 149
models/error.go View File

@@ -8,28 +8,34 @@ import (
8 8
 	"fmt"
9 9
 )
10 10
 
11
+// ErrNameReserved struct
11 12
 type ErrNameReserved struct {
12 13
 	Name string
13 14
 }
14 15
 
16
+// IsErrNameReserved func
15 17
 func IsErrNameReserved(err error) bool {
16 18
 	_, ok := err.(ErrNameReserved)
17 19
 	return ok
18 20
 }
19 21
 
22
+// Error func
20 23
 func (err ErrNameReserved) Error() string {
21 24
 	return fmt.Sprintf("name is reserved [name: %s]", err.Name)
22 25
 }
23 26
 
27
+// ErrNamePatternNotAllowed struct
24 28
 type ErrNamePatternNotAllowed struct {
25 29
 	Pattern string
26 30
 }
27 31
 
32
+// IsErrNamePatternNotAllowed func
28 33
 func IsErrNamePatternNotAllowed(err error) bool {
29 34
 	_, ok := err.(ErrNamePatternNotAllowed)
30 35
 	return ok
31 36
 }
32 37
 
38
+// Error func
33 39
 func (err ErrNamePatternNotAllowed) Error() string {
34 40
 	return fmt.Sprintf("name pattern is not allowed [pattern: %s]", err.Pattern)
35 41
 }
@@ -41,177 +47,34 @@ func (err ErrNamePatternNotAllowed) Error() string {
41 47
 // |______//____  >\___  >__|
42 48
 //              \/     \/
43 49
 
50
+// ErrUserAlreadyExist struct
44 51
 type ErrUserAlreadyExist struct {
45 52
 	Name string
46 53
 }
47 54
 
55
+// IsErrUserAlreadyExist func
48 56
 func IsErrUserAlreadyExist(err error) bool {
49 57
 	_, ok := err.(ErrUserAlreadyExist)
50 58
 	return ok
51 59
 }
52 60
 
61
+// Error func
53 62
 func (err ErrUserAlreadyExist) Error() string {
54 63
 	return fmt.Sprintf("user already exists [name: %s]", err.Name)
55 64
 }
56 65
 
66
+// ErrEmailAlreadyUsed struct
57 67
 type ErrEmailAlreadyUsed struct {
58 68
 	Email string
59 69
 }
60 70
 
71
+// IsErrEmailAlreadyUsed func
61 72
 func IsErrEmailAlreadyUsed(err error) bool {
62 73
 	_, ok := err.(ErrEmailAlreadyUsed)
63 74
 	return ok
64 75
 }
65 76
 
77
+// Error func
66 78
 func (err ErrEmailAlreadyUsed) Error() string {
67 79
 	return fmt.Sprintf("e-mail has been used [email: %s]", err.Email)
68 80
 }
69
-
70
-type ErrUserOwnRepos struct {
71
-	UID int64
72
-}
73
-
74
-func IsErrUserOwnRepos(err error) bool {
75
-	_, ok := err.(ErrUserOwnRepos)
76
-	return ok
77
-}
78
-
79
-func (err ErrUserOwnRepos) Error() string {
80
-	return fmt.Sprintf("user still has ownership of repositories [uid: %d]", err.UID)
81
-}
82
-
83
-// __________     ___.   .__  .__          ____  __.
84
-// \______   \__ _\_ |__ |  | |__| ____   |    |/ _|____ ___.__.
85
-//  |     ___/  |  \ __ \|  | |  |/ ___\  |      <_/ __ <   |  |
86
-//  |    |   |  |  / \_\ \  |_|  \  \___  |    |  \  ___/\___  |
87
-//  |____|   |____/|___  /____/__|\___  > |____|__ \___  > ____|
88
-//                     \/             \/          \/   \/\/
89
-
90
-type ErrKeyUnableVerify struct {
91
-	Result string
92
-}
93
-
94
-func IsErrKeyUnableVerify(err error) bool {
95
-	_, ok := err.(ErrKeyUnableVerify)
96
-	return ok
97
-}
98
-
99
-func (err ErrKeyUnableVerify) Error() string {
100
-	return fmt.Sprintf("Unable to verify key content [result: %s]", err.Result)
101
-}
102
-
103
-type ErrKeyNotExist struct {
104
-	ID int64
105
-}
106
-
107
-func IsErrKeyNotExist(err error) bool {
108
-	_, ok := err.(ErrKeyNotExist)
109
-	return ok
110
-}
111
-
112
-func (err ErrKeyNotExist) Error() string {
113
-	return fmt.Sprintf("public key does not exist [id: %d]", err.ID)
114
-}
115
-
116
-type ErrKeyAlreadyExist struct {
117
-	OwnerID int64
118
-	Content string
119
-}
120
-
121
-func IsErrKeyAlreadyExist(err error) bool {
122
-	_, ok := err.(ErrKeyAlreadyExist)
123
-	return ok
124
-}
125
-
126
-func (err ErrKeyAlreadyExist) Error() string {
127
-	return fmt.Sprintf("public key already exists [owner_id: %d, content: %s]", err.OwnerID, err.Content)
128
-}
129
-
130
-type ErrKeyNameAlreadyUsed struct {
131
-	OwnerID int64
132
-	Name    string
133
-}
134
-
135
-func IsErrKeyNameAlreadyUsed(err error) bool {
136
-	_, ok := err.(ErrKeyNameAlreadyUsed)
137
-	return ok
138
-}
139
-
140
-func (err ErrKeyNameAlreadyUsed) Error() string {
141
-	return fmt.Sprintf("public key already exists [owner_id: %d, name: %s]", err.OwnerID, err.Name)
142
-}
143
-
144
-type ErrKeyAccessDenied struct {
145
-	UserID int64
146
-	KeyID  int64
147
-	Note   string
148
-}
149
-
150
-func IsErrKeyAccessDenied(err error) bool {
151
-	_, ok := err.(ErrKeyAccessDenied)
152
-	return ok
153
-}
154
-
155
-func (err ErrKeyAccessDenied) Error() string {
156
-	return fmt.Sprintf("user does not have access to the key [user_id: %d, key_id: %d, note: %s]",
157
-		err.UserID, err.KeyID, err.Note)
158
-}
159
-
160
-type ErrDeployKeyNotExist struct {
161
-	ID     int64
162
-	KeyID  int64
163
-	RepoID int64
164
-}
165
-
166
-func IsErrDeployKeyNotExist(err error) bool {
167
-	_, ok := err.(ErrDeployKeyNotExist)
168
-	return ok
169
-}
170
-
171
-func (err ErrDeployKeyNotExist) Error() string {
172
-	return fmt.Sprintf("Deploy key does not exist [id: %d, key_id: %d, repo_id: %d]", err.ID, err.KeyID, err.RepoID)
173
-}
174
-
175
-type ErrDeployKeyAlreadyExist struct {
176
-	KeyID  int64
177
-	RepoID int64
178
-}
179
-
180
-func IsErrDeployKeyAlreadyExist(err error) bool {
181
-	_, ok := err.(ErrDeployKeyAlreadyExist)
182
-	return ok
183
-}
184
-
185
-func (err ErrDeployKeyAlreadyExist) Error() string {
186
-	return fmt.Sprintf("public key already exists [key_id: %d, repo_id: %d]", err.KeyID, err.RepoID)
187
-}
188
-
189
-type ErrDeployKeyNameAlreadyUsed struct {
190
-	RepoID int64
191
-	Name   string
192
-}
193
-
194
-func IsErrDeployKeyNameAlreadyUsed(err error) bool {
195
-	_, ok := err.(ErrDeployKeyNameAlreadyUsed)
196
-	return ok
197
-}
198
-
199
-func (err ErrDeployKeyNameAlreadyUsed) Error() string {
200
-	return fmt.Sprintf("public key already exists [repo_id: %d, name: %s]", err.RepoID, err.Name)
201
-}
202
-
203
-
204
-// Gitxt
205
-type ErrHashAlreadyExist struct {
206
-	Hash string
207
-}
208
-
209
-func IsErrHashAlreadyExist(err error) bool {
210
-	_, ok := err.(ErrHashAlreadyExist)
211
-	return ok
212
-}
213
-
214
-
215
-func (err ErrHashAlreadyExist) Error() string {
216
-	return fmt.Sprintf("hash already exists [hash: %s]", err.Hash)
217
-}

+ 0
- 18
models/errors/repo.go View File

@@ -1,18 +0,0 @@
1
-package errors
2
-
3
-import "fmt"
4
-
5
-type RepoNotExist struct {
6
-	ID     int64
7
-	UserID   int64
8
-	Name   string
9
-}
10
-
11
-func IsRepoNotExist(err error) bool {
12
-	_, ok := err.(RepoNotExist)
13
-	return ok
14
-}
15
-
16
-func (err RepoNotExist) Error() string {
17
-	return fmt.Sprintf("repository does not exist [id: %d, user_id: %d, name: %s]", err.ID, err.UserID, err.Name)
18
-}

+ 6
- 13
models/errors/user.go View File

@@ -6,40 +6,33 @@ package errors
6 6
 
7 7
 import "fmt"
8 8
 
9
+// EmptyName struct
9 10
 type EmptyName struct{}
10 11
 
12
+// IsEmptyName func
11 13
 func IsEmptyName(err error) bool {
12 14
 	_, ok := err.(EmptyName)
13 15
 	return ok
14 16
 }
15 17
 
18
+// Error func
16 19
 func (err EmptyName) Error() string {
17 20
 	return "empty name"
18 21
 }
19 22
 
23
+// UserNotExist struct
20 24
 type UserNotExist struct {
21 25
 	UserID int64
22 26
 	Name   string
23 27
 }
24 28
 
29
+// IsUserNotExist func
25 30
 func IsUserNotExist(err error) bool {
26 31
 	_, ok := err.(UserNotExist)
27 32
 	return ok
28 33
 }
29 34
 
35
+// Error func
30 36
 func (err UserNotExist) Error() string {
31 37
 	return fmt.Sprintf("user does not exist [user_id: %d, name: %s]", err.UserID, err.Name)
32 38
 }
33
-
34
-type UserNotKeyOwner struct {
35
-	KeyID int64
36
-}
37
-
38
-func IsUserNotKeyOwner(err error) bool {
39
-	_, ok := err.(UserNotKeyOwner)
40
-	return ok
41
-}
42
-
43
-func (err UserNotKeyOwner) Error() string {
44
-	return fmt.Sprintf("user is not the owner of public key [key_id: %d]", err.KeyID)
45
-}

+ 20
- 9
models/models.go View File

@@ -5,10 +5,13 @@ import (
5 5
 	"dev.sigpipe.me/dashie/myapp/setting"
6 6
 	"errors"
7 7
 	"fmt"
8
+	// mssql
8 9
 	_ "github.com/denisenkom/go-mssqldb"
10
+	// mysql
9 11
 	_ "github.com/go-sql-driver/mysql"
10 12
 	"github.com/go-xorm/core"
11 13
 	"github.com/go-xorm/xorm"
14
+	// Postgresql
12 15
 	_ "github.com/lib/pq"
13 16
 	log "gopkg.in/clog.v1"
14 17
 	"net/url"
@@ -33,6 +36,7 @@ type Engine interface {
33 36
 	Where(interface{}, ...interface{}) *xorm.Session
34 37
 }
35 38
 
39
+// Vars
36 40
 var (
37 41
 	x         *xorm.Engine
38 42
 	tables    []interface{}
@@ -46,7 +50,8 @@ var (
46 50
 )
47 51
 
48 52
 func init() {
49
-	tables = append(tables, new(User))
53
+	tables = append(tables,
54
+		new(User))
50 55
 
51 56
 	gonicNames := []string{"SSL"}
52 57
 	for _, name := range gonicNames {
@@ -54,6 +59,7 @@ func init() {
54 59
 	}
55 60
 }
56 61
 
62
+// LoadConfigs to init db
57 63
 func LoadConfigs() {
58 64
 	sec := setting.Cfg.Section("database")
59 65
 	DbCfg.Type = sec.Key("DB_TYPE").String()
@@ -108,7 +114,7 @@ func parseMSSQLHostPort(info string) (string, string) {
108 114
 
109 115
 func getEngine() (*xorm.Engine, error) {
110 116
 	connStr := ""
111
-	var Param string = "?"
117
+	var Param = "?"
112 118
 	if strings.Contains(DbCfg.Name, Param) {
113 119
 		Param = "&"
114 120
 	}
@@ -135,32 +141,34 @@ func getEngine() (*xorm.Engine, error) {
135 141
 		connStr = fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;", host, port, DbCfg.Name, DbCfg.User, DbCfg.Passwd)
136 142
 	case "sqlite3":
137 143
 		if !EnableSQLite3 {
138
-			return nil, errors.New("This binary version does not build support for SQLite3.")
144
+			return nil, errors.New("this binary version does not build support for SQLite3")
139 145
 		}
140 146
 		if err := os.MkdirAll(path.Dir(DbCfg.Path), os.ModePerm); err != nil {
141
-			return nil, fmt.Errorf("Fail to create directories: %v", err)
147
+			return nil, fmt.Errorf("fail to create directories: %v", err)
142 148
 		}
143 149
 		connStr = "file:" + DbCfg.Path + "?cache=shared&mode=rwc"
144 150
 	default:
145
-		return nil, fmt.Errorf("Unknown database type: %s", DbCfg.Type)
151
+		return nil, fmt.Errorf("unknown database type: %s", DbCfg.Type)
146 152
 	}
147 153
 	return xorm.NewEngine(DbCfg.Type, connStr)
148 154
 }
149 155
 
156
+// NewTestEngine to test
150 157
 func NewTestEngine(x *xorm.Engine) (err error) {
151 158
 	x, err = getEngine()
152 159
 	if err != nil {
153
-		return fmt.Errorf("Connect to database: %v", err)
160
+		return fmt.Errorf("connect to database: %v", err)
154 161
 	}
155 162
 
156 163
 	x.SetMapper(core.GonicMapper{})
157 164
 	return x.StoreEngine("InnoDB").Sync2(tables...)
158 165
 }
159 166
 
167
+// SetEngine to use
160 168
 func SetEngine() (err error) {
161 169
 	x, err = getEngine()
162 170
 	if err != nil {
163
-		return fmt.Errorf("Fail to connect to database: %v", err)
171
+		return fmt.Errorf("fail to connect to database: %v", err)
164 172
 	}
165 173
 
166 174
 	x.SetMapper(core.GonicMapper{})
@@ -176,7 +184,7 @@ func SetEngine() (err error) {
176 184
 			MaxDays: sec.Key("MAX_DAYS").MustInt64(3),
177 185
 		})
178 186
 	if err != nil {
179
-		return fmt.Errorf("Fail to create 'xorm.log': %v", err)
187
+		return fmt.Errorf("fail to create 'xorm.log': %v", err)
180 188
 	}
181 189
 
182 190
 	x.SetLogger(xorm.NewSimpleLogger3(logger, xorm.DEFAULT_LOG_PREFIX, xorm.DEFAULT_LOG_FLAG, core.LOG_DEBUG))
@@ -184,6 +192,7 @@ func SetEngine() (err error) {
184 192
 	return nil
185 193
 }
186 194
 
195
+// NewEngine to use
187 196
 func NewEngine() (err error) {
188 197
 	if err = SetEngine(); err != nil {
189 198
 		return err
@@ -192,16 +201,18 @@ func NewEngine() (err error) {
192 201
 	// TODO: here do migrations if any
193 202
 
194 203
 	if err = x.StoreEngine("InnoDB").Sync2(tables...); err != nil {
195
-		return fmt.Errorf("sync database struct error: %v\n", err)
204
+		return fmt.Errorf("sync database struct error: %v", err)
196 205
 	}
197 206
 
198 207
 	return nil
199 208
 }
200 209
 
210
+// Ping pong
201 211
 func Ping() error {
202 212
 	return x.Ping()
203 213
 }
204 214
 
215
+// InitDb from config
205 216
 func InitDb() {
206 217
 	LoadConfigs()
207 218
 

+ 1
- 1
models/models_sqlite.go View File

@@ -8,4 +8,4 @@ import (
8 8
 
9 9
 func init() {
10 10
 	EnableSQLite3 = true
11
-}
11
+}

+ 40
- 37
models/user.go View File

@@ -4,8 +4,8 @@ import (
4 4
 	"crypto/sha256"
5 5
 	"crypto/subtle"
6 6
 	"dev.sigpipe.me/dashie/myapp/models/errors"
7
-	"dev.sigpipe.me/dashie/myapp/pkg/mailer"
8
-	"dev.sigpipe.me/dashie/myapp/pkg/tool"
7
+	"dev.sigpipe.me/dashie/myapp/stuff/mailer"
8
+	"dev.sigpipe.me/dashie/myapp/stuff/tool"
9 9
 	"encoding/hex"
10 10
 	"fmt"
11 11
 	"github.com/Unknwon/com"
@@ -16,6 +16,7 @@ import (
16 16
 	"unicode/utf8"
17 17
 )
18 18
 
19
+// User struct
19 20
 type User struct {
20 21
 	ID        int64  `xorm:"pk autoincr"`
21 22
 	UserName  string `xorm:"UNIQUE NOT NULL"`
@@ -34,17 +35,15 @@ type User struct {
34 35
 	CreatedUnix int64
35 36
 	Updated     time.Time `xorm:"-"`
36 37
 	UpdatedUnix int64
37
-
38
-	// Relations
39
-	// 	Gitxts
40
-	// 	SshKeys
41 38
 }
42 39
 
40
+// BeforeInsert hooks
43 41
 func (user *User) BeforeInsert() {
44 42
 	user.CreatedUnix = time.Now().Unix()
45 43
 	user.UpdatedUnix = user.CreatedUnix
46 44
 }
47 45
 
46
+// BeforeUpdate hooks
48 47
 func (user *User) BeforeUpdate() {
49 48
 	user.UpdatedUnix = time.Now().Unix()
50 49
 }
@@ -150,21 +149,22 @@ func isUsableName(names, patterns []string, name string) error {
150 149
 	return nil
151 150
 }
152 151
 
152
+// IsUsableUsername or not
153 153
 func IsUsableUsername(name string) error {
154 154
 	return isUsableName(reservedUsernames, reservedUserPatterns, name)
155 155
 }
156 156
 
157 157
 // EncodePasswd encodes password to safe format.
158
-func (u *User) EncodePasswd() {
159
-	newPasswd := pbkdf2.Key([]byte(u.Password), []byte(u.Salt), 10000, 50, sha256.New)
160
-	u.Password = fmt.Sprintf("%x", newPasswd)
158
+func (user *User) EncodePasswd() {
159
+	newPasswd := pbkdf2.Key([]byte(user.Password), []byte(user.Salt), 10000, 50, sha256.New)
160
+	user.Password = fmt.Sprintf("%x", newPasswd)
161 161
 }
162 162
 
163 163
 // ValidatePassword checks if given password matches the one belongs to the user.
164
-func (u *User) ValidatePassword(passwd string) bool {
165
-	newUser := &User{Password: passwd, Salt: u.Salt}
164
+func (user *User) ValidatePassword(passwd string) bool {
165
+	newUser := &User{Password: passwd, Salt: user.Salt}
166 166
 	newUser.EncodePasswd()
167
-	return subtle.ConstantTimeCompare([]byte(u.Password), []byte(newUser.Password)) == 1
167
+	return subtle.ConstantTimeCompare([]byte(user.Password), []byte(newUser.Password)) == 1
168 168
 }
169 169
 
170 170
 // GetUserSalt returns a ramdom user salt token.
@@ -172,7 +172,7 @@ func GetUserSalt() (string, error) {
172 172
 	return tool.RandomString(10)
173 173
 }
174 174
 
175
-// Create a new user and do some validation
175
+// CreateUser and do some validation
176 176
 func CreateUser(u *User) (err error) {
177 177
 	if err = IsUsableUsername(u.UserName); err != nil {
178 178
 		return err
@@ -202,10 +202,6 @@ func CreateUser(u *User) (err error) {
202 202
 		return err
203 203
 	}
204 204
 
205
-	if _, err = sess.Insert(u); err != nil {
206
-		return err
207
-	}
208
-
209 205
 	return sess.Commit()
210 206
 }
211 207
 
@@ -217,11 +213,12 @@ func updateUser(e Engine, u *User) error {
217 213
 	return err
218 214
 }
219 215
 
216
+// UpdateUser with datas
220 217
 func UpdateUser(u *User) error {
221 218
 	return updateUser(x, u)
222 219
 }
223 220
 
224
-// Login validates user name and password.
221
+// UserLogin validates user name and password.
225 222
 func UserLogin(username, password string) (*User, error) {
226 223
 	var user *User
227 224
 	if strings.Contains(username, "@") {
@@ -248,12 +245,12 @@ func UserLogin(username, password string) (*User, error) {
248 245
 
249 246
 // get user by verify code
250 247
 func getVerifyUser(code string) (user *User) {
251
-	if len(code) <= tool.TIME_LIMIT_CODE_LENGTH {
248
+	if len(code) <= tool.TimeLimitCodeLength {
252 249
 		return nil
253 250
 	}
254 251
 
255 252
 	// use tail hex username query user
256
-	hexStr := code[tool.TIME_LIMIT_CODE_LENGTH:]
253
+	hexStr := code[tool.TimeLimitCodeLength:]
257 254
 	if b, err := hex.DecodeString(hexStr); err == nil {
258 255
 		if user, err = GetUserByName(string(b)); user != nil {
259 256
 			return user
@@ -265,14 +262,14 @@ func getVerifyUser(code string) (user *User) {
265 262
 	return nil
266 263
 }
267 264
 
268
-// verify active code when active account
265
+// VerifyUserActiveCode when active account
269 266
 func VerifyUserActiveCode(code string) (user *User) {
270 267
 	// HARDCODED
271 268
 	minutes := 180
272 269
 
273 270
 	if user = getVerifyUser(code); user != nil {
274 271
 		// time limit code
275
-		prefix := code[:tool.TIME_LIMIT_CODE_LENGTH]
272
+		prefix := code[:tool.TimeLimitCodeLength]
276 273
 		data := com.ToStr(user.ID) + user.Email + user.LowerName + user.Password + user.Rands
277 274
 
278 275
 		if tool.VerifyTimeLimitCode(data, minutes, prefix) {
@@ -283,18 +280,18 @@ func VerifyUserActiveCode(code string) (user *User) {
283 280
 }
284 281
 
285 282
 // GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
286
-func (u *User) GenerateEmailActivateCode(email string) string {
283
+func (user *User) GenerateEmailActivateCode(email string) string {
287 284
 	code := tool.CreateTimeLimitCode(
288
-		com.ToStr(u.ID)+email+u.LowerName+u.Password+u.Rands, 180, nil)
285
+		com.ToStr(user.ID)+email+user.LowerName+user.Password+user.Rands, 180, nil)
289 286
 
290 287
 	// Add tail hex username
291
-	code += hex.EncodeToString([]byte(u.LowerName))
288
+	code += hex.EncodeToString([]byte(user.LowerName))
292 289
 	return code
293 290
 }
294 291
 
295 292
 // GenerateActivateCode generates an activate code based on user information.
296
-func (u *User) GenerateActivateCode() string {
297
-	return u.GenerateEmailActivateCode(u.Email)
293
+func (user *User) GenerateActivateCode() string {
294
+	return user.GenerateEmailActivateCode(user.Email)
298 295
 }
299 296
 
300 297
 // mailerUser is a wrapper for satisfying mailer.User interface.
@@ -302,26 +299,32 @@ type mailerUser struct {
302 299
 	user *User
303 300
 }
304 301
 
305
-func (this mailerUser) ID() int64 {
306
-	return this.user.ID
302
+// ID id
303
+func (mUser mailerUser) ID() int64 {
304
+	return mUser.user.ID
307 305
 }
308 306
 
309
-func (this mailerUser) Email() string {
310
-	return this.user.Email
307
+// Email func
308
+func (mUser mailerUser) Email() string {
309
+	return mUser.user.Email
311 310
 }
312 311
 
313
-func (this mailerUser) DisplayName() string {
314
-	return this.user.UserName
312
+// DisplayName func
313
+func (mUser mailerUser) DisplayName() string {
314
+	return mUser.user.UserName
315 315
 }
316 316
 
317
-func (this mailerUser) GenerateActivateCode() string {
318
-	return this.user.GenerateActivateCode()
317
+// GenerateActivateCode func
318
+func (mUser mailerUser) GenerateActivateCode() string {
319
+	return mUser.user.GenerateActivateCode()
319 320
 }
320 321
 
321
-func (this mailerUser) GenerateEmailActivateCode(email string) string {
322
-	return this.user.GenerateEmailActivateCode(email)
322
+// GenerateEmailActivateCode func
323
+func (mUser mailerUser) GenerateEmailActivateCode(email string) string {
324
+	return mUser.user.GenerateEmailActivateCode(email)
323 325
 }
324 326
 
327
+// NewMailerUser mail user
325 328
 func NewMailerUser(u *User) mailer.User {
326 329
 	return mailerUser{u}
327 330
 }

+ 7
- 7
myapp.go View File

@@ -1,18 +1,18 @@
1 1
 package main
2 2
 
3 3
 import (
4
-	"os"
5
-	"github.com/urfave/cli"
6 4
 	"dev.sigpipe.me/dashie/myapp/cmd"
7 5
 	"dev.sigpipe.me/dashie/myapp/setting"
8
-	"github.com/getsentry/raven-go"
9 6
 	"fmt"
7
+	"github.com/getsentry/raven-go"
8
+	"github.com/urfave/cli"
9
+	"os"
10 10
 )
11 11
 
12
-const APP_VER = "0.2"
12
+const appVersion = "0.5.2"
13 13
 
14 14
 func init() {
15
-	setting.AppVer = APP_VER
15
+	setting.AppVer = appVersion
16 16
 	if os.Getenv("USE_RAVEN") == "true" {
17 17
 		raven.SetDSN(os.Getenv("RAVEN_DSN"))
18 18
 		fmt.Printf("Using Raven with DSN: %s\r\n", os.Getenv("RAVEN_DSN"))
@@ -24,8 +24,8 @@ func init() {
24 24
 func main() {
25 25
 	app := cli.NewApp()
26 26
 	app.Name = "myapp"
27
-	app.Usage = "paste stuff to the interweb with git backend"
28
-	app.Version = APP_VER
27
+	app.Usage = "myapp"
28
+	app.Version = appVersion
29 29
 	app.Commands = []cli.Command{
30 30
 		cmd.Web,
31 31
 	}

+ 0
- 50
pkg/form/gitxt.go View File

@@ -1,50 +0,0 @@
1
-package form
2
-
3
-import (
4
-	"gopkg.in/macaron.v1"
5
-	"github.com/go-macaron/binding"
6
-)
7
-
8
-/* New Gitxt */
9
-type Gitxt struct {
10
-	Description string `binding:"MaxSize(255)"`
11
-	IsPublic    bool   `binding:"Default:1"`
12
-	// Validation builtin into Macaron/Binding doesn't validates theses slices
13
-	// See the router view for manual validation
14
-	FilesFilename	[]string `binding:"Required;MaxSize(255);MinSizeSlice(1)"`
15
-	FilesContent	[]string `binding:"Required;MaxSize(255);MinSizeSlice(1)"`
16
-
17
-	//				     no, 1h, 4h, 1d, 2d, 3d, 4d, 5d,  6d,  7d,  1m,  1y
18
-	ExpiryHours	int64	`binding:"In(0,1,4,24,48,72,96,120,144,168,730,8760);Default(0)"`
19
-}
20
-
21
-func (f *Gitxt) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
22
-	return validate(errs, ctx.Data, f, ctx.Locale)
23
-}
24
-
25
-/* Delete Gitxt */
26
-type GitxtDelete struct {
27
-	Hash    string   `binding:"Required"`
28
-	Owner    string   `binding:"Required"`
29
-}
30
-
31
-func (f *GitxtDelete) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
32
-	return validate(errs, ctx.Data, f, ctx.Locale)
33
-}
34
-
35
-/* Edit Gitxt */
36
-type GitxtEdit struct {
37
-	Description string `binding:"MaxSize(255)"`
38
-	// Validation builtin into Macaron/Binding doesn't validates theses slices
39
-	// See the router view for manual validation
40
-	FilesFilename	[]string `binding:"Required;MaxSize(255);MinSizeSlice(1)"`
41
-	FilesContent	[]string `binding:"Required;MaxSize(255);MinSizeSlice(1)"`
42
-	FilesNotHandled []bool
43
-
44
-	//				     no, 1h, 4h, 1d, 2d, 3d, 4d, 5d,  6d,  7d,  1m,  1y
45
-	ExpiryHours	int64	`binding:"In(0,1,4,24,48,72,96,120,144,168,730,8760);Default(0)"`
46
-}
47
-
48
-func (f *GitxtEdit) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
49
-	return validate(errs, ctx.Data, f, ctx.Locale)
50
-}

routes/admin/admin.go → routers/admin/admin.go View File

@@ -2,15 +2,15 @@ package admin
2 2
 
3 3
 import (
4 4
 	"dev.sigpipe.me/dashie/myapp/context"
5
-	"time"
6
-	"dev.sigpipe.me/dashie/myapp/pkg/tool"
7
-	"dev.sigpipe.me/dashie/myapp/pkg/cron"
8
-	"runtime"
5
+	"dev.sigpipe.me/dashie/myapp/stuff/cron"
6
+	"dev.sigpipe.me/dashie/myapp/stuff/tool"
9 7
 	"fmt"
8
+	"runtime"
9
+	"time"
10 10
 )
11 11
 
12 12
 const (
13
-	DASHBOARD = "admin/dashboard"
13
+	tmplDashboard = "admin/dashboard"
14 14
 )
15 15
 
16 16
 var (
@@ -96,6 +96,7 @@ func updateSystemStatus() {
96 96
 	sysStatus.NumGC = m.NumGC
97 97
 }
98 98
 
99
+// Dashboard GET
99 100
 func Dashboard(ctx *context.Context) {
100 101
 	ctx.Title("admin.dashboard.title")
101 102
 	ctx.PageIs("AdminDashboard")
@@ -105,5 +106,5 @@ func Dashboard(ctx *context.Context) {
105 106
 	updateSystemStatus()
106 107
 	ctx.Data["SysStatus"] = sysStatus
107 108
 	ctx.Data["Entries"] = cron.ListTasks()
108
-	ctx.HTML(200, DASHBOARD)
109
+	ctx.HTML(200, tmplDashboard)
109 110
 }

routes/hub.go → routers/hub.go View File

@@ -1,14 +1,9 @@
1
-package routes
1
+package routers
2 2
 
3 3
 import "dev.sigpipe.me/dashie/myapp/context"
4 4
 
5
+// NotFound 404
5 6
 func NotFound(ctx *context.Context) {
6 7
 	ctx.Title(ctx.Tr("error.page_not_found"))
7 8
 	ctx.Handle(404, "home.NotFound", nil)
8 9
 }
9
-
10
-func Home(ctx *context.Context) {
11
-	ctx.Title("Home page")
12
-	ctx.PageIs("hub.home")
13
-	ctx.Success("home")
14
-}

routes/user/auth.go → routers/user/auth.go View File

@@ -2,21 +2,21 @@ package user
2 2
 
3 3
 import (
4 4
 	"dev.sigpipe.me/dashie/myapp/context"
5
-	"dev.sigpipe.me/dashie/myapp/setting"
6
-	"dev.sigpipe.me/dashie/myapp/pkg/form"
7 5
 	"dev.sigpipe.me/dashie/myapp/models"
8
-	"dev.sigpipe.me/dashie/myapp/pkg/mailer"
9
-	log "gopkg.in/clog.v1"
10 6
 	"dev.sigpipe.me/dashie/myapp/models/errors"
11
-	"net/url"
7
+	"dev.sigpipe.me/dashie/myapp/setting"
8
+	"dev.sigpipe.me/dashie/myapp/stuff/form"
9
+	"dev.sigpipe.me/dashie/myapp/stuff/mailer"
12 10
 	"fmt"
11
+	log "gopkg.in/clog.v1"
12
+	"net/url"
13 13
 )
14 14
 
15 15
 const (
16
-	LOGIN	= "user/auth/login"
17
-	REGISTER = "user/auth/register"
18
-	FORGOT_PASSWORD = "user/auth/forgot_password"
19
-	RESET_PASSWORD = "user/auth/reset_password"
16
+	tmplLogin          = "user/auth/login"
17
+	tmplRegister       = "user/auth/register"
18
+	tmplForgotPassword = "user/auth/forgot_password"
19
+	tmplResetPassword  = "user/auth/reset_password"
20 20
 )
21 21
 
22 22
 // isValidRedirect returns false if the URL does not redirect to same site.
@@ -69,7 +69,7 @@ func AutoLogin(c *context.Context) (bool, error) {
69 69
 	return true, nil
70 70
 }
71 71
 
72
-// Login
72
+// Login GET
73 73
 func Login(ctx *context.Context) {
74 74
 	ctx.Title("login.title")
75 75
 
@@ -97,21 +97,22 @@ func Login(ctx *context.Context) {
97 97
 		return
98 98
 	}
99 99
 
100
-	ctx.HTML(200, LOGIN)
100
+	ctx.HTML(200, tmplLogin)
101 101
 }
102 102
 
103
+// LoginPost POST
103 104
 func LoginPost(ctx *context.Context, f form.Login) {
104 105
 	ctx.Title("login.title")
105 106
 
106 107
 	if ctx.HasError() {
107
-		ctx.Success(LOGIN)
108
+		ctx.Success(tmplLogin)
108 109
 		return
109 110
 	}
110 111
 
111 112
 	u, err := models.UserLogin(f.UserName, f.Password)
112 113
 	if err != nil {
113 114
 		if errors.IsUserNotExist(err) {
114
-			ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), LOGIN, &f)
115
+			ctx.RenderWithErr(ctx.Tr("form.username_password_incorrect"), tmplLogin, &f)
115 116
 		} else {
116 117
 			ctx.ServerError("UserSignIn", err)
117 118
 		}
@@ -149,56 +150,57 @@ func afterLogin(ctx *context.Context, u *models.User, remember bool) {
149 150
 	ctx.Redirect(setting.AppSubURL + "/")
150 151
 }
151 152
 
152
-// Registration
153
+// Register GET
153 154
 func Register(ctx *context.Context) {
154 155
 	ctx.Title("register.title")
155
-	if ! setting.CanRegister {
156
+	if !setting.CanRegister {
156 157
 		ctx.Flash.Error(ctx.Tr("register.not_allowed"))
157 158
 		ctx.Redirect(setting.AppSubURL + "/")
158 159
 		return
159 160
 	}
160 161
 
161
-	ctx.HTML(200, REGISTER)
162
+	ctx.HTML(200, tmplRegister)
162 163
 }
163 164
 
165
+// RegisterPost POST
164 166
 func RegisterPost(ctx *context.Context, f form.Register) {
165 167
 	ctx.Title("register.title")
166 168
 
167
-	if ! setting.CanRegister {
169
+	if !setting.CanRegister {
168 170
 		ctx.Flash.Error(ctx.Tr("register.not_allowed"))
169 171
 		ctx.Redirect(setting.AppSubURL + "/")
170 172
 		return
171 173
 	}
172 174
 
173 175
 	if ctx.HasError() {
174
-		ctx.HTML(200, REGISTER)
176
+		ctx.HTML(200, tmplRegister)
175 177
 		return
176 178
 	}
177 179
 
178 180
 	if f.Password != f.Repeat {
179 181
 		ctx.Data["Err_Password"] = true
180 182
 		ctx.Data["Err_Retype"] = true
181
-		ctx.RenderWithErr(ctx.Tr("form.password_not_match"), REGISTER, &f)
183
+		ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tmplRegister, &f)
182 184
 		return
183 185
 	}
184 186
 
185 187
 	u := &models.User{
186
-		UserName:	f.UserName,
187
-		Email:		f.Email,
188
-		Password:	f.Password,
189
-		IsActive:	true, // FIXME: implement user activation by email
188
+		UserName: f.UserName,
189
+		Email:    f.Email,
190
+		Password: f.Password,
191
+		IsActive: true, // FIXME: implement user activation by email
190 192
 	}
191 193
 	if err := models.CreateUser(u); err != nil {
192 194
 		switch {
193 195
 		case models.IsErrUserAlreadyExist(err):
194 196
 			ctx.Data["Err_UserName"] = true
195
-			ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), REGISTER, &f)
197
+			ctx.RenderWithErr(ctx.Tr("form.username_been_taken"), tmplRegister, &f)
196 198
 		case models.IsErrNameReserved(err):
197 199
 			ctx.Data["Err_UserName"] = true
198
-			ctx.RenderWithErr(ctx.Tr("form.username_reserved"), REGISTER, &f)
200
+			ctx.RenderWithErr(ctx.Tr("form.username_reserved"), tmplRegister, &f)
199 201
 		case models.IsErrNamePatternNotAllowed(err):
200 202
 			ctx.Data["Err_UserName"] = true
201
-			ctx.RenderWithErr(ctx.Tr("form.username_pattern_not_allowed"), REGISTER, &f)
203
+			ctx.RenderWithErr(ctx.Tr("form.username_pattern_not_allowed"), tmplRegister, &f)
202 204
 		default:
203 205
 			ctx.Handle(500, "CreateUser", err)
204 206
 		}
@@ -222,7 +224,7 @@ func RegisterPost(ctx *context.Context, f form.Register) {
222 224
 	ctx.Redirect(setting.AppSubURL + "/user/login")
223 225
 }
224 226
 
225
-// Logout
227
+// Logout GET
226 228
 func Logout(ctx *context.Context) {
227 229
 	ctx.Session.Delete("uid")
228 230
 	ctx.Session.Delete("uname")
@@ -232,8 +234,7 @@ func Logout(ctx *context.Context) {
232 234
 	ctx.Redirect(setting.AppSubURL + "/")
233 235
 }
234 236
 
235
-
236
-// ResetPassword
237
+// ResetPasswd GET
237 238
 func ResetPasswd(ctx *context.Context) {
238 239
 	ctx.Title("auth.reset_password")
239 240
 	code := ctx.Query("code")
@@ -243,9 +244,10 @@ func ResetPasswd(ctx *context.Context) {
243 244
 	}
244 245
 	ctx.Data["Code"] = code
245 246
 	ctx.Data["IsResetForm"] = true
246
-	ctx.HTML(200, RESET_PASSWORD)
247
+	ctx.HTML(200, tmplResetPassword)
247 248
 }
248 249
 
250
+// ResetPasswdPost POST
249 251
 func ResetPasswdPost(ctx *context.Context) {
250 252
 	ctx.Title("auth.reset_password")
251 253
 
@@ -262,7 +264,7 @@ func ResetPasswdPost(ctx *context.Context) {
262 264
 		if len(passwd) < 6 {
263 265
 			ctx.Data["IsResetForm"] = true
264 266
 			ctx.Data["Err_Password"] = true
265
-			ctx.RenderWithErr(ctx.Tr("auth.password_too_short"), RESET_PASSWORD, nil)
267
+			ctx.RenderWithErr(ctx.Tr("auth.password_too_short"), tmplResetPassword, nil)
266 268
 			return
267 269
 		}
268 270
 
@@ -287,23 +289,25 @@ func ResetPasswdPost(ctx *context.Context) {
287 289
 		return
288 290
 	}
289 291
 	ctx.Data["IsResetFailed"] = true
290
-	ctx.HTML(200, RESET_PASSWORD)
292
+	ctx.HTML(200, tmplResetPassword)
291 293
 }
292 294
 
295
+// ForgotPasswd GET
293 296
 func ForgotPasswd(ctx *context.Context) {
294 297
 	ctx.Title("auth.forgot_password")
295 298
 
296 299
 	if setting.MailService == nil {
297 300
 		ctx.Data["IsResetDisable"] = true
298
-		ctx.HTML(200, FORGOT_PASSWORD)
301
+		ctx.HTML(200, tmplForgotPassword)
299 302
 		return
300 303
 	}
301 304
 
302 305
 	ctx.Data["IsResetRequest"] = true
303 306
 
304
-	ctx.HTML(200, FORGOT_PASSWORD)
307
+	ctx.HTML(200, tmplForgotPassword)
305 308
 }
306 309
 
310
+// ForgotPasswdPost POST
307 311
 func ForgotPasswdPost(ctx *context.Context) {
308 312
 	ctx.Title("auth.forgot_password")
309 313
 
@@ -323,18 +327,18 @@ func ForgotPasswdPost(ctx *context.Context) {
323 327
 			ctx.Data["Hours"] = 180 / 60
324 328
 			ctx.Data["IsResetSent"] = true
325 329
 			log.Trace("User doesn't exists")
326
-			ctx.HTML(200, FORGOT_PASSWORD)
330
+			ctx.HTML(200, tmplForgotPassword)
327 331
 			return
328
-		} else {
329
-			ctx.Handle(500, "user.ResetPasswd(check existence)", err)
330 332
 		}
333
+
334
+		ctx.Handle(500, "user.ResetPasswd(check existence)", err)
331 335
 		return
332 336
 	}
333 337
 
334 338
 	if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) {
335 339
 		log.Trace("Mail Resend limited")
336 340
 		ctx.Data["ResendLimited"] = true
337
-		ctx.HTML(200, FORGOT_PASSWORD)
341
+		ctx.HTML(200, tmplForgotPassword)
338 342
 		return
339 343
 	}
340 344
 
@@ -346,5 +350,5 @@ func ForgotPasswdPost(ctx *context.Context) {
346 350
 	// HARDCODED
347 351
 	ctx.Data["Hours"] = 180 / 60
348 352
 	ctx.Data["IsResetSent"] = true
349
-	ctx.HTML(200, FORGOT_PASSWORD)
353
+	ctx.HTML(200, tmplForgotPassword)
350 354
 }

routes/user/setting.go → routers/user/setting.go View File

@@ -2,28 +2,30 @@ package user
2 2
 
3 3
 import (
4 4
 	"dev.sigpipe.me/dashie/myapp/context"
5
-	"dev.sigpipe.me/dashie/myapp/pkg/form"
6 5
 	"dev.sigpipe.me/dashie/myapp/models"
6
+	"dev.sigpipe.me/dashie/myapp/stuff/form"
7 7
 )
8 8
 
9 9
 const (
10
-	SETTINGS_PROFILE = "user/settings/profile"
10
+	tmplSettingsProfile = "user/settings/profile"
11 11
 )
12 12
 
13
+// Settings GET
13 14
 func Settings(ctx *context.Context) {
14 15
 	ctx.Title("settings.title")
15 16
 	ctx.PageIs("SettingsProfile")
16 17
 	ctx.Data["email"] = ctx.User.Email
17
-	ctx.Success(SETTINGS_PROFILE)
18
+	ctx.Success(tmplSettingsProfile)
18 19
 }
19 20
 
21
+// SettingsPost POST
20 22
 func SettingsPost(ctx *context.Context, f form.UpdateSettingsProfile) {
21 23
 	ctx.Title("settings.title")
22 24
 	ctx.PageIs("SettingsProfile")
23 25
 	ctx.Data["origin_name"] = ctx.User.UserName
24 26
 
25 27
 	if ctx.HasError() {
26
-		ctx.Success(SETTINGS_PROFILE)
28
+		ctx.Success(tmplSettingsProfile)
27 29
 		return
28 30
 	}
29 31
 

+ 0
- 166
routes/routes.go View File

@@ -1,166 +0,0 @@
1
-package routes
2
-
3
-import (
4
-	"dev.sigpipe.me/dashie/myapp/context"
5
-	"dev.sigpipe.me/dashie/myapp/models"
6
-	"dev.sigpipe.me/dashie/myapp/pkg/cron"
7
-	"dev.sigpipe.me/dashie/myapp/pkg/form"
8
-	"dev.sigpipe.me/dashie/myapp/pkg/mailer"
9
-	"dev.sigpipe.me/dashie/myapp/pkg/template"
10
-	"dev.sigpipe.me/dashie/myapp/routes/admin"
11
-	"dev.sigpipe.me/dashie/myapp/routes/user"
12
-	"dev.sigpipe.me/dashie/myapp/setting"
13
-	"github.com/go-macaron/binding"
14
-	"github.com/go-macaron/cache"
15
-	"github.com/go-macaron/csrf"
16
-	"github.com/go-macaron/i18n"
17
-	"github.com/go-macaron/sessio