Compare commits

...

40 Commits

Author SHA1 Message Date
squeaky otter 324f9e548a
Improve the new file javascript; Still getting that issue 3 years ago
squeaky otter d0f06320f1
Show edit time if edited, add expiry on nice columns 3 years ago
squeaky otter 409ff5f085
Not relatable anymore; update year 3 years ago
squeaky otter b28934a7dd
quack 3 years ago
squeaky otter 3d2a65bb55
Update libgit to 0.27 3 years ago
squeaky otter 48953674c3
Update vendoring 3 years ago
squeaky otter 1f7d029c10
Grmbl 3 years ago
squeaky otter d73871f155
Fmt; Disappeared % format; % format updates; Unkeyed things 3 years ago
squeaky otter 7cd7699de9
Update vendoring 3 years ago
squeaky otter 61a8336d33
Sorry, no SSH planned 3 years ago
squeaky otter 2ddf2c0578
Update TODO 3 years ago
squeaky otter 53061bd495
I don't know 4 years ago
squeaky otter 04cd250964
Add item in todo 4 years ago
squeaky otter 92460f3727
Bump version ...... 4 years ago
squeaky otter 7caf949d0e
oops lol 4 years ago
squeaky otter e3f00561ac
Fix segfault with non existant file 4 years ago
squeaky otter 4a36884451
shrug. 4 years ago
squeaky otter 23e9945d5f
Update TODO 4 years ago
squeaky otter e3640aeb5f
Fix handling of files within a subdirectory 4 years ago
squeaky otter 16819cd115
Done task 4 years ago
squeaky otter 749a506630
Add more error flash messages 4 years ago
squeaky otter 98ee036020
Revert "A flash message before Handle is useless and won't work as expected" 4 years ago
squeaky otter a7c9c3c20f
Some fixes 4 years ago
squeaky otter 7fa519d79b
Fix path behaviour for raw file view 4 years ago
squeaky otter b5b9a482f0
It was more a quick fix 4 years ago
squeaky otter 01ba3aba6d
/ are now stripped from filenames 4 years ago
squeaky otter 03058b0a60
_ are now unstripped from filenames 4 years ago
squeaky otter fd0a8762c8
This have been done too 4 years ago
squeaky otter 8806bc3a4b
Try to force region 4 years ago
squeaky otter b63aaca0be
Better ? 4 years ago
squeaky otter dd29681412
Temporarily desactivate the s3 release 4 years ago
squeaky otter 1c04c1d237
Add blocking issue for git2go 4 years ago
squeaky otter 08de17dd7b
Try to fix libgit2 version 4 years ago
squeaky otter cc93005067
Try to fix libgit2 version 4 years ago
squeaky otter 7bcd817551
Add TODO in repository, can be useful 4 years ago
squeaky otter ea31d6a1fb
A flash message before Handle is useless and won't work as expected 4 years ago
squeaky otter 1b0e8f39c6
Add comment 4 years ago
squeaky otter 78f58622d4
Fix i18n string 4 years ago
squeaky otter 0521a3f3da
Fix typo or->of 4 years ago
squeaky otter 5c19530adb
Add the script I use for debugging i18n 4 years ago
  1. 7
      .drone.yml
  2. 305
      Gopkg.lock
  3. 50
      Gopkg.toml
  4. 55
      Makefile
  5. 6
      README.md
  6. 24
      TODO.org
  7. 2
      cmd/cmd.go
  8. 69
      cmd/web.go
  9. 4
      conf/locale/locale_en-US.ini
  10. 2
      conf/locale/locale_fr-FR.ini
  11. 12
      context/auth.go
  12. 38
      context/context.go
  13. 16
      context/repo.go
  14. 4
      context/user.go
  15. 2
      git.txt.go
  16. 88
      i18n.py
  17. 8
      models/counter.go
  18. 1
      models/error.go
  19. 4
      models/errors/repo.go
  20. 42
      models/gitxt.go
  21. 18
      models/models.go
  22. 2
      models/models_sqlite.go
  23. 22
      models/sshkey.go
  24. 64
      models/user.go
  25. 8
      routers/admin/admin.go
  26. 112
      routers/gitxt/gitxt.go
  27. 2
      routers/hub.go
  28. 26
      routers/repo/archive.go
  29. 48
      routers/repo/repo.go
  30. 21
      routers/user/auth.go
  31. 4
      routers/user/setting.go
  32. 110
      setting/setting.go
  33. 4
      static/css/custom.css
  34. 23
      static/js/GitxtNewPost.js
  35. 2
      stuff/auth/auth.go
  36. 14
      stuff/cron/cron.go
  37. 4
      stuff/form/auth.go
  38. 12
      stuff/form/form.go
  39. 18
      stuff/form/gitxt.go
  40. 2
      stuff/form/user.go
  41. 25
      stuff/gite/gite.go
  42. 2
      stuff/markup/markdown_test.go
  43. 2
      stuff/markup/markup.go
  44. 4
      stuff/repository/repository.go
  45. 15
      stuff/sanitize/sanitize.go
  46. 2
      stuff/sanitize/sanitize_test.go
  47. 4
      stuff/template/highlight/highlight.go
  48. 42
      stuff/template/template.go
  49. 2
      stuff/tool/file_test.go
  50. 14
      stuff/tool/tool.go
  51. 12
      stuff/tool/tool_test.go
  52. 2
      templates/base/footer.tmpl
  53. 6
      templates/base/head.tmpl
  54. 17
      templates/gitxt/edit.tmpl
  55. 16
      templates/gitxt/new.tmpl
  56. 14
      templates/gitxt/view.tmpl
  57. 15
      vendor/cloud.google.com/go/AUTHORS
  58. 40
      vendor/cloud.google.com/go/CONTRIBUTORS
  59. 202
      vendor/cloud.google.com/go/LICENSE
  60. 277
      vendor/cloud.google.com/go/civil/civil.go
  61. 140
      vendor/github.com/Unknwon/com/cmd_test.go
  62. 56
      vendor/github.com/Unknwon/com/convert_test.go
  63. 53
      vendor/github.com/Unknwon/com/dir.go
  64. 56
      vendor/github.com/Unknwon/com/dir_test.go
  65. 299
      vendor/github.com/Unknwon/com/example_test.go
  66. 61
      vendor/github.com/Unknwon/com/file_test.go
  67. 35
      vendor/github.com/Unknwon/com/html_test.go
  68. 111
      vendor/github.com/Unknwon/com/http_test.go
  69. 4
      vendor/github.com/Unknwon/com/math.go
  70. 44
      vendor/github.com/Unknwon/com/math_test.go
  71. 67
      vendor/github.com/Unknwon/com/path_test.go
  72. 70
      vendor/github.com/Unknwon/com/regex_test.go
  73. 99
      vendor/github.com/Unknwon/com/slice_test.go
  74. 153
      vendor/github.com/Unknwon/com/string_test.go
  75. 1
      vendor/github.com/Unknwon/com/testdata/SaveFile.txt
  76. 1
      vendor/github.com/Unknwon/com/testdata/SaveFileS.txt
  77. 0
      vendor/github.com/Unknwon/com/testdata/sample_file.txt
  78. 1
      vendor/github.com/Unknwon/com/testdata/statDir/SaveFile.txt
  79. 1
      vendor/github.com/Unknwon/com/testdata/statDir/SaveFileS.txt
  80. 0
      vendor/github.com/Unknwon/com/testdata/statDir/sample_file.txt
  81. 1
      vendor/github.com/Unknwon/com/testdata/statDir/secondLevel/SaveFile.txt
  82. 1
      vendor/github.com/Unknwon/com/testdata/statDir/secondLevel/SaveFileS.txt
  83. 0
      vendor/github.com/Unknwon/com/testdata/statDir/secondLevel/sample_file.txt
  84. 5
      vendor/github.com/Unknwon/i18n/i18n.go
  85. 64
      vendor/github.com/Unknwon/i18n/i18n_test.go
  86. 6
      vendor/github.com/Unknwon/i18n/testdata/locale_en-US.ini
  87. 86
      vendor/github.com/Unknwon/i18n/ui18n/sync.go
  88. 166
      vendor/github.com/Unknwon/i18n/ui18n/ui18n.go
  89. 324
      vendor/github.com/Unknwon/paginater/paginater_test.go
  90. 965
      vendor/github.com/certifi/gocertifi/certifi.go
  91. 10
      vendor/github.com/certifi/gocertifi/certifi_test.go
  92. 239
      vendor/github.com/denisenkom/go-mssqldb/README.md
  93. 16
      vendor/github.com/denisenkom/go-mssqldb/appveyor.yml
  94. 287
      vendor/github.com/denisenkom/go-mssqldb/batch/batch.go
  95. 12
      vendor/github.com/denisenkom/go-mssqldb/batch/batch_fuzz.go
  96. 120
      vendor/github.com/denisenkom/go-mssqldb/batch/batch_test.go
  97. 111
      vendor/github.com/denisenkom/go-mssqldb/buf.go
  98. 195
      vendor/github.com/denisenkom/go-mssqldb/buf_test.go
  99. 198
      vendor/github.com/denisenkom/go-mssqldb/bulkcopy.go
  100. 27
      vendor/github.com/denisenkom/go-mssqldb/bulkcopy_sql.go

