gitea源码

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package settings
  4. import (
  5. "net/http"
  6. "code.gitea.io/gitea/modules/setting"
  7. api "code.gitea.io/gitea/modules/structs"
  8. "code.gitea.io/gitea/services/context"
  9. )
  10. // GetGeneralUISettings returns instance's global settings for ui
  11. func GetGeneralUISettings(ctx *context.APIContext) {
  12. // swagger:operation GET /settings/ui settings getGeneralUISettings
  13. // ---
  14. // summary: Get instance's global settings for ui
  15. // produces:
  16. // - application/json
  17. // responses:
  18. // "200":
  19. // "$ref": "#/responses/GeneralUISettings"
  20. ctx.JSON(http.StatusOK, api.GeneralUISettings{
  21. DefaultTheme: setting.UI.DefaultTheme,
  22. AllowedReactions: setting.UI.Reactions,
  23. CustomEmojis: setting.UI.CustomEmojis,
  24. })
  25. }
  26. // GetGeneralAPISettings returns instance's global settings for api
  27. func GetGeneralAPISettings(ctx *context.APIContext) {
  28. // swagger:operation GET /settings/api settings getGeneralAPISettings
  29. // ---
  30. // summary: Get instance's global settings for api
  31. // produces:
  32. // - application/json
  33. // responses:
  34. // "200":
  35. // "$ref": "#/responses/GeneralAPISettings"
  36. ctx.JSON(http.StatusOK, api.GeneralAPISettings{
  37. MaxResponseItems: setting.API.MaxResponseItems,
  38. DefaultPagingNum: setting.API.DefaultPagingNum,
  39. DefaultGitTreesPerPage: setting.API.DefaultGitTreesPerPage,
  40. DefaultMaxBlobSize: setting.API.DefaultMaxBlobSize,
  41. DefaultMaxResponseSize: setting.API.DefaultMaxResponseSize,
  42. })
  43. }
  44. // GetGeneralRepoSettings returns instance's global settings for repositories
  45. func GetGeneralRepoSettings(ctx *context.APIContext) {
  46. // swagger:operation GET /settings/repository settings getGeneralRepositorySettings
  47. // ---
  48. // summary: Get instance's global settings for repositories
  49. // produces:
  50. // - application/json
  51. // responses:
  52. // "200":
  53. // "$ref": "#/responses/GeneralRepoSettings"
  54. ctx.JSON(http.StatusOK, api.GeneralRepoSettings{
  55. MirrorsDisabled: !setting.Mirror.Enabled,
  56. HTTPGitDisabled: setting.Repository.DisableHTTPGit,
  57. MigrationsDisabled: setting.Repository.DisableMigrations,
  58. StarsDisabled: setting.Repository.DisableStars,
  59. TimeTrackingDisabled: !setting.Service.EnableTimetracking,
  60. LFSDisabled: !setting.LFS.StartServer,
  61. })
  62. }
  63. // GetGeneralAttachmentSettings returns instance's global settings for Attachment
  64. func GetGeneralAttachmentSettings(ctx *context.APIContext) {
  65. // swagger:operation GET /settings/attachment settings getGeneralAttachmentSettings
  66. // ---
  67. // summary: Get instance's global settings for Attachment
  68. // produces:
  69. // - application/json
  70. // responses:
  71. // "200":
  72. // "$ref": "#/responses/GeneralAttachmentSettings"
  73. ctx.JSON(http.StatusOK, api.GeneralAttachmentSettings{
  74. Enabled: setting.Attachment.Enabled,
  75. AllowedTypes: setting.Attachment.AllowedTypes,
  76. MaxFiles: setting.Attachment.MaxFiles,
  77. MaxSize: setting.Attachment.MaxSize,
  78. })
  79. }