7
.drone.yml

@ -44,6 +44,7 @@ pipeline:
TAGS: sqlite
GOPATH: /srv/app
commands:
- apk update
- apk -U add libmagic file-dev libgit2 libgit2-dev
- make clean
- make build
@ -52,10 +53,11 @@ pipeline:
event: [ push, tag ]
release:
image: plugins/s3:1
image: plugins/s3
pull: true
secrets: [ aws_access_key_id, aws_secret_access_key ]
bucket: drone-git.txt
region: us-east-1
endpoint: https://s3.sigpipe.me
path_style: true
strip_prefix: dist/release/
@ -65,10 +67,11 @@ pipeline:
event: [ tag ]
release:
image: plugins/s3:1
image: plugins/s3
pull: true
secrets: [ aws_access_key_id, aws_secret_access_key ]
bucket: drone-git.txt
region: us-east-1
endpoint: https://s3.sigpipe.me
path_style: true
strip_prefix: dist/release/

305
Gopkg.lock

@ -1,285 +1,448 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
digest = "1:b62a3c5b37db602bf1158e921da1a762315a4c37855fd418a14498aa87a342d5"
name = "cloud.google.com/go"
packages = ["civil"]
pruneopts = "UT"
revision = "28a4bc8c44b3acbcc482cff0cdf7de29a4688b61"
version = "v0.35.1"
[[projects]]
branch = "master"
digest = "1:b67d9fb93495f20c1650448395a35d8c8a05cc1744bdd9986f5bc69d5d114f22"
name = "github.com/Unknwon/com"
packages = ["."]
revision = "7677a1d7c1137cd3dd5ba7a076d0c898a1ef4520"
pruneopts = "UT"
revision = "41959bdd855fb7db467f78865d5f9044507df1cd"
[[projects]]
branch = "master"
digest = "1:bd9a1730dc16cc1f04700999f3d324204e0a1971920e7b2f7989927a7467537e"
name = "github.com/Unknwon/i18n"
packages = ["."]
revision = "8372b908b5876d26cfa46a85fc4851b981dad102"
pruneopts = "UT"
revision = "b64d336589669d317928070e70ba0ae558f16633"
[[projects]]
branch = "master"
digest = "1:4a44e85c894774bc6adde2d64de85a97e9cb30ba7084eece33248c570d461c49"
name = "github.com/Unknwon/paginater"
packages = ["."]
pruneopts = "UT"
revision = "45e5d631308ea359946e761484147982c978d0df"
[[projects]]
digest = "1:fed1f537c2f1269fe475a8556c393fe466641682d73ef8fd0491cd3aa1e47bad"
name = "github.com/certifi/gocertifi"
packages = ["."]
revision = "3fd9e1adb12b72d2f3f82191d49be9b93c69f67c"
version = "2017.07.27"
pruneopts = "UT"
revision = "deb3ae2ef2610fde3330947281941c562861188b"
version = "2018.01.18"
[[projects]]
branch = "master"
digest = "1:cf0505eb7d4704d5ab445353dc64122acf56d13937e20dac5570b995cb21232c"
name = "github.com/denisenkom/go-mssqldb"
packages = ["."]
revision = "c7ee4153c0fc40206bde939f96eefa1f501cbcaa"
packages = [
".",
"internal/cp",
]
pruneopts = "UT"
revision = "df6d76eb92899e4dfe4db66d53b187c89d34be37"
[[projects]]
digest = "1:865079840386857c809b72ce300be7580cb50d3d3129ce11bf9aa6ca2bc1934a"
name = "github.com/fatih/color"
packages = ["."]
revision = "570b54cabe6b8eb0bc2dfce68d964677d63b5260"
version = "v1.5.0"
pruneopts = "UT"
revision = "5b77d2a35fb0ede96d138fc9a99f5c9b6aef11b4"
version = "v1.7.0"
[[projects]]
branch = "master"
digest = "1:d18f6f088d7d8365df47f49dfa24b6ff6701a941118ffda30c589d1bd954074b"
name = "github.com/getsentry/raven-go"
packages = ["."]
revision = "1452f6376ddb15c546b6d7567e1d9518765391b5"
pruneopts = "UT"
revision = "f04e7487e9a6b9d9837d52743fb5f40576c56411"
version = "v0.2.0"
[[projects]]
branch = "master"
digest = "1:2c70cb4f416b5badad7248e6a169047657c9288db3966b15eb1ddf75ca1cf3cd"
name = "github.com/go-macaron/binding"
packages = ["."]
pruneopts = "UT"
revision = "ac54ee249c27dca7e76fad851a4a04b73bd1b183"
[[projects]]
branch = "master"
digest = "1:2e2b2c8b2803b8d62aa8eb58285de5e7039ae603999f70bfe6ffc83a6779aa0c"
name = "github.com/go-macaron/cache"
packages = ["."]
pruneopts = "UT"
revision = "56173531277692bc2925924d51fda1cd0a6b8178"
[[projects]]
branch = "master"
digest = "1:cf7ea39f8fc3684b759962a8bdd630c541870e9be94a6c655437938f19982cb3"
name = "github.com/go-macaron/csrf"
packages = ["."]
revision = "428b7c62d7d0034b048b1cd43ba60d87857f5253"
pruneopts = "UT"
revision = "3751b136073c3ebaf8b5c85b418472a19e61c15f"
[[projects]]
branch = "master"
digest = "1:d405e6f5c6d1e1bc57a771ef5a4554851cee3ef8540ea76a6ddbe24fe0d37ee2"
name = "github.com/go-macaron/i18n"
packages = ["."]
revision = "ef57533c3b0fc2d8581deda14937e52f11a203ab"
pruneopts = "UT"
revision = "56731837a73b0165c93fe7779d0c1669d5a49e36"
[[projects]]
branch = "master"
digest = "1:bdb17865b13e720add16eaa212872b4306c8521f367c7a7ff2c10cef1e7afdb1"
name = "github.com/go-macaron/inject"
packages = ["."]
pruneopts = "UT"
revision = "d8a0b8677191f4380287cfebd08e462217bac7ad"
[[projects]]
branch = "master"
digest = "1:c86c37eebd36c97a761d7f756dbf3c69e9349b095efffa13f5eb54eac505eede"
name = "github.com/go-macaron/session"
packages = ["."]
revision = "b8e286a0dba8f4999042d6b258daf51b31d08938"
pruneopts = "UT"
revision = "0a0a789bf1934e55fde19629869caa015a40c525"
[[projects]]
branch = "master"
digest = "1:ffbec58b40e72acdab27dcba73bf1ecaf9f9a11a21901b74257748023ede3a8b"
name = "github.com/go-macaron/toolbox"
packages = ["."]
revision = "6766b8f16d1b135b250f09ba4dc4e24ab65b1107"
pruneopts = "UT"
revision = "a77f45a7ce909c0ff14b28279fa1a2b674acb70f"
[[projects]]
digest = "1:ec6f9bf5e274c833c911923c9193867f3f18788c461f76f05f62bb1510e0ae65"
name = "github.com/go-sql-driver/mysql"
packages = ["."]
revision = "a0583e0143b1624142adab07e0e97fe106d99561"
version = "v1.3"
pruneopts = "UT"
revision = "72cd26f257d44c1114970e19afddcd812016007e"
version = "v1.4.1"
[[projects]]
branch = "master"
digest = "1:43c0f7d28e1d4359041ef2d2ed2e37f599a6c623b1c59aac0d04da2fda29bbb3"
name = "github.com/go-xorm/builder"
packages = ["."]
revision = "c8871c857d2555fbfbd8524f895be5386d3d8836"
pruneopts = "UT"
revision = "1d658d7596c25394aab557ef5b50ef35bf706384"
version = "v0.3.4"
[[projects]]
digest = "1:ee0b218753df985dd6633b13a894a69f0c1ea385f092f4afa093d407bb165cc5"
name = "github.com/go-xorm/core"
packages = ["."]
revision = "da1adaf7a28ca792961721a34e6e04945200c890"
version = "v0.5.7"
pruneopts = "UT"
revision = "f43c33d9a48db006417a7ac4c16b08897e3e1458"
version = "v0.5.8"
[[projects]]
digest = "1:6ff42d216e382408d6a16831014cd95298fdaaf988adf471289924c591d47603"
name = "github.com/go-xorm/xorm"
packages = ["."]
revision = "d7f04c3cecff8d8c9321b2c39940e1992ce9f01a"
version = "v0.6.3"
pruneopts = "UT"
revision = "fc1b13e0d8e240788213230aa5747eb557f80f41"
version = "v0.6.6"
[[projects]]
branch = "master"
digest = "1:feda45e0c87eb025dac4ad8c9c769dddcd06e161f36e77ce24372956928275e5"
name = "github.com/gogits/cron"
packages = ["."]
revision = "c803a08f3bd6f5d5f0281e5ef6a5e09b28488ed7"
pruneopts = "UT"
revision = "9f6c956d3e147cf00f540e31a13bce128fd2fe2d"
[[projects]]
branch = "master"
digest = "1:f14d1b50e0075fb00177f12a96dd7addf93d1e2883c25befd17285b779549795"
name = "github.com/gopherjs/gopherjs"
packages = ["js"]
revision = "415225646bb92c4449bb484646f2c95a98402f6f"
pruneopts = "UT"
revision = "d547d1d9531ed93dbdebcbff7f83e7c876a1e0ee"
[[projects]]
branch = "master"
digest = "1:8bacc2118e6cc6a207eb144656537ff7ee0397f8bc8c1f7639519b0de2bb949a"
name = "github.com/jaytaylor/html2text"
packages = ["."]
revision = "0ee88d3006305456b84cad14a24b2576f9411965"
pruneopts = "UT"
revision = "57d518f124b0cf46ea2021f25a01396b3522e6fb"
[[projects]]
digest = "1:4b63210654b1f2b664f74ec434a1bb1cb442b3d75742cc064a10808d1cca6361"
name = "github.com/jtolds/gls"
packages = ["."]
revision = "77f18212c9c7edc9bd6a33d383a7b545ce62f064"
version = "v4.2.1"
pruneopts = "UT"
revision = "b4936e06046bbecbb94cae9c18127ebe510a2cb9"
version = "v4.20"
[[projects]]
branch = "master"
digest = "1:8ef506fc2bb9ced9b151dafa592d4046063d744c646c1bbe801982ce87e4bc24"
name = "github.com/lib/pq"
packages = [".","oid"]
revision = "b77235e3890a962fe8a6f8c4c7198679ca7814e7"
packages = [
".",
"oid",
]
pruneopts = "UT"
revision = "4ded0e9383f75c197b3a2aaa6d590ac52df6fd79"
version = "v1.0.0"
[[projects]]
digest = "1:c658e84ad3916da105a761660dcaeb01e63416c8ec7bc62256a9b411a05fcd67"
name = "github.com/mattn/go-colorable"
packages = ["."]
pruneopts = "UT"
revision = "167de6bfdfba052fa6b2d3664c8f5272e23c9072"
version = "v0.0.9"
[[projects]]
digest = "1:0981502f9816113c9c8c4ac301583841855c8cf4da8c72f696b3ebedf6d0e4e5"
name = "github.com/mattn/go-isatty"
packages = ["."]
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
version = "v0.0.3"
pruneopts = "UT"
revision = "6ca4dbf54d38eea1a992b3c722a76a5d1c4cb25c"
version = "v0.0.4"
[[projects]]
digest = "1:0356f3312c9bd1cbeda81505b7fd437501d8e778ab66998ef69f00d7f9b3a0d7"
name = "github.com/mattn/go-runewidth"
packages = ["."]
revision = "9e777a8366cce605130a531d2cd6363d07ad7317"
version = "v0.0.2"
pruneopts = "UT"
revision = "3ee7d812e62a0804a7d0a324e0249ca2db3476d3"
version = "v0.0.4"
[[projects]]
digest = "1:4a49346ca45376a2bba679ca0e83bec949d780d4e927931317904bad482943ec"
name = "github.com/mattn/go-sqlite3"
packages = ["."]
revision = "ca5e3819723d8eeaf170ad510e7da1d6d2e94a08"
version = "v1.2.0"
pruneopts = "UT"
revision = "c7c4067b79cc51e6dfdcef5c702e74b1e0fa7c75"
version = "v1.10.0"
[[projects]]
branch = "master"
digest = "1:6ff1026b8d873d074ddec82ad60bb0eb537dc013f456ef26b63d30beba2f99e7"
name = "github.com/microcosm-cc/bluemonday"
packages = ["."]
revision = "68fecaef60268522d2ac3f0123cec9d3bcab7b6e"
pruneopts = "UT"
revision = "506f3da9b7c86d737e91f16b7431df8635871552"
version = "v1.0.2"
[[projects]]
branch = "master"
digest = "1:abcdbf03ca6ca13d3697e2186edc1f33863bbdac2b3a44dfa39015e8903f7409"
name = "github.com/olekukonko/tablewriter"
packages = ["."]
revision = "a7a4c189eb47ed33ce7b35f2880070a0c82a67d4"
pruneopts = "UT"
revision = "e6d60cf7ba1f42d86d54cdf5508611c4aafb3970"
version = "v0.0.1"
[[projects]]
branch = "master"
digest = "1:cf31692c14422fa27c83a05292eb5cbe0fb2775972e8f1f8446a71549bd8980b"
name = "github.com/pkg/errors"
packages = ["."]
pruneopts = "UT"
revision = "ba968bfe8b2f7e042a574c888954fccecfa385b4"
version = "v0.8.1"
[[projects]]
digest = "1:1090c43442963716e8f440ca37bd9e7804bc656e669662ab30995fad2f8dbd33"
name = "github.com/rakyll/magicmime"
packages = ["."]
pruneopts = "UT"
revision = "9b99294d6b2216897632b9734769d8ce4568681e"
version = "v0.1.0"
[[projects]]
digest = "1:b36a0ede02c4c2aef7df7f91cbbb7bb88a98b5d253509d4f997dda526e50c88c"
name = "github.com/russross/blackfriday"
packages = ["."]
revision = "4048872b16cc0fc2c5fd9eacf0ed2c2fedaa0c8c"
version = "v1.5"
pruneopts = "UT"
revision = "05f3235734ad95d0016f6a23902f06461fcf567a"
version = "v1.5.2"
[[projects]]
digest = "1:cc1c574c9cb5e99b123888c12b828e2d19224ab6c2244bda34647f230bf33243"
name = "github.com/smartystreets/assertions"
packages = [".","internal/go-render/render","internal/oglematchers"]
revision = "ff1918e1e5a13a74014644ae7c1e0ba2f791364d"
version = "1.8.0"
packages = [
".",
"internal/go-render/render",
"internal/oglematchers",
]
pruneopts = "UT"
revision = "7678a5452ebea5b7090a6b163f844c133f523da2"
version = "1.8.3"
[[projects]]
digest = "1:a3e081e593ee8e3b0a9af6a5dcac964c67a40c4f2034b5345b2ad78d05920728"
name = "github.com/smartystreets/goconvey"
packages = ["convey","convey/gotest","convey/reporting"]
packages = [
"convey",
"convey/gotest",
"convey/reporting",
]
pruneopts = "UT"
revision = "9e8dc3f972df6c8fcc0375ef492c24d0bb204857"
version = "1.6.3"
[[projects]]
branch = "master"
digest = "1:362b269942e8508aed33025593090ad4cdbd9077de4b1cd505e6124728e9e856"
name = "github.com/ssor/bom"
packages = ["."]
pruneopts = "UT"
revision = "6386211fdfcf24c0bfbdaceafd02849ed9a8a509"
[[projects]]
digest = "1:b24d38b282bacf9791408a080f606370efa3d364e4b5fd9ba0f7b87786d3b679"
name = "github.com/urfave/cli"
packages = ["."]
pruneopts = "UT"
revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1"
version = "v1.20.0"
[[projects]]
branch = "master"
digest = "1:706aaf5e43c7dc00fe3fe91015cf8ef07e50736356c8acf924a061ccb1845237"
name = "golang.org/x/crypto"
packages = ["md4","pbkdf2"]
revision = "34d0413e1bf9c8d5ccc42391da5c92d16c595f74"
packages = [
"md4",
"pbkdf2",
]
pruneopts = "UT"
revision = "b8fe1690c61389d7d2a8074a507d1d40c5d30448"
[[projects]]
branch = "master"
digest = "1:1235bd185006c1bbdc4292ec1942974469ba1a37ab6bbb73850d75b2bd952efc"
name = "golang.org/x/net"
packages = ["context","html","html/atom"]
revision = "0a9397675ba34b2845f758fe3cd68828369c6517"
packages = [
"html",
"html/atom",
]
pruneopts = "UT"
revision = "d26f9f9a57f3fab6a695bec0d84433c2c50f8bbf"
[[projects]]
branch = "master"
digest = "1:969c44c96e9866e912a16e282a362cf045b64202107424983fe8abc3373d1eab"
name = "golang.org/x/sys"
packages = ["unix"]
revision = "314a259e304ff91bd6985da2a7149bbf91237993"
pruneopts = "UT"
revision = "41f3e6584952bb034a481797859f6ab34b6803bd"
[[projects]]
branch = "master"
digest = "1:17ad89bd57485e11f306d41b703f53089fb0803682707b21fe9b3b29467d37a0"
name = "golang.org/x/text"
packages = ["internal/gen","internal/tag","language","unicode/cldr"]
revision = "1cbadb444a806fd9430d14ad08967ed91da4fa0a"
packages = [
"internal/gen",
"internal/tag",
"language",
"unicode/cldr",
]
pruneopts = "UT"
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
version = "v0.3.0"
[[projects]]
digest = "1:c25289f43ac4a68d88b02245742347c94f1e108c534dda442188015ff80669b3"
name = "google.golang.org/appengine"
packages = ["cloudsql"]
pruneopts = "UT"
revision = "e9657d882bb81064595ca3b56cbe2546bbabf7b1"
version = "v1.4.0"
[[projects]]
branch = "v3"
digest = "1:7388652e2215a3f45d341d58766ed58317971030eb1cbd75f005f96ace8e9196"
name = "gopkg.in/alexcesaro/quotedprintable.v3"
packages = ["."]
pruneopts = "UT"
revision = "2caba252f4dc53eaf6b553000885530023f54623"
[[projects]]
digest = "1:ce0d683e17b7c249c081cf4f5e4a54dce8fedf7e72d2b56aa557ee33abe367f0"
name = "gopkg.in/clog.v1"
packages = ["."]
revision = "8492a6faa632c31ba82f562b53b4a6e5eacf2732"
version = "v1.1.1"
pruneopts = "UT"
revision = "3bc2eaba5fa35df0338549cc1180dc45f6fc2a16"
version = "v1.2.0"
[[projects]]
digest = "1:eebd52aee67d9f1e0af1859a584e14b1817581dd5f90d4585418c27b6a93c966"
name = "gopkg.in/gomail.v2"
packages = ["."]
pruneopts = "UT"
revision = "41f3572897373c5538c50a2402db15db079fa4fd"
version = "2.0.0"
[[projects]]
digest = "1:8b4bb15de2e698d359eeec15c42453567c98972a70c8619946050360ec02ec32"
name = "gopkg.in/ini.v1"
packages = ["."]
revision = "20b96f641a5ea98f2f8619ff4f3e061cff4833bd"
version = "v1.28.2"
[[projects]]
branch = "v24"
name = "gopkg.in/libgit2/git2go.v24"
packages = ["."]
revision = "22091886372e73de5d66168e8665775676ec13c5"
pruneopts = "UT"
revision = "6ed8d5f64cd79a498d1f3fab5880cc376ce41bbe"
version = "v1.41.0"
[[projects]]
branch = "v25"
name = "gopkg.in/libgit2/git2go.v25"
branch = "v27"
digest = "1:6af8f24e29863581ecaa0900389a20c5b7cd13506fb83c317494a4f92253d6d5"
name = "gopkg.in/libgit2/git2go.v27"
packages = ["."]
revision = "334260d743d713a55ff3c097ec6707f2bb39e9d5"
pruneopts = "UT"
revision = "ecaeb7a21d479b7966311760a2e8bd734f8f0eef"
[[projects]]
digest = "1:3d43a1d68f315a1c4c2cd20ee4d35c96695f17637502366341ac43b7813ea95f"
name = "gopkg.in/macaron.v1"
packages = ["."]
revision = "97f995df0bf34ca1a77c00704c9278476275566b"
version = "v1.2.2"
pruneopts = "UT"
revision = "dfcb80ca86e8534962c62812efd93209c7e600e7"
version = "v1.3.2"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "64a282e40d5479506dd2acfe0f5dd762a0369ea392ec692d6fe0f4fc15bb1b90"
input-imports = [
"github.com/Unknwon/com",
"github.com/Unknwon/paginater",
"github.com/denisenkom/go-mssqldb",
"github.com/getsentry/raven-go",
"github.com/go-macaron/binding",
"github.com/go-macaron/cache",
"github.com/go-macaron/csrf",
"github.com/go-macaron/i18n",
"github.com/go-macaron/session",
"github.com/go-macaron/toolbox",
"github.com/go-sql-driver/mysql",
"github.com/go-xorm/core",
"github.com/go-xorm/xorm",
"github.com/gogits/cron",
"github.com/jaytaylor/html2text",
"github.com/lib/pq",
"github.com/mattn/go-sqlite3",
"github.com/microcosm-cc/bluemonday",
"github.com/rakyll/magicmime",
"github.com/russross/blackfriday",
"github.com/smartystreets/goconvey/convey",
"github.com/urfave/cli",
"golang.org/x/crypto/pbkdf2",
"golang.org/x/net/html",
"gopkg.in/clog.v1",
"gopkg.in/gomail.v2",
"gopkg.in/ini.v1",
"gopkg.in/libgit2/git2go.v27",
"gopkg.in/macaron.v1",
]
solver-name = "gps-cdcl"
solver-version = 1

50
Gopkg.toml

@ -1,7 +1,6 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
@ -17,44 +16,58 @@
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
[[constraint]]
branch = "master"
name = "github.com/Unknwon/com"
branch = "master"
[[constraint]]
branch = "master"
name = "github.com/Unknwon/paginater"
[[constraint]]
branch = "master"
name = "github.com/denisenkom/go-mssqldb"
[[constraint]]
name = "github.com/getsentry/raven-go"
version = "0.2.0"
[[constraint]]
branch = "master"
name = "github.com/go-macaron/binding"
[[constraint]]
branch = "master"
name = "github.com/go-macaron/cache"
[[constraint]]
branch = "master"
name = "github.com/go-macaron/csrf"
[[constraint]]
branch = "master"
name = "github.com/go-macaron/i18n"
[[constraint]]
branch = "master"
name = "github.com/go-macaron/session"
[[constraint]]
branch = "master"
name = "github.com/go-macaron/toolbox"
[[constraint]]
name = "github.com/go-sql-driver/mysql"
version = "1.3.0"
version = "1.4.1"
[[constraint]]
name = "github.com/go-xorm/core"
@ -65,24 +78,28 @@
version = "0.6.2"
[[constraint]]
branch = "master"
name = "github.com/gogits/cron"
branch = "master"
[[constraint]]
branch = "master"
name = "github.com/jaytaylor/html2text"
[[constraint]]
name = "github.com/lib/pq"
version = "1.0.0"
[[constraint]]
name = "github.com/mattn/go-sqlite3"
version = "1.2.0"
version = "1.10.0"
[[constraint]]
name = "github.com/microcosm-cc/bluemonday"
version = "1.0.2"
[[constraint]]
name = "github.com/rakyll/magicmime"
version = "0.1.0"
[[constraint]]
name = "github.com/russross/blackfriday"
@ -90,29 +107,40 @@
[[constraint]]
name = "github.com/smartystreets/goconvey"
version = "1.6.2"
version = "1.6.3"
[[constraint]]
name = "github.com/urfave/cli"
version = "1.19.1"
version = "1.20.0"
[[constraint]]
branch = "master"
name = "golang.org/x/crypto"
[[constraint]]
branch = "master"
name = "golang.org/x/net"
[[constraint]]
name = "gopkg.in/clog.v1"
version = "1.2.0"
[[constraint]]
name = "gopkg.in/gomail.v2"
version = "2.0.0"
[[constraint]]
name = "gopkg.in/ini.v1"
version = "1.41.0"
[[constraint]]
name = "gopkg.in/libgit2/git2go.v25"
branch = "v27"
name = "gopkg.in/libgit2/git2go.v27"
[[constraint]]
name = "gopkg.in/macaron.v1"
version = "1.3.2"
[prune]
go-tests = true
unused-packages = true

55
Makefile

@ -16,14 +16,16 @@ BUILD_FLAGS:=-o $(EXECUTABLE) -v
TAGS=sqlite
NOW=$(shell date -u '+%Y%m%d%I%M%S')
GOVET=go vet
GOLINT=golint -set_exit_status
GO ?= go
GOVET=$(GO) vet
GOLINT=golint -set_exit_status
GOFMT ?= gofmt -s
GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go")
PACKAGES ?= $(filter-out dev.sigpipe.me/dashie/git.txt/integrations,$(shell go list ./... | grep -v /vendor/))
PACKAGES_ALL ?= $(shell go list ./... | grep -v /vendor/)
SOURCES ?= $(shell find . -name "*.go" -type f)
XGO_DEPS = "--deps=https://s3.sigpipe.me/tarballs/1-mingw-libgnurx-2.5.1-src.tar.gz https://s3.sigpipe.me/tarballs/2-file-5.32.tar.gz"
#XGO_DEPS += "--deps=https://github.com/libgit2/libgit2/archive/maint/v0.25.zip"
ifneq ($(DRONE_TAG),)
VERSION ?= $(subst v,,$(DRONE_TAG))
@ -35,44 +37,40 @@ else
endif
endif
### Targets
### Targets build and checks
.PHONY: build clean
all: build
check: test
web: build
./$(EXECUTABLE) web
vet:
$(GOVET) git.txt.go
$(GOVET) $(PACKAGES_ALL)
lint:
@hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) get -u github.com/golang/lint/golint; \
fi
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;
for PKG in $(PACKAGES_ALL); do golint -set_exit_status $$PKG || exit 1; done;
build:
$(GO) build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)'
build-dev: govet
$(GO) build $(BUILD_FLAGS) -tags '$(TAGS)'
build-dev: vet
$(GO) build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(TAGS)'
build-dev-race: govet
$(GO) build $(BUILD_FLAGS) -race -tags '$(TAGS)'
build-dev-race: vet
$(GO) build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -race -tags '$(TAGS)'
clean:
clean: clean-mac
$(GO) clean -i ./...
rm -f $(EXECUTABLE)
clean-mac: clean
clean-mac:
find . -name ".DS_Store" -delete
test:
$(GO) test -cover -v $(PACKAGES)
.PHONY: misspell-check
misspell-check:
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
@ -87,8 +85,29 @@ misspell:
fi
misspell -w -i unknwon $(GOFILES)
.PHONY: fmt
fmt:
$(GOFMT) -w $(GOFILES)
.PHONY: fmt-check
fmt-check:
# get all go files and run go fmt on them
@diff=$$($(GOFMT) -d $(GOFILES)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;
### Targets for tests
# Use PACKAGES instead of PACKAGES_ALL because the integrations tests are run separately
test: fmt-check
$(GO) test -cover -v $(PACKAGES)
### Targets for releases
.PHONY: release
release: release-dirs release-windows release-linux release-copy release-check
release: release-dirs release-linux release-copy release-check
.PHONY: release-dirs
release-dirs:

6
README.md

@ -23,21 +23,21 @@ It's a Pastebin where all pastes are backed in is own Git repository.
- Binary or over-size files are excluded from Edit form in Web-UI, preserving them in the commit (they still can be deleted)
# Planned Feature List
- Pull or Push over SSH for user Gitxts
- Display other rich texts
- API for third party tools
- More tests coverage
# Build
Install or build libgit2 0.25.x ONLY. NO Version less than 0.25 (hello Debian Stable) or higher.
Install or build libgit2 0.27.x ONLY.
This might be painful, and you might need to download manually .deb on older systems.
You also needs libmagic
go get -v -insecure -u dev.sigpipe.me/dashie/git.txt
# Release build
- Get last release from https://sigpipe.me/projet:git.txt#binary_releases
- You still need to install libgit2 0.25.x ONLY, and libmagic
- You still need to install libgit2 0.27.x ONLY, and libmagic
# Contact, issues
- Main contact: Dashie: dashie (at) sigpipe (dot) me

24
TODO.org

@ -0,0 +1,24 @@
#+TITLE: git dot txt TODO list
* Ways of improvement
** TODO Merge AssignUser and AssignRepository ?
** TODO blackfriday dependency update to 2.x, breaking changes
** TODO xorm update, breaking changes
*** migrate to gorm ?
** TODO Add line-break option
** TODO Add more checks for <nil> fields wrongly used, like issue with non existant file
** TODO If a binary file, or huge one is added from git, we get weird submit results and can't update from interface
** DONE Non existant file in git for raw file: git_object_lookup_prefix: Assertion `repo && object_out && id' failed.
** DONE Can't add files with filename "/some/thing/foo.bar"
** DONE Investigate the non-working context.Flash when not using a redirect
** DONE Correctly handle filenames with a /, like raw view
** DONE strip '/' from filenames
** DONE _ shouldn't be stripped from filenames
** DONE Creation date on gitxt view
** DONE Count of current gitxt
** DONE Count of total managed gitxt
** DONE Show this on footer and admin

2
cmd/cmd.go

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

69
cmd/web.go

@ -1,42 +1,42 @@
package cmd
import (
"github.com/urfave/cli"
"gopkg.in/macaron.v1"
"dev.sigpipe.me/dashie/git.txt/setting"
"dev.sigpipe.me/dashie/git.txt/context"
"dev.sigpipe.me/dashie/git.txt/stuff/template"
"dev.sigpipe.me/dashie/git.txt/models"
"dev.sigpipe.me/dashie/git.txt/routers"
"dev.sigpipe.me/dashie/git.txt/routers/admin"
"dev.sigpipe.me/dashie/git.txt/routers/gitxt"
"dev.sigpipe.me/dashie/git.txt/routers/repo"
"dev.sigpipe.me/dashie/git.txt/routers/user"
"dev.sigpipe.me/dashie/git.txt/setting"
"dev.sigpipe.me/dashie/git.txt/stuff/cron"
"dev.sigpipe.me/dashie/git.txt/stuff/form"
"path"
"github.com/go-macaron/session"
"github.com/go-macaron/csrf"
"dev.sigpipe.me/dashie/git.txt/stuff/mailer"
"dev.sigpipe.me/dashie/git.txt/stuff/template"
"fmt"
"github.com/go-macaron/binding"
"github.com/go-macaron/cache"
"github.com/go-macaron/csrf"
"github.com/go-macaron/i18n"
"github.com/go-macaron/binding"
"github.com/go-macaron/session"
"github.com/go-macaron/toolbox"
"strings"
"fmt"
"github.com/urfave/cli"
log "gopkg.in/clog.v1"
"net/http"
"gopkg.in/macaron.v1"
"net"
"net/http"
"net/http/fcgi"
"os"
"dev.sigpipe.me/dashie/git.txt/models"
"dev.sigpipe.me/dashie/git.txt/routers/user"
"dev.sigpipe.me/dashie/git.txt/routers/gitxt"
"dev.sigpipe.me/dashie/git.txt/routers/repo"
"dev.sigpipe.me/dashie/git.txt/stuff/cron"
"dev.sigpipe.me/dashie/git.txt/routers"
"dev.sigpipe.me/dashie/git.txt/routers/admin"
"dev.sigpipe.me/dashie/git.txt/stuff/mailer"
"path"
"strings"
)
// Web command
var Web = cli.Command{
Name: "web",
Usage: "Start web server",
Name: "web",
Usage: "Start web server",
Description: "It starts a web server, great no ?",
Action: runWeb,
Action: runWeb,
Flags: []cli.Flag{
stringFlag("port, p", "3000", "Server port"),
stringFlag("config, c", "config/app.ini", "Custom config file path"),
@ -64,19 +64,19 @@ func newMacaron() *macaron.Macaron {
funcMap := template.NewFuncMap()
m.Use(macaron.Renderer(macaron.RenderOptions{
Directory: path.Join(setting.StaticRootPath, "templates"),
Funcs: funcMap,
IndentJSON: macaron.Env != macaron.PROD,
Directory: path.Join(setting.StaticRootPath, "templates"),
Funcs: funcMap,
IndentJSON: macaron.Env != macaron.PROD,
}))
mailer.InitMailRender(path.Join(setting.StaticRootPath, "templates/mail"), funcMap)
m.Use(i18n.I18n(i18n.Options{
SubURL: setting.AppSubURL,
SubURL: setting.AppSubURL,
//Files: localFiles,
Langs: setting.Langs,
Names: setting.Names,
DefaultLang: "en-US",
Redirect: true,
Langs: setting.Langs,
Names: setting.Names,
DefaultLang: "en-US",
Redirect: true,
}))
m.Use(cache.Cacher(cache.Options{
@ -97,7 +97,7 @@ func newMacaron() *macaron.Macaron {
m.Use(toolbox.Toolboxer(m, toolbox.Options{
HealthCheckFuncs: []*toolbox.HealthCheckFuncDesc{
&toolbox.HealthCheckFuncDesc{
{
Desc: "Database connection",
Func: models.Ping,
},
@ -116,6 +116,7 @@ func runWeb(ctx *cli.Context) error {
}
setting.InitConfig()
//markup.NewSanitizer() // IDK what I wanted to do here
models.InitDb()
cron.NewContext()
mailer.NewContext()
@ -181,7 +182,7 @@ func runWeb(ctx *cli.Context) error {
m.Get("/edit", context.AssignUser(), context.AssignRepository(), context.CheckRepoExpiry(), gitxt.Edit, reqSignIn)
m.Post("/edit", csrf.Validate, context.AssignUser(), context.AssignRepository(), context.CheckRepoExpiry(), bindIgnErr(form.GitxtEdit{}), gitxt.EditPost, reqSignIn)
m.Get("/archive/*", context.AssignUser(), context.AssignRepository(), context.CheckRepoExpiry(), repo.DownloadArchive)
m.Get("/raw/:path", context.AssignUser(), context.AssignRepository(), context.CheckRepoExpiry(), gitxt.RawFile)
m.Get("/raw/*", context.AssignUser(), context.AssignRepository(), context.CheckRepoExpiry(), gitxt.RawFile)
})
m.Group("/:hash([\\d\\w-_\\.]+\\.git$)", func() {
m.Get("", context.AssignUser(), context.AssignRepository(), context.CheckRepoExpiry(), gitxt.View)
@ -232,7 +233,7 @@ func runWeb(ctx *cli.Context) error {
os.Remove(listenAddr)
var listener *net.UnixListener
listener, err = net.ListenUnix("unix", &net.UnixAddr{listenAddr, "unix"})
listener, err = net.ListenUnix("unix", &net.UnixAddr{Name: listenAddr, Net: "unix"})
if err != nil {
break // Handle error after switch
}
@ -252,4 +253,4 @@ func runWeb(ctx *cli.Context) error {
}
return nil
}
}

4
conf/locale/locale_en-US.ini

@ -93,14 +93,16 @@ show_uploads_for = "Show uploads for %s"
show_all_uploads = "Show all uploads"
edit = "Edit"
delete = "Delete"
expiry_on = "Expiry on:"
expiry_on = "Expires on:"
created_on = "Created on:"
updated_on = "Updated on:"
raw_file = "raw file"
file_too_big = "File is too big and can't be displayed."
over_page_size = "Page size limit exceeded and file won't me displayed."
load_image = "Load image"
load_pdf = "Load PDF Viewer"
is_binary = "Can't display binary files."
file_not_found = "File not found"
[gitxt_list]
title = "List of git.txts"

2
conf/locale/locale_fr-FR.ini

@ -95,12 +95,14 @@ edit = "Editer"
delete = "Supprimer"
expiry_on = "Expire le:"
created_on = "Crée le:"
updated_on = "Mis-à-jour le:"
raw_file = "fichier brut"
file_too_big = "Le fichier trop gros et ne peut être affiché."
over_page_size = "Limite de taille pour la page atteinte et le fichier ne sera pas affiché."
load_image = "Charger image"
load_pdf = "Charger le lecteur de PDF"
is_binary = "Impossible d'afficher les fichiers binaires."
file_not_found = "Fichier non trouvé"
[gitxt_list]
title = "Liste des git.txts"

12
context/auth.go

@ -1,11 +1,11 @@
package context
import (
"gopkg.in/macaron.v1"
"dev.sigpipe.me/dashie/git.txt/setting"
"github.com/go-macaron/csrf"
"net/url"
log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1"
"net/url"
)
// ToggleOptions struct
@ -26,7 +26,7 @@ func Toggle(options *ToggleOptions) macaron.Handler {
return
}
log.Trace("SignOutRequired: %s, DisableCSRF: %s, Req Method: %s", options.SignOutRequired, options.DisableCSRF, ctx.Req.Method)
log.Trace("SignOutRequired: %t, DisableCSRF: %t, Req Method: %s", options.SignOutRequired, options.DisableCSRF, ctx.Req.Method)
if !options.SignOutRequired && !options.DisableCSRF && ctx.Req.Method == "POST" {
log.Trace("Validating CSRF")
csrf.Validate(ctx.Context, ctx.csrf)
@ -37,7 +37,7 @@ func Toggle(options *ToggleOptions) macaron.Handler {
if options.SignInRequired {
if !ctx.IsLogged {
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL + ctx.Req.RequestURI), 0, setting.AppSubURL)
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL+ctx.Req.RequestURI), 0, setting.AppSubURL)
ctx.Redirect(setting.AppSubURL + "/user/login")
return
} else if !ctx.User.IsActive {
@ -49,7 +49,7 @@ func Toggle(options *ToggleOptions) macaron.Handler {
// Redirect to login page if auto-sign provided and not signed in
if !options.SignOutRequired && !ctx.IsLogged && len(ctx.GetCookie(setting.CookieUserName)) > 0 {
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL + ctx.Req.RequestURI), 0, setting.AppSubURL)
ctx.SetCookie("redirect_to", url.QueryEscape(setting.AppSubURL+ctx.Req.RequestURI), 0, setting.AppSubURL)
ctx.Redirect(setting.AppSubURL + "/user/login")
return
}
@ -62,4 +62,4 @@ func Toggle(options *ToggleOptions) macaron.Handler {
ctx.Data["PageIsAdmin"] = true
}
}
}
}

38
context/context.go

@ -1,22 +1,22 @@
package context
import (
"gopkg.in/macaron.v1"
"dev.sigpipe.me/dashie/git.txt/models"
"dev.sigpipe.me/dashie/git.txt/setting"
"dev.sigpipe.me/dashie/git.txt/stuff/auth"
"dev.sigpipe.me/dashie/git.txt/stuff/form"
"fmt"
"github.com/go-macaron/cache"
"github.com/go-macaron/csrf"
"github.com/go-macaron/i18n"
"github.com/go-macaron/session"
"github.com/go-macaron/cache"
log "gopkg.in/clog.v1"
"net/http"
"dev.sigpipe.me/dashie/git.txt/setting"
"fmt"
"gopkg.in/macaron.v1"
"html/template"
"io"
"time"
"net/http"
"strings"
"github.com/go-macaron/i18n"
"html/template"
"dev.sigpipe.me/dashie/git.txt/models"
"dev.sigpipe.me/dashie/git.txt/stuff/form"
"dev.sigpipe.me/dashie/git.txt/stuff/auth"
"time"
)
// Context represents context of a request.
@ -27,13 +27,13 @@ type Context struct {
Flash *session.Flash
Session session.Store
User *models.User // logged in user
Gitxt *Gitxt
User *models.User // logged in user
Gitxt *Gitxt
RepoOwnerUsername string
RepoOwnerUsername string
IsLogged bool
IsBasicAuth bool
IsLogged bool
IsBasicAuth bool
}
// Title sets "Title" field in template data.
@ -89,7 +89,7 @@ func (c *Context) Handle(status int, title string, err error) {
case http.StatusNotFound:
c.Data["Title"] = c.Tr("error.page_not_found")
case http.StatusInternalServerError:
c.Data["Title"] = c.Tr("internal_server_error")
c.Data["Title"] = c.Tr("error.internal_server_error")
log.Error(2, "%s: %v", title, err)
}
c.HTML(status, fmt.Sprintf("status/%d", status))
@ -172,7 +172,7 @@ func Contexter() macaron.Handler {
csrf: x,
Flash: f,
Session: sess,
Gitxt: &Gitxt{},
Gitxt: &Gitxt{},
}
if len(setting.HTTP.AccessControlAllowOrigin) > 0 {
@ -211,4 +211,4 @@ func Contexter() macaron.Handler {
c.Map(ctx)
}
}
}

16
context/repo.go

@ -1,21 +1,21 @@
package context
import (
"gopkg.in/macaron.v1"
"dev.sigpipe.me/dashie/git.txt/models"
"dev.sigpipe.me/dashie/git.txt/models/errors"
"strings"
"dev.sigpipe.me/dashie/git.txt/setting"
"time"
log "gopkg.in/clog.v1"
"gopkg.in/macaron.v1"
"strings"
"time"
)
// Gitxt struct
type Gitxt struct {
User *models.User
Gitxt *models.Gitxt
Owner bool // Gitxt.Owner: "toto/repos" does "repos" belongs to "toto" ?
UserName string
User *models.User
Gitxt *models.Gitxt
Owner bool // Gitxt.Owner: "toto/repos" does "repos" belongs to "toto" ?
UserName string
}
// AssignRepository to context
@ -64,4 +64,4 @@ func CheckRepoExpiry() macaron.Handler {
return
}
}
}
}

4
context/user.go

@ -1,9 +1,9 @@
package context
import (
"gopkg.in/macaron.v1"
"dev.sigpipe.me/dashie/git.txt/models"
"dev.sigpipe.me/dashie/git.txt/models/errors"
"gopkg.in/macaron.v1"
)
// AssignUser to context
@ -31,4 +31,4 @@ func AssignUser() macaron.Handler {
ctx.Gitxt.User = user
ctx.RepoOwnerUsername = userName
}
}
}

2
git.txt.go

@ -9,7 +9,7 @@ import (
"os"
)
const appVersion = "0.4.2"
const appVersion = "0.5.2"
func init() {
setting.AppVer = appVersion

88
i18n.py

@ -0,0 +1,88 @@
#!/usr/bin/env python
import re
import configparser
import pprint
import os
# START OF CONFIG
"""
Examples for each regexp match:
1.
2.
"""
RES = {
".tmpl": re.compile(r"{{\s*\.i18n\.Tr\s+\"(\w*)\.([a-zA-Z_-]*)\"\s*}}"),
".go": re.compile(r"ctx\.Tr\(\"(\w*)\.(.*)\"")
}
INI_PARSE = [
"conf/locale/locale_en-US.ini",
"conf/locale/locale_fr-FR.ini",
]
DIRS_SEARCH = [
"cmd",
"models",
"routers",
"setting",
"stuff",
"templates",
]
EXT_ALLOWED = [".go", ".tmpl"]
# END OF CONFIG
# Global variables
"""
[{filename, obj},]
"""
ini_parsed = []
"""
[{ini, filename, section, option, kind},]
"""
unknown = []
# 1. Parse ini file
print("== Parsing {num} INI local files".format(num=len(INI_PARSE)))
for i in INI_PARSE:
a = configparser.ConfigParser()
a.read(i)
ini_parsed.append({'filename': i, 'obj': a})
print("= {filename}".format(filename=i))
print("")
def compare_inis(match, fname):
for i in ini_parsed:
try:
kv = i['obj'].get(match[0], match[1])
except configparser.NoOptionError:
unknown.append({'ini': i['filename'], 'filename': fname, 'section': match[0], 'option': match[1], 'kind': 'option'})
except configparser.NoSectionError:
unknown.append({'ini': i['filename'], 'filename': fname, 'section': match[0], 'option': match[1], 'kind': 'section'})
def parse_file(path, fname, ext):
filename = os.path.join(path, fname)
print("= Parsing {filename}".format(filename=filename))
with open(filename, 'r') as f:
for line in f:
match = RES[ext].findall(line)
if match and len(match) >= 1:
for m in match:
compare_inis(m, filename)
# 2. Parse each dirs - walking sub
for directory in DIRS_SEARCH:
for root, dirs, files in os.walk(directory):
for fname in files:
ext = os.path.splitext(fname)[1]
if ext in EXT_ALLOWED:
parse_file(root, fname, ext)
# 3. Show non-matched
print("")
if len(unknown) <= 0:
print("= No unmatched i18n strings detected")
else:
print("= Unmatched strings:")
for u in unknown:
print("From file '{filename}' with ini locale '{ini}', missing [{section}] {option}".format(filename=u['filename'], ini=u['ini'], section=u['section'], option=u['option']))

8
models/counter.go

@ -6,9 +6,9 @@ import (
// Counter struct
type Counter struct {
ID int64 `xorm:"pk autoincr"`
Name string `xorm:"UNIQUE NOT NULL"`
Count int64
ID int64 `xorm:"pk autoincr"`
Name string `xorm:"UNIQUE NOT NULL"`
Count int64
}
// Don't change them !
@ -111,4 +111,4 @@ func updateCounterGitxtsManaged(e Engine, count int64) error {
// UpdateCounterGitxtsManaged with count
func UpdateCounterGitxtsManaged(c int64) error {
return updateCounterGitxtsManaged(x, c)
}
}

1
models/error.go

@ -239,7 +239,6 @@ func (err ErrDeployKeyNameAlreadyUsed) Error() string {
return fmt.Sprintf("public key already exists [repo_id: %d, name: %s]", err.RepoID, err.Name)
}
// ErrHashAlreadyExist struct
type ErrHashAlreadyExist struct {
Hash string

4
models/errors/repo.go

@ -5,7 +5,7 @@ import "fmt"
// RepoNotExist struct
type RepoNotExist struct {
ID int64
UserID int64
UserID int64
Name string
}
@ -18,4 +18,4 @@ func IsRepoNotExist(err error) bool {
// Error func
func (err RepoNotExist) Error() string {
return fmt.Sprintf("repository does not exist [id: %d, user_id: %d, name: %s]", err.ID, err.UserID, err.Name)
}
}

42
models/gitxt.go

@ -1,41 +1,41 @@
package models
import (
"time"
"dev.sigpipe.me/dashie/git.txt/models/errors"
"github.com/go-xorm/xorm"
"fmt"
"os"
"dev.sigpipe.me/dashie/git.txt/setting"
"dev.sigpipe.me/dashie/git.txt/stuff/repository"
"dev.sigpipe.me/dashie/git.txt/stuff/sync"
"dev.sigpipe.me/dashie/git.txt/setting"
"fmt"
"github.com/Unknwon/com"
"github.com/go-xorm/xorm"
log "gopkg.in/clog.v1"