You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

setting.go 53 kB

11 years ago
11 years ago
11 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
11 years ago
11 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
Pull request review/approval and comment on code (#3748) * Initial ui components for pull request review * Add Review Add IssueComment types Signed-off-by: Jonas Franz <info@jonasfranz.software> (cherry picked from commit 2b4daab) Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace ReviewComment with Content Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add load functions Add ReviewID to findComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add create review comment implementation Add migration for review Other small changes Signed-off-by: Jonas Franz <info@jonasfranz.software> * Simplified create and find functions for review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved "Pending" to first position Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add GetCurrentReview to simplify fetching current review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Preview for listing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Move new comment form to its own file Signed-off-by: Jonas Franz <info@jonasfranz.software> * Implement Review form Show Review comments on comment stream Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for single comments Showing buttons in context Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add pending tag to pending review comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add unit tests for Review Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fetch all review ids at once Add unit tests Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improved comment rendering in "Files" view by adding Comments to DiffLine Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for invalidating comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Switched back to code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Moved review migration from v64 to v65 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Rebuild css Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Improve translations Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix unit tests by updating fixtures and updating outdated test Signed-off-by: Jonas Franz <info@jonasfranz.software> * Comments will be shown at the right place now Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for deleting CodeComments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems caused by files in subdirectories Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for showing code comments of reviews in conversation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for "Show/Hide outdated" Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update code.gitea.io/git Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add support for new webhooks Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update comparison Signed-off-by: Jonas Franz <info@jonasfranz.software> * Resolve conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Minor UI improvements * update code.gitea.io/git * Fix ui bug reported by @lunny causing wrong position of add button Add functionality to "Cancel" button Add scale effects to add button Hide "Cancel" button for existing comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Prepare solving conflicts Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show add button only if no comments already exist for the line Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add missing vendor files Signed-off-by: Jonas Franz <info@jonasfranz.software> * Check if reviewer is nil Signed-off-by: Jonas Franz <info@jonasfranz.software> * Show forms only to users who are logged in Signed-off-by: Jonas Franz <info@jonasfranz.software> * Revert "Show forms only to users who are logged in" This reverts commit c083682 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Save patch in comment Render patch for code comments Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add link to comment in code Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add reply form to comment list Show forms only to signed in users Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add 'Reply' as translatable Add CODE_COMMENT_LINES setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * gofmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix problems introduced by checking for singed in user Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add v70 Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update generated stylesheet Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix preview Beginn with new review comment patch system Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add new algo to generate diff for line range Remove old algo used for cutting big diffs (it was very buggy) * Add documentation and example for CutDiffAroundLine * Fix example of CutDiffAroundLine * Fix some comment UI rendering bugs * Add code comment edit mode * Send notifications / actions to users until review gets published Fix diff generation bug Fix wrong hashtag * Fix vet errors * Send notifications also for single comments * Fix some notification bugs, fix link * Fix: add comment icon is only shown on code lines * Add lint comment * Add unit tests for git diff * Add more error messages * Regenerated css Signed-off-by: Jonas Franz <info@jonasfranz.software> * fmt Signed-off-by: Jonas Franz <info@jonasfranz.software> * Regenerated CSS with latest less version Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix test by updating comment type to new ID Signed-off-by: Jonas Franz <info@jonasfranz.software> * Introducing CodeComments as type for map[string]map[int64][]*Comment Other minor code improvements Signed-off-by: Jonas Franz <info@jonasfranz.software> * Fix data-tab issues Signed-off-by: Jonas Franz <info@jonasfranz.software> * Remove unnecessary change Signed-off-by: Jonas Franz <info@jonasfranz.software> * refactored checkForInvalidation Signed-off-by: Jonas Franz <info@jonasfranz.software> * Append comments instead of setting Signed-off-by: Jonas Franz <info@jonasfranz.software> * Use HeadRepo instead of BaseRepo Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update migration Signed-off-by: Jonas Franz <info@jonasfranz.de> * Regenerated CSS Signed-off-by: Jonas Franz <info@jonasfranz.software> * Add copyright Signed-off-by: Jonas Franz <info@jonasfranz.software> * Update index.css Signed-off-by: Jonas Franz <info@jonasfranz.software>
7 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
10 years ago
11 years ago
11 years ago
11 years ago
10 years ago
11 years ago
11 years ago
10 years ago
10 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
Git LFS support v2 (#122) * Import github.com/git-lfs/lfs-test-server as lfs module base Imported commit is 3968aac269a77b73924649b9412ae03f7ccd3198 Removed: Dockerfile CONTRIBUTING.md mgmt* script/ vendor/ kvlogger.go .dockerignore .gitignore README.md * Remove config, add JWT support from github.com/mgit-at/lfs-test-server Imported commit f0cdcc5a01599c5a955dc1bbf683bb4acecdba83 * Add LFS settings * Add LFS meta object model * Add LFS routes and initialization * Import github.com/dgrijalva/jwt-go into vendor/ * Adapt LFS module: handlers, routing, meta store * Move LFS routes to /user/repo/info/lfs/* * Add request header checks to LFS BatchHandler / PostHandler * Implement LFS basic authentication * Rework JWT secret generation / load * Implement LFS SSH token authentication with JWT Specification: https://github.com/github/git-lfs/tree/master/docs/api * Integrate LFS settings into install process * Remove LFS objects when repository is deleted Only removes objects from content store when deleted repo is the only referencing repository * Make LFS module stateless Fixes bug where LFS would not work after installation without restarting Gitea * Change 500 'Internal Server Error' to 400 'Bad Request' * Change sql query to xorm call * Remove unneeded type from LFS module * Change internal imports to code.gitea.io/gitea/ * Add Gitea authors copyright * Change basic auth realm to "gitea-lfs" * Add unique indexes to LFS model * Use xorm count function in LFS check on repository delete * Return io.ReadCloser from content store and close after usage * Add LFS info to runWeb() * Export LFS content store base path * LFS file download from UI * Work around git-lfs client issue with unauthenticated requests Returning a dummy Authorization header for unauthenticated requests lets git-lfs client skip asking for auth credentials See: https://github.com/github/git-lfs/issues/1088 * Fix unauthenticated UI downloads from public repositories * Authentication check order, Finish LFS file view logic * Ignore LFS hooks if installed for current OS user Fixes Gitea UI actions for repositories tracking LFS files. Checks for minimum needed git version by parsing the semantic version string. * Hide LFS metafile diff from commit view, marking as binary * Show LFS notice if file in commit view is tracked * Add notbefore/nbf JWT claim * Correct lint suggestions - comments for structs and functions - Add comments to LFS model - Function comment for GetRandomBytesAsBase64 - LFS server function comments and lint variable suggestion * Move secret generation code out of conditional Ensures no LFS code may run with an empty secret * Do not hand out JWT tokens if LFS server support is disabled
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
Squashed commit of the following: commit 0afcb843d7ffd596991c4885cab768273a6eb42c Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 17:13:29 2016 -0600 Removed Upload stats as the upload table is just a temporary table commit 7ecd73ff5535612d79d471409173ee7f1fcfa157 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:42:41 2016 -0600 Fix for CodeMirror mode commit c29b9ab531e2e7af0fb5db24dc17e51027dd1174 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 08:03:33 2016 -0600 Made tabbing in editor use spaces commit 23af384c53206a8a40e11e45bf49d7a149c4adcd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:56:46 2016 -0600 Fix for data-url commit cfb8a97591cb6fc0a92e49563b7b764c524db0e9 Merge: 7fc8a89 991ce42 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:42:53 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit 7fc8a89cb495478225b02d613e647f99a1489634 Merge: fd3d86c c03d040 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:40:00 2016 -0600 Merge branch 'feature-create-and-edit-repo-file' of github.com:richmahn/gogs into feature-create-and-edit-repo-file commit fd3d86ca6bbc02cfda566a504ffd6b03db4f75ef Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Sun Jul 31 07:39:44 2016 -0600 Code cleanup commit c03d0401c1049eeeccc32ab1f9c3303c130be5ee Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 29 15:38:23 2016 -0600 Code cleanup commit 98e1206ccf9f9a4503c020e3a7830cf9f861dfae Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:36:01 2016 -0600 Code cleanup and fixes commit c2895dc742f25f8412879c9fa15e18f27f42f194 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 18:24:04 2016 -0600 Fixes per Unknwon's requests commit 6aa7e46b21ad4c96e562daa2eac26a8fb408f8ef Merge: 889e9fa ad7ea88 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Thu Jul 28 17:13:43 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go modules/setting/setting.go commit 889e9faf1bd8559a4979c8f46005d488c1a234d4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:09:18 2016 -0600 Fix in gogs.js commit 47603edf223f147b114be65f3bd27bc1e88827a5 Merge: bb57912 cf85e9e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:07:36 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go public/js/gogs.js commit bb5791255867a71c11a77b639db050ad09c597a4 Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 22 14:02:18 2016 -0600 Update for using CodeMirror mode addon commit d10d128c51039be19e2af9c66c63db66a9f2ec6d Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 16:12:57 2016 -0600 Update for Edit commit 34a34982025144e3225e389f7849eb6273c1d576 Merge: fa1b752 1c7dcdd Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Tue Jul 19 11:52:02 2016 -0600 Merge remote-tracking branch 'gogits/develop' into feature-create-and-edit-repo-file Conflicts: modules/bindata/bindata.go commit fa1b752be29cd455c5184ddac2ffe80b3489763e Author: Richard Mahn <richard_mahn@wycliffeassociates.org> Date: Fri Jul 15 18:35:42 2016 -0600 Feature for editing, creating, uploading and deleting files
9 years ago
11 years ago
11 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
9 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
9 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
9 years ago
Add support for federated avatars (#3320) * Add support for federated avatars Fixes #3105 Removes avatar fetching duplication code Adds an "Enable Federated Avatar" checkbox in user settings (defaults to unchecked) Moves avatar settings all in the same form, making local and remote avatars mutually exclusive Renames UploadAvatarForm to AvatarForm as it's not anymore only for uploading * Run gofmt on all modified files * Move Avatar form in its own page * Add go-libravatar dependency to vendor/ dir Hopefully helps with accepting the contribution. See also #3214 * Revert "Add go-libravatar dependency to vendor/ dir" This reverts commit a8cb93ae640bbb90f7d25012fc257bda9fae9b82. * Make federated avatar setting a global configuration Removes the per-user setting * Move avatar handling back to base tool, disable federated avatar in offline mode * Format, handle error * Properly set fallback host * Use unsupported github.com mirror for importing go-libravatar * Remove comment showing life exists outside of github.com ... pity, but contribution would not be accepted otherwise * Use Combo for Get and Post methods over /avatar * FEDERATED_AVATAR -> ENABLE_FEDERATED_AVATAR * Fix persistance of federated avatar lookup checkbox at install time * Federated Avatars -> Enable Federated Avatars * Use len(string) == 0 instead of string == "" * Move import line where it belong See https://github.com/Unknwon/go-code-convention/blob/master/en-US/import_packages.md Pity the import url is still the unofficial one, but oh well... * Save a line (and waste much more expensive time) * Remove redundant parens * Remove an empty line * Remove empty lines * Reorder lines to make diff smaller * Remove another newline Unknwon review got me start a fight against newlines * Move DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR after OFFLINE_MODE On re-reading the diff I figured what Unknwon meant here: https://github.com/gogits/gogs/pull/3320/files#r73741106 * Remove newlines that weren't there before my intervention
9 years ago
11 years ago
11 years ago
11 years ago
11 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
11 years ago
11 years ago
Feature: Timetracking (#2211) * Added comment's hashtag to url for mail notifications. * Added explanation to return statement + documentation. * Replacing in-line link generation with HTMLURL. (+gofmt) * Replaced action-based model with nil-based model. (+gofmt) * Replaced mailIssueActionToParticipants with mailIssueCommentToParticipants. * Updating comment for mailIssueCommentToParticipants * Added link to comment in "Dashboard" * Deleting feed entry if a comment is going to be deleted * Added migration * Added improved migration to add a CommentID column to action. * Added improved links to comments in feed entries. * Fixes #1956 by filtering for deleted comments that are referenced in actions. * Introducing "IsDeleted" column to action. * Adding design draft (not functional) * Adding database models for stopwatches and trackedtimes * See go-gitea/gitea#967 * Adding design draft (not functional) * Adding translations and improving design * Implementing stopwatch (for timetracking) * Make UI functional * Add hints in timeline for time tracking events * Implementing timetracking feature * Adding "Add time manual" option * Improved stopwatch * Created report of total spent time by user * Only showing total time spent if theire is something to show. * Adding license headers. * Improved error handling for "Add Time Manual" * Adding @sapks 's changes, refactoring * Adding API for feature tracking * Adding unit test * Adding DISABLE/ENABLE option to Repository settings page * Improving translations * Applying @sapk 's changes * Removing repo_unit and using IssuesSetting for disabling/enabling timetracker * Adding DEFAULT_ENABLE_TIMETRACKER to config, installation and admin menu * Improving documentation * Fixing vendor/ folder * Changing timtracking routes by adding subgroups /times and /times/stopwatch (Proposed by @lafriks ) * Restricting write access to timetracking based on the repo settings (Proposed by @lafriks ) * Fixed minor permissions bug. * Adding CanUseTimetracker and IsTimetrackerEnabled in ctx.Repo * Allow assignees and authors to track there time too. * Fixed some build-time-errors + logical errors. * Removing unused Get...ByID functions * Moving IsTimetrackerEnabled from context.Repository to models.Repository * Adding a seperate file for issue related repo functions * Adding license headers * Fixed GetUserByParams return 404 * Moving /users/:username/times to /repos/:username/:reponame/times/:username for security reasons * Adding /repos/:username/times to get all tracked times of the repo * Updating sdk-dependency * Updating swagger.v1.json * Adding warning if user has already a running stopwatch (auto-timetracker) * Replacing GetTrackedTimesBy... with GetTrackedTimes(options FindTrackedTimesOptions) * Changing code.gitea.io/sdk back to code.gitea.io/sdk * Correcting spelling mistake * Updating vendor.json * Changing GET stopwatch/toggle to POST stopwatch/toggle * Changing GET stopwatch/cancel to POST stopwatch/cancel * Added migration for stopwatches/timetracking * Fixed some access bugs for read-only users * Added default allow only contributors to track time value to config * Fixed migration by chaging x.Iterate to x.Find * Resorted imports * Moved Add Time Manually form to repo_form.go * Removed "Seconds" field from Add Time Manually * Resorted imports * Improved permission checking * Fixed some bugs * Added integration test * gofmt * Adding integration test by @lafriks * Added created_unix to comment fixtures * Using last event instead of a fixed event * Adding another integration test by @lafriks * Fixing bug Timetracker enabled causing error 500 at sidebar.tpl * Fixed a refactoring bug that resulted in hiding "HasUserStopwatch" warning. * Returning TrackedTime instead of AddTimeOption at AddTime. * Updating SDK from go-gitea/go-sdk#69 * Resetting Go-SDK back to default repository * Fixing test-vendor by changing ini back to original repository * Adding "tags" to swagger spec * govendor sync * Removed duplicate * Formatting templates * Adding IsTimetrackingEnabled checks to API * Improving translations / english texts * Improving documentation * Updating swagger spec * Fixing integration test caused be translation-changes * Removed encoding issues in local_en-US.ini. * "Added" copyright line * Moved unit.IssuesConfig().EnableTimetracker into a != nil check * Removed some other encoding issues in local_en-US.ini * Improved javascript by checking if data-context exists * Replaced manual comment creation with CreateComment * Removed unnecessary code * Improved error checking * Small cosmetic changes * Replaced int>string>duration parsing with int>duration parsing * Fixed encoding issues * Removed unused imports Signed-off-by: Jonas Franz <info@jonasfranz.software>
8 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Copyright 2017 The Gitea Authors. All rights reserved.
  3. // Use of this source code is governed by a MIT-style
  4. // license that can be found in the LICENSE file.
  5. package setting
  6. import (
  7. "encoding/base64"
  8. "fmt"
  9. "net"
  10. "net/mail"
  11. "net/url"
  12. "os"
  13. "os/exec"
  14. "path"
  15. "path/filepath"
  16. "regexp"
  17. "runtime"
  18. "strconv"
  19. "strings"
  20. "time"
  21. "code.gitea.io/git"
  22. "code.gitea.io/gitea/modules/generate"
  23. "code.gitea.io/gitea/modules/log"
  24. _ "code.gitea.io/gitea/modules/minwinsvc" // import minwinsvc for windows services
  25. "code.gitea.io/gitea/modules/user"
  26. "github.com/Unknwon/com"
  27. _ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
  28. _ "github.com/go-macaron/cache/redis"
  29. "github.com/go-macaron/session"
  30. _ "github.com/go-macaron/session/redis" // redis plugin for store session
  31. "github.com/go-xorm/core"
  32. shellquote "github.com/kballard/go-shellquote"
  33. version "github.com/mcuadros/go-version"
  34. ini "gopkg.in/ini.v1"
  35. "strk.kbt.io/projects/go/libravatar"
  36. )
  37. // Scheme describes protocol types
  38. type Scheme string
  39. // enumerates all the scheme types
  40. const (
  41. HTTP Scheme = "http"
  42. HTTPS Scheme = "https"
  43. FCGI Scheme = "fcgi"
  44. UnixSocket Scheme = "unix"
  45. )
  46. // LandingPage describes the default page
  47. type LandingPage string
  48. // enumerates all the landing page types
  49. const (
  50. LandingPageHome LandingPage = "/"
  51. LandingPageExplore LandingPage = "/explore"
  52. LandingPageOrganizations LandingPage = "/explore/organizations"
  53. )
  54. // MarkupParser defines the external parser configured in ini
  55. type MarkupParser struct {
  56. Enabled bool
  57. MarkupName string
  58. Command string
  59. FileExtensions []string
  60. IsInputFile bool
  61. }
  62. // enumerates all the policy repository creating
  63. const (
  64. RepoCreatingLastUserVisibility = "last"
  65. RepoCreatingPrivate = "private"
  66. RepoCreatingPublic = "public"
  67. )
  68. // enumerates all the types of captchas
  69. const (
  70. ImageCaptcha = "image"
  71. ReCaptcha = "recaptcha"
  72. )
  73. // settings
  74. var (
  75. // AppVer settings
  76. AppVer string
  77. AppBuiltWith string
  78. AppName string
  79. AppURL string
  80. AppSubURL string
  81. AppSubURLDepth int // Number of slashes
  82. AppPath string
  83. AppDataPath string
  84. AppWorkPath string
  85. // Server settings
  86. Protocol Scheme
  87. Domain string
  88. HTTPAddr string
  89. HTTPPort string
  90. LocalURL string
  91. RedirectOtherPort bool
  92. PortToRedirect string
  93. OfflineMode bool
  94. DisableRouterLog bool
  95. CertFile string
  96. KeyFile string
  97. StaticRootPath string
  98. EnableGzip bool
  99. LandingPageURL LandingPage
  100. UnixSocketPermission uint32
  101. EnablePprof bool
  102. PprofDataPath string
  103. EnableLetsEncrypt bool
  104. LetsEncryptTOS bool
  105. LetsEncryptDirectory string
  106. LetsEncryptEmail string
  107. SSH = struct {
  108. Disabled bool `ini:"DISABLE_SSH"`
  109. StartBuiltinServer bool `ini:"START_SSH_SERVER"`
  110. BuiltinServerUser string `ini:"BUILTIN_SSH_SERVER_USER"`
  111. Domain string `ini:"SSH_DOMAIN"`
  112. Port int `ini:"SSH_PORT"`
  113. ListenHost string `ini:"SSH_LISTEN_HOST"`
  114. ListenPort int `ini:"SSH_LISTEN_PORT"`
  115. RootPath string `ini:"SSH_ROOT_PATH"`
  116. ServerCiphers []string `ini:"SSH_SERVER_CIPHERS"`
  117. ServerKeyExchanges []string `ini:"SSH_SERVER_KEY_EXCHANGES"`
  118. ServerMACs []string `ini:"SSH_SERVER_MACS"`
  119. KeyTestPath string `ini:"SSH_KEY_TEST_PATH"`
  120. KeygenPath string `ini:"SSH_KEYGEN_PATH"`
  121. AuthorizedKeysBackup bool `ini:"SSH_AUTHORIZED_KEYS_BACKUP"`
  122. MinimumKeySizeCheck bool `ini:"-"`
  123. MinimumKeySizes map[string]int `ini:"-"`
  124. CreateAuthorizedKeysFile bool `ini:"SSH_CREATE_AUTHORIZED_KEYS_FILE"`
  125. ExposeAnonymous bool `ini:"SSH_EXPOSE_ANONYMOUS"`
  126. }{
  127. Disabled: false,
  128. StartBuiltinServer: false,
  129. Domain: "",
  130. Port: 22,
  131. ServerCiphers: []string{"aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-gcm@openssh.com", "arcfour256", "arcfour128"},
  132. ServerKeyExchanges: []string{"diffie-hellman-group1-sha1", "diffie-hellman-group14-sha1", "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", "curve25519-sha256@libssh.org"},
  133. ServerMACs: []string{"hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha1", "hmac-sha1-96"},
  134. KeygenPath: "ssh-keygen",
  135. }
  136. LFS struct {
  137. StartServer bool `ini:"LFS_START_SERVER"`
  138. ContentPath string `ini:"LFS_CONTENT_PATH"`
  139. JWTSecretBase64 string `ini:"LFS_JWT_SECRET"`
  140. JWTSecretBytes []byte `ini:"-"`
  141. HTTPAuthExpiry time.Duration `ini:"LFS_HTTP_AUTH_EXPIRY"`
  142. }
  143. // Security settings
  144. InstallLock bool
  145. SecretKey string
  146. LogInRememberDays int
  147. CookieUserName string
  148. CookieRememberName string
  149. ReverseProxyAuthUser string
  150. ReverseProxyAuthEmail string
  151. MinPasswordLength int
  152. ImportLocalPaths bool
  153. DisableGitHooks bool
  154. // Database settings
  155. UseSQLite3 bool
  156. UseMySQL bool
  157. UseMSSQL bool
  158. UsePostgreSQL bool
  159. UseTiDB bool
  160. LogSQL bool
  161. DBConnectRetries int
  162. DBConnectBackoff time.Duration
  163. // Indexer settings
  164. Indexer struct {
  165. IssuePath string
  166. RepoIndexerEnabled bool
  167. RepoPath string
  168. UpdateQueueLength int
  169. MaxIndexerFileSize int64
  170. }
  171. // Webhook settings
  172. Webhook = struct {
  173. QueueLength int
  174. DeliverTimeout int
  175. SkipTLSVerify bool
  176. Types []string
  177. PagingNum int
  178. }{
  179. QueueLength: 1000,
  180. DeliverTimeout: 5,
  181. SkipTLSVerify: false,
  182. PagingNum: 10,
  183. }
  184. // Repository settings
  185. Repository = struct {
  186. AnsiCharset string
  187. ForcePrivate bool
  188. DefaultPrivate string
  189. MaxCreationLimit int
  190. MirrorQueueLength int
  191. PullRequestQueueLength int
  192. PreferredLicenses []string
  193. DisableHTTPGit bool
  194. AccessControlAllowOrigin string
  195. UseCompatSSHURI bool
  196. // Repository editor settings
  197. Editor struct {
  198. LineWrapExtensions []string
  199. PreviewableFileModes []string
  200. } `ini:"-"`
  201. // Repository upload settings
  202. Upload struct {
  203. Enabled bool
  204. TempPath string
  205. AllowedTypes []string `delim:"|"`
  206. FileMaxSize int64
  207. MaxFiles int
  208. } `ini:"-"`
  209. // Repository local settings
  210. Local struct {
  211. LocalCopyPath string
  212. LocalWikiPath string
  213. } `ini:"-"`
  214. // Pull request settings
  215. PullRequest struct {
  216. WorkInProgressPrefixes []string
  217. } `ini:"repository.pull-request"`
  218. }{
  219. AnsiCharset: "",
  220. ForcePrivate: false,
  221. DefaultPrivate: RepoCreatingLastUserVisibility,
  222. MaxCreationLimit: -1,
  223. MirrorQueueLength: 1000,
  224. PullRequestQueueLength: 1000,
  225. PreferredLicenses: []string{"Apache License 2.0,MIT License"},
  226. DisableHTTPGit: false,
  227. AccessControlAllowOrigin: "",
  228. UseCompatSSHURI: false,
  229. // Repository editor settings
  230. Editor: struct {
  231. LineWrapExtensions []string
  232. PreviewableFileModes []string
  233. }{
  234. LineWrapExtensions: strings.Split(".txt,.md,.markdown,.mdown,.mkd,", ","),
  235. PreviewableFileModes: []string{"markdown"},
  236. },
  237. // Repository upload settings
  238. Upload: struct {
  239. Enabled bool
  240. TempPath string
  241. AllowedTypes []string `delim:"|"`
  242. FileMaxSize int64
  243. MaxFiles int
  244. }{
  245. Enabled: true,
  246. TempPath: "data/tmp/uploads",
  247. AllowedTypes: []string{},
  248. FileMaxSize: 3,
  249. MaxFiles: 5,
  250. },
  251. // Repository local settings
  252. Local: struct {
  253. LocalCopyPath string
  254. LocalWikiPath string
  255. }{
  256. LocalCopyPath: "tmp/local-repo",
  257. LocalWikiPath: "tmp/local-wiki",
  258. },
  259. // Pull request settings
  260. PullRequest: struct {
  261. WorkInProgressPrefixes []string
  262. }{
  263. WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
  264. },
  265. }
  266. RepoRootPath string
  267. ScriptType = "bash"
  268. // UI settings
  269. UI = struct {
  270. ExplorePagingNum int
  271. IssuePagingNum int
  272. RepoSearchPagingNum int
  273. FeedMaxCommitNum int
  274. GraphMaxCommitNum int
  275. CodeCommentLines int
  276. ReactionMaxUserNum int
  277. ThemeColorMetaTag string
  278. MaxDisplayFileSize int64
  279. ShowUserEmail bool
  280. DefaultTheme string
  281. Themes []string
  282. Admin struct {
  283. UserPagingNum int
  284. RepoPagingNum int
  285. NoticePagingNum int
  286. OrgPagingNum int
  287. } `ini:"ui.admin"`
  288. User struct {
  289. RepoPagingNum int
  290. } `ini:"ui.user"`
  291. Meta struct {
  292. Author string
  293. Description string
  294. Keywords string
  295. } `ini:"ui.meta"`
  296. }{
  297. ExplorePagingNum: 20,
  298. IssuePagingNum: 10,
  299. RepoSearchPagingNum: 10,
  300. FeedMaxCommitNum: 5,
  301. GraphMaxCommitNum: 100,
  302. CodeCommentLines: 4,
  303. ReactionMaxUserNum: 10,
  304. ThemeColorMetaTag: `#6cc644`,
  305. MaxDisplayFileSize: 8388608,
  306. DefaultTheme: `gitea`,
  307. Themes: []string{`gitea`, `arc-green`},
  308. Admin: struct {
  309. UserPagingNum int
  310. RepoPagingNum int
  311. NoticePagingNum int
  312. OrgPagingNum int
  313. }{
  314. UserPagingNum: 50,
  315. RepoPagingNum: 50,
  316. NoticePagingNum: 25,
  317. OrgPagingNum: 50,
  318. },
  319. User: struct {
  320. RepoPagingNum int
  321. }{
  322. RepoPagingNum: 15,
  323. },
  324. Meta: struct {
  325. Author string
  326. Description string
  327. Keywords string
  328. }{
  329. Author: "Gitea - Git with a cup of tea",
  330. Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
  331. Keywords: "go,git,self-hosted,gitea",
  332. },
  333. }
  334. // Markdown settings
  335. Markdown = struct {
  336. EnableHardLineBreak bool
  337. CustomURLSchemes []string `ini:"CUSTOM_URL_SCHEMES"`
  338. FileExtensions []string
  339. }{
  340. EnableHardLineBreak: false,
  341. FileExtensions: strings.Split(".md,.markdown,.mdown,.mkd", ","),
  342. }
  343. // Admin settings
  344. Admin struct {
  345. DisableRegularOrgCreation bool
  346. }
  347. // Picture settings
  348. AvatarUploadPath string
  349. AvatarMaxWidth int
  350. AvatarMaxHeight int
  351. GravatarSource string
  352. GravatarSourceURL *url.URL
  353. DisableGravatar bool
  354. EnableFederatedAvatar bool
  355. LibravatarService *libravatar.Libravatar
  356. // Log settings
  357. LogLevel string
  358. LogRootPath string
  359. LogModes []string
  360. LogConfigs []string
  361. // Attachment settings
  362. AttachmentPath string
  363. AttachmentAllowedTypes string
  364. AttachmentMaxSize int64
  365. AttachmentMaxFiles int
  366. AttachmentEnabled bool
  367. // Time settings
  368. TimeFormat string
  369. // Session settings
  370. SessionConfig session.Options
  371. CSRFCookieName = "_csrf"
  372. // Cron tasks
  373. Cron = struct {
  374. UpdateMirror struct {
  375. Enabled bool
  376. RunAtStart bool
  377. Schedule string
  378. } `ini:"cron.update_mirrors"`
  379. RepoHealthCheck struct {
  380. Enabled bool
  381. RunAtStart bool
  382. Schedule string
  383. Timeout time.Duration
  384. Args []string `delim:" "`
  385. } `ini:"cron.repo_health_check"`
  386. CheckRepoStats struct {
  387. Enabled bool
  388. RunAtStart bool
  389. Schedule string
  390. } `ini:"cron.check_repo_stats"`
  391. ArchiveCleanup struct {
  392. Enabled bool
  393. RunAtStart bool
  394. Schedule string
  395. OlderThan time.Duration
  396. } `ini:"cron.archive_cleanup"`
  397. SyncExternalUsers struct {
  398. Enabled bool
  399. RunAtStart bool
  400. Schedule string
  401. UpdateExisting bool
  402. } `ini:"cron.sync_external_users"`
  403. DeletedBranchesCleanup struct {
  404. Enabled bool
  405. RunAtStart bool
  406. Schedule string
  407. OlderThan time.Duration
  408. } `ini:"cron.deleted_branches_cleanup"`
  409. }{
  410. UpdateMirror: struct {
  411. Enabled bool
  412. RunAtStart bool
  413. Schedule string
  414. }{
  415. Enabled: true,
  416. RunAtStart: false,
  417. Schedule: "@every 10m",
  418. },
  419. RepoHealthCheck: struct {
  420. Enabled bool
  421. RunAtStart bool
  422. Schedule string
  423. Timeout time.Duration
  424. Args []string `delim:" "`
  425. }{
  426. Enabled: true,
  427. RunAtStart: false,
  428. Schedule: "@every 24h",
  429. Timeout: 60 * time.Second,
  430. Args: []string{},
  431. },
  432. CheckRepoStats: struct {
  433. Enabled bool
  434. RunAtStart bool
  435. Schedule string
  436. }{
  437. Enabled: true,
  438. RunAtStart: true,
  439. Schedule: "@every 24h",
  440. },
  441. ArchiveCleanup: struct {
  442. Enabled bool
  443. RunAtStart bool
  444. Schedule string
  445. OlderThan time.Duration
  446. }{
  447. Enabled: true,
  448. RunAtStart: true,
  449. Schedule: "@every 24h",
  450. OlderThan: 24 * time.Hour,
  451. },
  452. SyncExternalUsers: struct {
  453. Enabled bool
  454. RunAtStart bool
  455. Schedule string
  456. UpdateExisting bool
  457. }{
  458. Enabled: true,
  459. RunAtStart: false,
  460. Schedule: "@every 24h",
  461. UpdateExisting: true,
  462. },
  463. DeletedBranchesCleanup: struct {
  464. Enabled bool
  465. RunAtStart bool
  466. Schedule string
  467. OlderThan time.Duration
  468. }{
  469. Enabled: true,
  470. RunAtStart: true,
  471. Schedule: "@every 24h",
  472. OlderThan: 24 * time.Hour,
  473. },
  474. }
  475. // Git settings
  476. Git = struct {
  477. Version string `ini:"-"`
  478. DisableDiffHighlight bool
  479. MaxGitDiffLines int
  480. MaxGitDiffLineCharacters int
  481. MaxGitDiffFiles int
  482. GCArgs []string `delim:" "`
  483. Timeout struct {
  484. Migrate int
  485. Mirror int
  486. Clone int
  487. Pull int
  488. GC int `ini:"GC"`
  489. } `ini:"git.timeout"`
  490. }{
  491. DisableDiffHighlight: false,
  492. MaxGitDiffLines: 1000,
  493. MaxGitDiffLineCharacters: 5000,
  494. MaxGitDiffFiles: 100,
  495. GCArgs: []string{},
  496. Timeout: struct {
  497. Migrate int
  498. Mirror int
  499. Clone int
  500. Pull int
  501. GC int `ini:"GC"`
  502. }{
  503. Migrate: 600,
  504. Mirror: 300,
  505. Clone: 300,
  506. Pull: 300,
  507. GC: 60,
  508. },
  509. }
  510. // Mirror settings
  511. Mirror struct {
  512. DefaultInterval time.Duration
  513. MinInterval time.Duration
  514. }
  515. // API settings
  516. API = struct {
  517. EnableSwagger bool
  518. MaxResponseItems int
  519. DefaultPagingNum int
  520. }{
  521. EnableSwagger: true,
  522. MaxResponseItems: 50,
  523. DefaultPagingNum: 30,
  524. }
  525. U2F = struct {
  526. AppID string
  527. TrustedFacets []string
  528. }{}
  529. // Metrics settings
  530. Metrics = struct {
  531. Enabled bool
  532. Token string
  533. }{
  534. Enabled: false,
  535. Token: "",
  536. }
  537. // I18n settings
  538. Langs []string
  539. Names []string
  540. dateLangs map[string]string
  541. // Highlight settings are loaded in modules/template/highlight.go
  542. // Other settings
  543. ShowFooterBranding bool
  544. ShowFooterVersion bool
  545. ShowFooterTemplateLoadTime bool
  546. // Global setting objects
  547. Cfg *ini.File
  548. CustomPath string // Custom directory path
  549. CustomConf string
  550. CustomPID string
  551. ProdMode bool
  552. RunUser string
  553. IsWindows bool
  554. HasRobotsTxt bool
  555. InternalToken string // internal access token
  556. IterateBufferSize int
  557. ExternalMarkupParsers []MarkupParser
  558. // UILocation is the location on the UI, so that we can display the time on UI.
  559. // Currently only show the default time.Local, it could be added to app.ini after UI is ready
  560. UILocation = time.Local
  561. )
  562. // DateLang transforms standard language locale name to corresponding value in datetime plugin.
  563. func DateLang(lang string) string {
  564. name, ok := dateLangs[lang]
  565. if ok {
  566. return name
  567. }
  568. return "en"
  569. }
  570. func getAppPath() (string, error) {
  571. var appPath string
  572. var err error
  573. if IsWindows && filepath.IsAbs(os.Args[0]) {
  574. appPath = filepath.Clean(os.Args[0])
  575. } else {
  576. appPath, err = exec.LookPath(os.Args[0])
  577. }
  578. if err != nil {
  579. return "", err
  580. }
  581. appPath, err = filepath.Abs(appPath)
  582. if err != nil {
  583. return "", err
  584. }
  585. // Note: we don't use path.Dir here because it does not handle case
  586. // which path starts with two "/" in Windows: "//psf/Home/..."
  587. return strings.Replace(appPath, "\\", "/", -1), err
  588. }
  589. func getWorkPath(appPath string) string {
  590. workPath := ""
  591. giteaWorkPath := os.Getenv("GITEA_WORK_DIR")
  592. if len(giteaWorkPath) > 0 {
  593. workPath = giteaWorkPath
  594. } else {
  595. i := strings.LastIndex(appPath, "/")
  596. if i == -1 {
  597. workPath = appPath
  598. } else {
  599. workPath = appPath[:i]
  600. }
  601. }
  602. return strings.Replace(workPath, "\\", "/", -1)
  603. }
  604. func init() {
  605. IsWindows = runtime.GOOS == "windows"
  606. log.NewLogger(0, "console", `{"level": 0}`)
  607. var err error
  608. if AppPath, err = getAppPath(); err != nil {
  609. log.Fatal(4, "Failed to get app path: %v", err)
  610. }
  611. AppWorkPath = getWorkPath(AppPath)
  612. }
  613. func forcePathSeparator(path string) {
  614. if strings.Contains(path, "\\") {
  615. log.Fatal(4, "Do not use '\\' or '\\\\' in paths, instead, please use '/' in all places")
  616. }
  617. }
  618. // IsRunUserMatchCurrentUser returns false if configured run user does not match
  619. // actual user that runs the app. The first return value is the actual user name.
  620. // This check is ignored under Windows since SSH remote login is not the main
  621. // method to login on Windows.
  622. func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
  623. if IsWindows {
  624. return "", true
  625. }
  626. currentUser := user.CurrentUsername()
  627. return currentUser, runUser == currentUser
  628. }
  629. func createPIDFile(pidPath string) {
  630. currentPid := os.Getpid()
  631. if err := os.MkdirAll(filepath.Dir(pidPath), os.ModePerm); err != nil {
  632. log.Fatal(4, "Failed to create PID folder: %v", err)
  633. }
  634. file, err := os.Create(pidPath)
  635. if err != nil {
  636. log.Fatal(4, "Failed to create PID file: %v", err)
  637. }
  638. defer file.Close()
  639. if _, err := file.WriteString(strconv.FormatInt(int64(currentPid), 10)); err != nil {
  640. log.Fatal(4, "Failed to write PID information: %v", err)
  641. }
  642. }
  643. // CheckLFSVersion will check lfs version, if not satisfied, then disable it.
  644. func CheckLFSVersion() {
  645. if LFS.StartServer {
  646. //Disable LFS client hooks if installed for the current OS user
  647. //Needs at least git v2.1.2
  648. binVersion, err := git.BinVersion()
  649. if err != nil {
  650. log.Fatal(4, "Error retrieving git version: %v", err)
  651. }
  652. if !version.Compare(binVersion, "2.1.2", ">=") {
  653. LFS.StartServer = false
  654. log.Error(4, "LFS server support needs at least Git v2.1.2")
  655. } else {
  656. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "filter.lfs.required=",
  657. "-c", "filter.lfs.smudge=", "-c", "filter.lfs.clean=")
  658. }
  659. }
  660. }
  661. // NewContext initializes configuration context.
  662. // NOTE: do not print any log except error.
  663. func NewContext() {
  664. Cfg = ini.Empty()
  665. CustomPath = os.Getenv("GITEA_CUSTOM")
  666. if len(CustomPath) == 0 {
  667. CustomPath = path.Join(AppWorkPath, "custom")
  668. } else if !filepath.IsAbs(CustomPath) {
  669. CustomPath = path.Join(AppWorkPath, CustomPath)
  670. }
  671. if len(CustomPID) > 0 {
  672. createPIDFile(CustomPID)
  673. }
  674. if len(CustomConf) == 0 {
  675. CustomConf = path.Join(CustomPath, "conf/app.ini")
  676. } else if !filepath.IsAbs(CustomConf) {
  677. CustomConf = path.Join(CustomPath, CustomConf)
  678. }
  679. if com.IsFile(CustomConf) {
  680. if err := Cfg.Append(CustomConf); err != nil {
  681. log.Fatal(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  682. }
  683. } else {
  684. log.Warn("Custom config '%s' not found, ignore this if you're running first time", CustomConf)
  685. }
  686. Cfg.NameMapper = ini.AllCapsUnderscore
  687. homeDir, err := com.HomeDir()
  688. if err != nil {
  689. log.Fatal(4, "Failed to get home directory: %v", err)
  690. }
  691. homeDir = strings.Replace(homeDir, "\\", "/", -1)
  692. LogLevel = getLogLevel("log", "LEVEL", "Info")
  693. LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(AppWorkPath, "log"))
  694. forcePathSeparator(LogRootPath)
  695. sec := Cfg.Section("server")
  696. AppName = Cfg.Section("").Key("APP_NAME").MustString("Gitea: Git with a cup of tea")
  697. Protocol = HTTP
  698. if sec.Key("PROTOCOL").String() == "https" {
  699. Protocol = HTTPS
  700. CertFile = sec.Key("CERT_FILE").String()
  701. KeyFile = sec.Key("KEY_FILE").String()
  702. } else if sec.Key("PROTOCOL").String() == "fcgi" {
  703. Protocol = FCGI
  704. } else if sec.Key("PROTOCOL").String() == "unix" {
  705. Protocol = UnixSocket
  706. UnixSocketPermissionRaw := sec.Key("UNIX_SOCKET_PERMISSION").MustString("666")
  707. UnixSocketPermissionParsed, err := strconv.ParseUint(UnixSocketPermissionRaw, 8, 32)
  708. if err != nil || UnixSocketPermissionParsed > 0777 {
  709. log.Fatal(4, "Failed to parse unixSocketPermission: %s", UnixSocketPermissionRaw)
  710. }
  711. UnixSocketPermission = uint32(UnixSocketPermissionParsed)
  712. }
  713. EnableLetsEncrypt = sec.Key("ENABLE_LETSENCRYPT").MustBool(false)
  714. LetsEncryptTOS = sec.Key("LETSENCRYPT_ACCEPTTOS").MustBool(false)
  715. if !LetsEncryptTOS && EnableLetsEncrypt {
  716. log.Warn("Failed to enable Let's Encrypt due to Let's Encrypt TOS not being accepted")
  717. EnableLetsEncrypt = false
  718. }
  719. LetsEncryptDirectory = sec.Key("LETSENCRYPT_DIRECTORY").MustString("https")
  720. LetsEncryptEmail = sec.Key("LETSENCRYPT_EMAIL").MustString("")
  721. Domain = sec.Key("DOMAIN").MustString("localhost")
  722. HTTPAddr = sec.Key("HTTP_ADDR").MustString("0.0.0.0")
  723. HTTPPort = sec.Key("HTTP_PORT").MustString("3000")
  724. defaultAppURL := string(Protocol) + "://" + Domain
  725. if (Protocol == HTTP && HTTPPort != "80") || (Protocol == HTTPS && HTTPPort != "443") {
  726. defaultAppURL += ":" + HTTPPort
  727. }
  728. AppURL = sec.Key("ROOT_URL").MustString(defaultAppURL)
  729. AppURL = strings.TrimRight(AppURL, "/") + "/"
  730. // Check if has app suburl.
  731. url, err := url.Parse(AppURL)
  732. if err != nil {
  733. log.Fatal(4, "Invalid ROOT_URL '%s': %s", AppURL, err)
  734. }
  735. // Suburl should start with '/' and end without '/', such as '/{subpath}'.
  736. // This value is empty if site does not have sub-url.
  737. AppSubURL = strings.TrimSuffix(url.Path, "/")
  738. AppSubURLDepth = strings.Count(AppSubURL, "/")
  739. // Check if Domain differs from AppURL domain than update it to AppURL's domain
  740. // TODO: Can be replaced with url.Hostname() when minimal GoLang version is 1.8
  741. urlHostname := strings.SplitN(url.Host, ":", 2)[0]
  742. if urlHostname != Domain && net.ParseIP(urlHostname) == nil {
  743. Domain = urlHostname
  744. }
  745. var defaultLocalURL string
  746. switch Protocol {
  747. case UnixSocket:
  748. defaultLocalURL = "http://unix/"
  749. case FCGI:
  750. defaultLocalURL = AppURL
  751. default:
  752. defaultLocalURL = string(Protocol) + "://"
  753. if HTTPAddr == "0.0.0.0" {
  754. defaultLocalURL += "localhost"
  755. } else {
  756. defaultLocalURL += HTTPAddr
  757. }
  758. defaultLocalURL += ":" + HTTPPort + "/"
  759. }
  760. LocalURL = sec.Key("LOCAL_ROOT_URL").MustString(defaultLocalURL)
  761. RedirectOtherPort = sec.Key("REDIRECT_OTHER_PORT").MustBool(false)
  762. PortToRedirect = sec.Key("PORT_TO_REDIRECT").MustString("80")
  763. OfflineMode = sec.Key("OFFLINE_MODE").MustBool()
  764. DisableRouterLog = sec.Key("DISABLE_ROUTER_LOG").MustBool()
  765. StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(AppWorkPath)
  766. AppDataPath = sec.Key("APP_DATA_PATH").MustString(path.Join(AppWorkPath, "data"))
  767. EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
  768. EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false)
  769. PprofDataPath = sec.Key("PPROF_DATA_PATH").MustString(path.Join(AppWorkPath, "data/tmp/pprof"))
  770. if !filepath.IsAbs(PprofDataPath) {
  771. PprofDataPath = filepath.Join(AppWorkPath, PprofDataPath)
  772. }
  773. switch sec.Key("LANDING_PAGE").MustString("home") {
  774. case "explore":
  775. LandingPageURL = LandingPageExplore
  776. case "organizations":
  777. LandingPageURL = LandingPageOrganizations
  778. default:
  779. LandingPageURL = LandingPageHome
  780. }
  781. if len(SSH.Domain) == 0 {
  782. SSH.Domain = Domain
  783. }
  784. SSH.RootPath = path.Join(homeDir, ".ssh")
  785. serverCiphers := sec.Key("SSH_SERVER_CIPHERS").Strings(",")
  786. if len(serverCiphers) > 0 {
  787. SSH.ServerCiphers = serverCiphers
  788. }
  789. serverKeyExchanges := sec.Key("SSH_SERVER_KEY_EXCHANGES").Strings(",")
  790. if len(serverKeyExchanges) > 0 {
  791. SSH.ServerKeyExchanges = serverKeyExchanges
  792. }
  793. serverMACs := sec.Key("SSH_SERVER_MACS").Strings(",")
  794. if len(serverMACs) > 0 {
  795. SSH.ServerMACs = serverMACs
  796. }
  797. SSH.KeyTestPath = os.TempDir()
  798. if err = Cfg.Section("server").MapTo(&SSH); err != nil {
  799. log.Fatal(4, "Failed to map SSH settings: %v", err)
  800. }
  801. SSH.KeygenPath = sec.Key("SSH_KEYGEN_PATH").MustString("ssh-keygen")
  802. SSH.Port = sec.Key("SSH_PORT").MustInt(22)
  803. SSH.ListenPort = sec.Key("SSH_LISTEN_PORT").MustInt(SSH.Port)
  804. // When disable SSH, start builtin server value is ignored.
  805. if SSH.Disabled {
  806. SSH.StartBuiltinServer = false
  807. }
  808. if !SSH.Disabled && !SSH.StartBuiltinServer {
  809. if err := os.MkdirAll(SSH.RootPath, 0700); err != nil {
  810. log.Fatal(4, "Failed to create '%s': %v", SSH.RootPath, err)
  811. } else if err = os.MkdirAll(SSH.KeyTestPath, 0644); err != nil {
  812. log.Fatal(4, "Failed to create '%s': %v", SSH.KeyTestPath, err)
  813. }
  814. }
  815. SSH.MinimumKeySizeCheck = sec.Key("MINIMUM_KEY_SIZE_CHECK").MustBool()
  816. SSH.MinimumKeySizes = map[string]int{}
  817. minimumKeySizes := Cfg.Section("ssh.minimum_key_sizes").Keys()
  818. for _, key := range minimumKeySizes {
  819. if key.MustInt() != -1 {
  820. SSH.MinimumKeySizes[strings.ToLower(key.Name())] = key.MustInt()
  821. }
  822. }
  823. SSH.AuthorizedKeysBackup = sec.Key("SSH_AUTHORIZED_KEYS_BACKUP").MustBool(true)
  824. SSH.CreateAuthorizedKeysFile = sec.Key("SSH_CREATE_AUTHORIZED_KEYS_FILE").MustBool(true)
  825. SSH.ExposeAnonymous = sec.Key("SSH_EXPOSE_ANONYMOUS").MustBool(false)
  826. sec = Cfg.Section("server")
  827. if err = sec.MapTo(&LFS); err != nil {
  828. log.Fatal(4, "Failed to map LFS settings: %v", err)
  829. }
  830. LFS.ContentPath = sec.Key("LFS_CONTENT_PATH").MustString(filepath.Join(AppDataPath, "lfs"))
  831. if !filepath.IsAbs(LFS.ContentPath) {
  832. LFS.ContentPath = filepath.Join(AppWorkPath, LFS.ContentPath)
  833. }
  834. LFS.HTTPAuthExpiry = sec.Key("LFS_HTTP_AUTH_EXPIRY").MustDuration(20 * time.Minute)
  835. if LFS.StartServer {
  836. if err := os.MkdirAll(LFS.ContentPath, 0700); err != nil {
  837. log.Fatal(4, "Failed to create '%s': %v", LFS.ContentPath, err)
  838. }
  839. LFS.JWTSecretBytes = make([]byte, 32)
  840. n, err := base64.RawURLEncoding.Decode(LFS.JWTSecretBytes, []byte(LFS.JWTSecretBase64))
  841. if err != nil || n != 32 {
  842. LFS.JWTSecretBase64, err = generate.NewLfsJwtSecret()
  843. if err != nil {
  844. log.Fatal(4, "Error generating JWT Secret for custom config: %v", err)
  845. return
  846. }
  847. // Save secret
  848. cfg := ini.Empty()
  849. if com.IsFile(CustomConf) {
  850. // Keeps custom settings if there is already something.
  851. if err := cfg.Append(CustomConf); err != nil {
  852. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  853. }
  854. }
  855. cfg.Section("server").Key("LFS_JWT_SECRET").SetValue(LFS.JWTSecretBase64)
  856. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  857. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  858. }
  859. if err := cfg.SaveTo(CustomConf); err != nil {
  860. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  861. return
  862. }
  863. }
  864. }
  865. sec = Cfg.Section("security")
  866. InstallLock = sec.Key("INSTALL_LOCK").MustBool(false)
  867. SecretKey = sec.Key("SECRET_KEY").MustString("!#@FDEWREWR&*(")
  868. LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(7)
  869. CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
  870. CookieRememberName = sec.Key("COOKIE_REMEMBER_NAME").MustString("gitea_incredible")
  871. ReverseProxyAuthUser = sec.Key("REVERSE_PROXY_AUTHENTICATION_USER").MustString("X-WEBAUTH-USER")
  872. ReverseProxyAuthEmail = sec.Key("REVERSE_PROXY_AUTHENTICATION_EMAIL").MustString("X-WEBAUTH-EMAIL")
  873. MinPasswordLength = sec.Key("MIN_PASSWORD_LENGTH").MustInt(6)
  874. ImportLocalPaths = sec.Key("IMPORT_LOCAL_PATHS").MustBool(false)
  875. DisableGitHooks = sec.Key("DISABLE_GIT_HOOKS").MustBool(false)
  876. InternalToken = sec.Key("INTERNAL_TOKEN").String()
  877. if len(InternalToken) == 0 {
  878. InternalToken, err = generate.NewInternalToken()
  879. if err != nil {
  880. log.Fatal(4, "Error generate internal token: %v", err)
  881. }
  882. // Save secret
  883. cfgSave := ini.Empty()
  884. if com.IsFile(CustomConf) {
  885. // Keeps custom settings if there is already something.
  886. if err := cfgSave.Append(CustomConf); err != nil {
  887. log.Error(4, "Failed to load custom conf '%s': %v", CustomConf, err)
  888. }
  889. }
  890. cfgSave.Section("security").Key("INTERNAL_TOKEN").SetValue(InternalToken)
  891. if err := os.MkdirAll(filepath.Dir(CustomConf), os.ModePerm); err != nil {
  892. log.Fatal(4, "Failed to create '%s': %v", CustomConf, err)
  893. }
  894. if err := cfgSave.SaveTo(CustomConf); err != nil {
  895. log.Fatal(4, "Error saving generated JWT Secret to custom config: %v", err)
  896. }
  897. }
  898. IterateBufferSize = Cfg.Section("database").Key("ITERATE_BUFFER_SIZE").MustInt(50)
  899. LogSQL = Cfg.Section("database").Key("LOG_SQL").MustBool(true)
  900. DBConnectRetries = Cfg.Section("database").Key("DB_RETRIES").MustInt(10)
  901. DBConnectBackoff = Cfg.Section("database").Key("DB_RETRY_BACKOFF").MustDuration(3 * time.Second)
  902. sec = Cfg.Section("attachment")
  903. AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments"))
  904. if !filepath.IsAbs(AttachmentPath) {
  905. AttachmentPath = path.Join(AppWorkPath, AttachmentPath)
  906. }
  907. AttachmentAllowedTypes = strings.Replace(sec.Key("ALLOWED_TYPES").MustString("image/jpeg,image/png,application/zip,application/gzip"), "|", ",", -1)
  908. AttachmentMaxSize = sec.Key("MAX_SIZE").MustInt64(4)
  909. AttachmentMaxFiles = sec.Key("MAX_FILES").MustInt(5)
  910. AttachmentEnabled = sec.Key("ENABLED").MustBool(true)
  911. TimeFormatKey := Cfg.Section("time").Key("FORMAT").MustString("RFC1123")
  912. TimeFormat = map[string]string{
  913. "ANSIC": time.ANSIC,
  914. "UnixDate": time.UnixDate,
  915. "RubyDate": time.RubyDate,
  916. "RFC822": time.RFC822,
  917. "RFC822Z": time.RFC822Z,
  918. "RFC850": time.RFC850,
  919. "RFC1123": time.RFC1123,
  920. "RFC1123Z": time.RFC1123Z,
  921. "RFC3339": time.RFC3339,
  922. "RFC3339Nano": time.RFC3339Nano,
  923. "Kitchen": time.Kitchen,
  924. "Stamp": time.Stamp,
  925. "StampMilli": time.StampMilli,
  926. "StampMicro": time.StampMicro,
  927. "StampNano": time.StampNano,
  928. }[TimeFormatKey]
  929. // When the TimeFormatKey does not exist in the previous map e.g.'2006-01-02 15:04:05'
  930. if len(TimeFormat) == 0 {
  931. TimeFormat = TimeFormatKey
  932. TestTimeFormat, _ := time.Parse(TimeFormat, TimeFormat)
  933. if TestTimeFormat.Format(time.RFC3339) != "2006-01-02T15:04:05Z" {
  934. log.Fatal(4, "Can't create time properly, please check your time format has 2006, 01, 02, 15, 04 and 05")
  935. }
  936. log.Trace("Custom TimeFormat: %s", TimeFormat)
  937. }
  938. RunUser = Cfg.Section("").Key("RUN_USER").MustString(user.CurrentUsername())
  939. // Does not check run user when the install lock is off.
  940. if InstallLock {
  941. currentUser, match := IsRunUserMatchCurrentUser(RunUser)
  942. if !match {
  943. log.Fatal(4, "Expect user '%s' but current user is: %s", RunUser, currentUser)
  944. }
  945. }
  946. SSH.BuiltinServerUser = Cfg.Section("server").Key("BUILTIN_SSH_SERVER_USER").MustString(RunUser)
  947. // Determine and create root git repository path.
  948. sec = Cfg.Section("repository")
  949. Repository.DisableHTTPGit = sec.Key("DISABLE_HTTP_GIT").MustBool()
  950. Repository.UseCompatSSHURI = sec.Key("USE_COMPAT_SSH_URI").MustBool()
  951. Repository.MaxCreationLimit = sec.Key("MAX_CREATION_LIMIT").MustInt(-1)
  952. RepoRootPath = sec.Key("ROOT").MustString(path.Join(homeDir, "gitea-repositories"))
  953. forcePathSeparator(RepoRootPath)
  954. if !filepath.IsAbs(RepoRootPath) {
  955. RepoRootPath = filepath.Join(AppWorkPath, RepoRootPath)
  956. } else {
  957. RepoRootPath = filepath.Clean(RepoRootPath)
  958. }
  959. ScriptType = sec.Key("SCRIPT_TYPE").MustString("bash")
  960. if err = Cfg.Section("repository").MapTo(&Repository); err != nil {
  961. log.Fatal(4, "Failed to map Repository settings: %v", err)
  962. } else if err = Cfg.Section("repository.editor").MapTo(&Repository.Editor); err != nil {
  963. log.Fatal(4, "Failed to map Repository.Editor settings: %v", err)
  964. } else if err = Cfg.Section("repository.upload").MapTo(&Repository.Upload); err != nil {
  965. log.Fatal(4, "Failed to map Repository.Upload settings: %v", err)
  966. } else if err = Cfg.Section("repository.local").MapTo(&Repository.Local); err != nil {
  967. log.Fatal(4, "Failed to map Repository.Local settings: %v", err)
  968. } else if err = Cfg.Section("repository.pull-request").MapTo(&Repository.PullRequest); err != nil {
  969. log.Fatal(4, "Failed to map Repository.PullRequest settings: %v", err)
  970. }
  971. if !filepath.IsAbs(Repository.Upload.TempPath) {
  972. Repository.Upload.TempPath = path.Join(AppWorkPath, Repository.Upload.TempPath)
  973. }
  974. sec = Cfg.Section("picture")
  975. AvatarUploadPath = sec.Key("AVATAR_UPLOAD_PATH").MustString(path.Join(AppDataPath, "avatars"))
  976. forcePathSeparator(AvatarUploadPath)
  977. if !filepath.IsAbs(AvatarUploadPath) {
  978. AvatarUploadPath = path.Join(AppWorkPath, AvatarUploadPath)
  979. }
  980. AvatarMaxWidth = sec.Key("AVATAR_MAX_WIDTH").MustInt(4096)
  981. AvatarMaxHeight = sec.Key("AVATAR_MAX_HEIGHT").MustInt(3072)
  982. switch source := sec.Key("GRAVATAR_SOURCE").MustString("gravatar"); source {
  983. case "duoshuo":
  984. GravatarSource = "http://gravatar.duoshuo.com/avatar/"
  985. case "gravatar":
  986. GravatarSource = "https://secure.gravatar.com/avatar/"
  987. case "libravatar":
  988. GravatarSource = "https://seccdn.libravatar.org/avatar/"
  989. default:
  990. GravatarSource = source
  991. }
  992. DisableGravatar = sec.Key("DISABLE_GRAVATAR").MustBool()
  993. EnableFederatedAvatar = sec.Key("ENABLE_FEDERATED_AVATAR").MustBool(!InstallLock)
  994. if OfflineMode {
  995. DisableGravatar = true
  996. EnableFederatedAvatar = false
  997. }
  998. if DisableGravatar {
  999. EnableFederatedAvatar = false
  1000. }
  1001. if EnableFederatedAvatar || !DisableGravatar {
  1002. GravatarSourceURL, err = url.Parse(GravatarSource)
  1003. if err != nil {
  1004. log.Fatal(4, "Failed to parse Gravatar URL(%s): %v",
  1005. GravatarSource, err)
  1006. }
  1007. }
  1008. if EnableFederatedAvatar {
  1009. LibravatarService = libravatar.New()
  1010. if GravatarSourceURL.Scheme == "https" {
  1011. LibravatarService.SetUseHTTPS(true)
  1012. LibravatarService.SetSecureFallbackHost(GravatarSourceURL.Host)
  1013. } else {
  1014. LibravatarService.SetUseHTTPS(false)
  1015. LibravatarService.SetFallbackHost(GravatarSourceURL.Host)
  1016. }
  1017. }
  1018. if err = Cfg.Section("ui").MapTo(&UI); err != nil {
  1019. log.Fatal(4, "Failed to map UI settings: %v", err)
  1020. } else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil {
  1021. log.Fatal(4, "Failed to map Markdown settings: %v", err)
  1022. } else if err = Cfg.Section("admin").MapTo(&Admin); err != nil {
  1023. log.Fatal(4, "Fail to map Admin settings: %v", err)
  1024. } else if err = Cfg.Section("cron").MapTo(&Cron); err != nil {
  1025. log.Fatal(4, "Failed to map Cron settings: %v", err)
  1026. } else if err = Cfg.Section("git").MapTo(&Git); err != nil {
  1027. log.Fatal(4, "Failed to map Git settings: %v", err)
  1028. } else if err = Cfg.Section("api").MapTo(&API); err != nil {
  1029. log.Fatal(4, "Failed to map API settings: %v", err)
  1030. } else if err = Cfg.Section("metrics").MapTo(&Metrics); err != nil {
  1031. log.Fatal(4, "Failed to map Metrics settings: %v", err)
  1032. }
  1033. sec = Cfg.Section("mirror")
  1034. Mirror.MinInterval = sec.Key("MIN_INTERVAL").MustDuration(10 * time.Minute)
  1035. Mirror.DefaultInterval = sec.Key("DEFAULT_INTERVAL").MustDuration(8 * time.Hour)
  1036. if Mirror.MinInterval.Minutes() < 1 {
  1037. log.Warn("Mirror.MinInterval is too low")
  1038. Mirror.MinInterval = 1 * time.Minute
  1039. }
  1040. if Mirror.DefaultInterval < Mirror.MinInterval {
  1041. log.Warn("Mirror.DefaultInterval is less than Mirror.MinInterval")
  1042. Mirror.DefaultInterval = time.Hour * 8
  1043. }
  1044. Langs = Cfg.Section("i18n").Key("LANGS").Strings(",")
  1045. if len(Langs) == 0 {
  1046. Langs = []string{
  1047. "en-US", "zh-CN", "zh-HK", "zh-TW", "de-DE", "fr-FR", "nl-NL", "lv-LV",
  1048. "ru-RU", "uk-UA", "ja-JP", "es-ES", "pt-BR", "pl-PL", "bg-BG", "it-IT",
  1049. "fi-FI", "tr-TR", "cs-CZ", "sr-SP", "sv-SE", "ko-KR"}
  1050. }
  1051. Names = Cfg.Section("i18n").Key("NAMES").Strings(",")
  1052. if len(Names) == 0 {
  1053. Names = []string{"English", "简体中文", "繁體中文(香港)", "繁體中文(台灣)", "Deutsch",
  1054. "français", "Nederlands", "latviešu", "русский", "Українська", "日本語",
  1055. "español", "português do Brasil", "polski", "български", "italiano",
  1056. "suomi", "Türkçe", "čeština", "српски", "svenska", "한국어"}
  1057. }
  1058. dateLangs = Cfg.Section("i18n.datelang").KeysHash()
  1059. ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool(false)
  1060. ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool(true)
  1061. ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
  1062. UI.ShowUserEmail = Cfg.Section("ui").Key("SHOW_USER_EMAIL").MustBool(true)
  1063. HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
  1064. extensionReg := regexp.MustCompile(`\.\w`)
  1065. for _, sec := range Cfg.Section("markup").ChildSections() {
  1066. name := strings.TrimPrefix(sec.Name(), "markup.")
  1067. if name == "" {
  1068. log.Warn("name is empty, markup " + sec.Name() + "ignored")
  1069. continue
  1070. }
  1071. extensions := sec.Key("FILE_EXTENSIONS").Strings(",")
  1072. var exts = make([]string, 0, len(extensions))
  1073. for _, extension := range extensions {
  1074. if !extensionReg.MatchString(extension) {
  1075. log.Warn(sec.Name() + " file extension " + extension + " is invalid. Extension ignored")
  1076. } else {
  1077. exts = append(exts, extension)
  1078. }
  1079. }
  1080. if len(exts) == 0 {
  1081. log.Warn(sec.Name() + " file extension is empty, markup " + name + " ignored")
  1082. continue
  1083. }
  1084. command := sec.Key("RENDER_COMMAND").MustString("")
  1085. if command == "" {
  1086. log.Warn(" RENDER_COMMAND is empty, markup " + name + " ignored")
  1087. continue
  1088. }
  1089. ExternalMarkupParsers = append(ExternalMarkupParsers, MarkupParser{
  1090. Enabled: sec.Key("ENABLED").MustBool(false),
  1091. MarkupName: name,
  1092. FileExtensions: exts,
  1093. Command: command,
  1094. IsInputFile: sec.Key("IS_INPUT_FILE").MustBool(false),
  1095. })
  1096. }
  1097. sec = Cfg.Section("U2F")
  1098. U2F.TrustedFacets, _ = shellquote.Split(sec.Key("TRUSTED_FACETS").MustString(strings.TrimRight(AppURL, "/")))
  1099. U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimRight(AppURL, "/"))
  1100. binVersion, err := git.BinVersion()
  1101. if err != nil {
  1102. log.Fatal(4, "Error retrieving git version: %v", err)
  1103. }
  1104. if version.Compare(binVersion, "2.9", ">=") {
  1105. // Explicitly disable credential helper, otherwise Git credentials might leak
  1106. git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "credential.helper=")
  1107. }
  1108. }
  1109. // Service settings
  1110. var Service struct {
  1111. ActiveCodeLives int
  1112. ResetPwdCodeLives int
  1113. RegisterEmailConfirm bool
  1114. EmailDomainWhitelist []string
  1115. DisableRegistration bool
  1116. AllowOnlyExternalRegistration bool
  1117. ShowRegistrationButton bool
  1118. RequireSignInView bool
  1119. EnableNotifyMail bool
  1120. EnableReverseProxyAuth bool
  1121. EnableReverseProxyAutoRegister bool
  1122. EnableReverseProxyEmail bool
  1123. EnableCaptcha bool
  1124. CaptchaType string
  1125. RecaptchaSecret string
  1126. RecaptchaSitekey string
  1127. DefaultKeepEmailPrivate bool
  1128. DefaultAllowCreateOrganization bool
  1129. EnableTimetracking bool
  1130. DefaultEnableTimetracking bool
  1131. DefaultEnableDependencies bool
  1132. DefaultAllowOnlyContributorsToTrackTime bool
  1133. NoReplyAddress string
  1134. EnableUserHeatmap bool
  1135. AutoWatchNewRepos bool
  1136. // OpenID settings
  1137. EnableOpenIDSignIn bool
  1138. EnableOpenIDSignUp bool
  1139. OpenIDWhitelist []*regexp.Regexp
  1140. OpenIDBlacklist []*regexp.Regexp
  1141. }
  1142. func newService() {
  1143. sec := Cfg.Section("service")
  1144. Service.ActiveCodeLives = sec.Key("ACTIVE_CODE_LIVE_MINUTES").MustInt(180)
  1145. Service.ResetPwdCodeLives = sec.Key("RESET_PASSWD_CODE_LIVE_MINUTES").MustInt(180)
  1146. Service.DisableRegistration = sec.Key("DISABLE_REGISTRATION").MustBool()
  1147. Service.AllowOnlyExternalRegistration = sec.Key("ALLOW_ONLY_EXTERNAL_REGISTRATION").MustBool()
  1148. Service.EmailDomainWhitelist = sec.Key("EMAIL_DOMAIN_WHITELIST").Strings(",")
  1149. Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration))
  1150. Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
  1151. Service.EnableReverseProxyAuth = sec.Key("ENABLE_REVERSE_PROXY_AUTHENTICATION").MustBool()
  1152. Service.EnableReverseProxyAutoRegister = sec.Key("ENABLE_REVERSE_PROXY_AUTO_REGISTRATION").MustBool()
  1153. Service.EnableReverseProxyEmail = sec.Key("ENABLE_REVERSE_PROXY_EMAIL").MustBool()
  1154. Service.EnableCaptcha = sec.Key("ENABLE_CAPTCHA").MustBool(false)
  1155. Service.CaptchaType = sec.Key("CAPTCHA_TYPE").MustString(ImageCaptcha)
  1156. Service.RecaptchaSecret = sec.Key("RECAPTCHA_SECRET").MustString("")
  1157. Service.RecaptchaSitekey = sec.Key("RECAPTCHA_SITEKEY").MustString("")
  1158. Service.DefaultKeepEmailPrivate = sec.Key("DEFAULT_KEEP_EMAIL_PRIVATE").MustBool()
  1159. Service.DefaultAllowCreateOrganization = sec.Key("DEFAULT_ALLOW_CREATE_ORGANIZATION").MustBool(true)
  1160. Service.EnableTimetracking = sec.Key("ENABLE_TIMETRACKING").MustBool(true)
  1161. if Service.EnableTimetracking {
  1162. Service.DefaultEnableTimetracking = sec.Key("DEFAULT_ENABLE_TIMETRACKING").MustBool(true)
  1163. }
  1164. Service.DefaultEnableDependencies = sec.Key("DEFAULT_ENABLE_DEPENDENCIES").MustBool(true)
  1165. Service.DefaultAllowOnlyContributorsToTrackTime = sec.Key("DEFAULT_ALLOW_ONLY_CONTRIBUTORS_TO_TRACK_TIME").MustBool(true)
  1166. Service.NoReplyAddress = sec.Key("NO_REPLY_ADDRESS").MustString("noreply.example.org")
  1167. Service.EnableUserHeatmap = sec.Key("ENABLE_USER_HEATMAP").MustBool(true)
  1168. Service.AutoWatchNewRepos = sec.Key("AUTO_WATCH_NEW_REPOS").MustBool(true)
  1169. sec = Cfg.Section("openid")
  1170. Service.EnableOpenIDSignIn = sec.Key("ENABLE_OPENID_SIGNIN").MustBool(!InstallLock)
  1171. Service.EnableOpenIDSignUp = sec.Key("ENABLE_OPENID_SIGNUP").MustBool(!Service.DisableRegistration && Service.EnableOpenIDSignIn)
  1172. pats := sec.Key("WHITELISTED_URIS").Strings(" ")
  1173. if len(pats) != 0 {
  1174. Service.OpenIDWhitelist = make([]*regexp.Regexp, len(pats))
  1175. for i, p := range pats {
  1176. Service.OpenIDWhitelist[i] = regexp.MustCompilePOSIX(p)
  1177. }
  1178. }
  1179. pats = sec.Key("BLACKLISTED_URIS").Strings(" ")
  1180. if len(pats) != 0 {
  1181. Service.OpenIDBlacklist = make([]*regexp.Regexp, len(pats))
  1182. for i, p := range pats {
  1183. Service.OpenIDBlacklist[i] = regexp.MustCompilePOSIX(p)
  1184. }
  1185. }
  1186. }
  1187. var logLevels = map[string]string{
  1188. "Trace": "0",
  1189. "Debug": "1",
  1190. "Info": "2",
  1191. "Warn": "3",
  1192. "Error": "4",
  1193. "Critical": "5",
  1194. }
  1195. func getLogLevel(section string, key string, defaultValue string) string {
  1196. validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
  1197. return Cfg.Section(section).Key(key).In(defaultValue, validLevels)
  1198. }
  1199. func newLogService() {
  1200. log.Info("Gitea v%s%s", AppVer, AppBuiltWith)
  1201. LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
  1202. LogConfigs = make([]string, len(LogModes))
  1203. useConsole := false
  1204. for i := 0; i < len(LogModes); i++ {
  1205. LogModes[i] = strings.TrimSpace(LogModes[i])
  1206. if LogModes[i] == "console" {
  1207. useConsole = true
  1208. }
  1209. }
  1210. if !useConsole {
  1211. log.DelLogger("console")
  1212. }
  1213. for i, mode := range LogModes {
  1214. sec, err := Cfg.GetSection("log." + mode)
  1215. if err != nil {
  1216. sec, _ = Cfg.NewSection("log." + mode)
  1217. }
  1218. // Log level.
  1219. levelName := getLogLevel("log."+mode, "LEVEL", LogLevel)
  1220. level, ok := logLevels[levelName]
  1221. if !ok {
  1222. log.Fatal(4, "Unknown log level: %s", levelName)
  1223. }
  1224. // Generate log configuration.
  1225. switch mode {
  1226. case "console":
  1227. LogConfigs[i] = fmt.Sprintf(`{"level":%s}`, level)
  1228. case "file":
  1229. logPath := sec.Key("FILE_NAME").MustString(path.Join(LogRootPath, "gitea.log"))
  1230. if err = os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
  1231. panic(err.Error())
  1232. }
  1233. LogConfigs[i] = fmt.Sprintf(
  1234. `{"level":%s,"filename":"%s","rotate":%v,"maxsize":%d,"daily":%v,"maxdays":%d}`, level,
  1235. logPath,
  1236. sec.Key("LOG_ROTATE").MustBool(true),
  1237. 1<<uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28)),
  1238. sec.Key("DAILY_ROTATE").MustBool(true),
  1239. sec.Key("MAX_DAYS").MustInt(7))
  1240. case "conn":
  1241. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"reconnectOnMsg":%v,"reconnect":%v,"net":"%s","addr":"%s"}`, level,
  1242. sec.Key("RECONNECT_ON_MSG").MustBool(),
  1243. sec.Key("RECONNECT").MustBool(),
  1244. sec.Key("PROTOCOL").In("tcp", []string{"tcp", "unix", "udp"}),
  1245. sec.Key("ADDR").MustString(":7020"))
  1246. case "smtp":
  1247. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"username":"%s","password":"%s","host":"%s","sendTos":["%s"],"subject":"%s"}`, level,
  1248. sec.Key("USER").MustString("example@example.com"),
  1249. sec.Key("PASSWD").MustString("******"),
  1250. sec.Key("HOST").MustString("127.0.0.1:25"),
  1251. strings.Replace(sec.Key("RECEIVERS").MustString("example@example.com"), ",", "\",\"", -1),
  1252. sec.Key("SUBJECT").MustString("Diagnostic message from serve"))
  1253. case "database":
  1254. LogConfigs[i] = fmt.Sprintf(`{"level":%s,"driver":"%s","conn":"%s"}`, level,
  1255. sec.Key("DRIVER").String(),
  1256. sec.Key("CONN").String())
  1257. }
  1258. log.NewLogger(Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000), mode, LogConfigs[i])
  1259. log.Info("Log Mode: %s(%s)", strings.Title(mode), levelName)
  1260. }
  1261. }
  1262. // NewXORMLogService initializes xorm logger service
  1263. func NewXORMLogService(disableConsole bool) {
  1264. logModes := strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
  1265. var logConfigs string
  1266. for _, mode := range logModes {
  1267. mode = strings.TrimSpace(mode)
  1268. if disableConsole && mode == "console" {
  1269. continue
  1270. }
  1271. sec, err := Cfg.GetSection("log." + mode)
  1272. if err != nil {
  1273. sec, _ = Cfg.NewSection("log." + mode)
  1274. }
  1275. // Log level.
  1276. levelName := getLogLevel("log."+mode, "LEVEL", LogLevel)
  1277. level, ok := logLevels[levelName]
  1278. if !ok {
  1279. log.Fatal(4, "Unknown log level: %s", levelName)
  1280. }
  1281. // Generate log configuration.
  1282. switch mode {
  1283. case "console":
  1284. logConfigs = fmt.Sprintf(`{"level":%s}`, level)
  1285. case "file":
  1286. logPath := sec.Key("FILE_NAME").MustString(path.Join(LogRootPath, "xorm.log"))
  1287. if err = os.MkdirAll(path.Dir(logPath), os.ModePerm); err != nil {
  1288. panic(err.Error())
  1289. }
  1290. logPath = path.Join(filepath.Dir(logPath), "xorm.log")
  1291. logConfigs = fmt.Sprintf(
  1292. `{"level":%s,"filename":"%s","rotate":%v,"maxsize":%d,"daily":%v,"maxdays":%d}`, level,
  1293. logPath,
  1294. sec.Key("LOG_ROTATE").MustBool(true),
  1295. 1<<uint(sec.Key("MAX_SIZE_SHIFT").MustInt(28)),
  1296. sec.Key("DAILY_ROTATE").MustBool(true),
  1297. sec.Key("MAX_DAYS").MustInt(7))
  1298. case "conn":
  1299. logConfigs = fmt.Sprintf(`{"level":%s,"reconnectOnMsg":%v,"reconnect":%v,"net":"%s","addr":"%s"}`, level,
  1300. sec.Key("RECONNECT_ON_MSG").MustBool(),
  1301. sec.Key("RECONNECT").MustBool(),
  1302. sec.Key("PROTOCOL").In("tcp", []string{"tcp", "unix", "udp"}),
  1303. sec.Key("ADDR").MustString(":7020"))
  1304. case "smtp":
  1305. logConfigs = fmt.Sprintf(`{"level":%s,"username":"%s","password":"%s","host":"%s","sendTos":"%s","subject":"%s"}`, level,
  1306. sec.Key("USER").MustString("example@example.com"),
  1307. sec.Key("PASSWD").MustString("******"),
  1308. sec.Key("HOST").MustString("127.0.0.1:25"),
  1309. sec.Key("RECEIVERS").MustString("[]"),
  1310. sec.Key("SUBJECT").MustString("Diagnostic message from serve"))
  1311. case "database":
  1312. logConfigs = fmt.Sprintf(`{"level":%s,"driver":"%s","conn":"%s"}`, level,
  1313. sec.Key("DRIVER").String(),
  1314. sec.Key("CONN").String())
  1315. }
  1316. log.NewXORMLogger(Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000), mode, logConfigs)
  1317. if !disableConsole {
  1318. log.Info("XORM Log Mode: %s(%s)", strings.Title(mode), levelName)
  1319. }
  1320. var lvl core.LogLevel
  1321. switch levelName {
  1322. case "Trace", "Debug":
  1323. lvl = core.LOG_DEBUG
  1324. case "Info":
  1325. lvl = core.LOG_INFO
  1326. case "Warn":
  1327. lvl = core.LOG_WARNING
  1328. case "Error", "Critical":
  1329. lvl = core.LOG_ERR
  1330. }
  1331. log.XORMLogger.SetLevel(lvl)
  1332. }
  1333. if len(logConfigs) == 0 {
  1334. log.DiscardXORMLogger()
  1335. }
  1336. }
  1337. // Cache represents cache settings
  1338. type Cache struct {
  1339. Adapter string
  1340. Interval int
  1341. Conn string
  1342. TTL time.Duration
  1343. }
  1344. var (
  1345. // CacheService the global cache
  1346. CacheService *Cache
  1347. )
  1348. func newCacheService() {
  1349. sec := Cfg.Section("cache")
  1350. CacheService = &Cache{
  1351. Adapter: sec.Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache"}),
  1352. }
  1353. switch CacheService.Adapter {
  1354. case "memory":
  1355. CacheService.Interval = sec.Key("INTERVAL").MustInt(60)
  1356. case "redis", "memcache":
  1357. CacheService.Conn = strings.Trim(sec.Key("HOST").String(), "\" ")
  1358. default:
  1359. log.Fatal(4, "Unknown cache adapter: %s", CacheService.Adapter)
  1360. }
  1361. CacheService.TTL = sec.Key("ITEM_TTL").MustDuration(16 * time.Hour)
  1362. log.Info("Cache Service Enabled")
  1363. }
  1364. func newSessionService() {
  1365. SessionConfig.Provider = Cfg.Section("session").Key("PROVIDER").In("memory",
  1366. []string{"memory", "file", "redis", "mysql"})
  1367. SessionConfig.ProviderConfig = strings.Trim(Cfg.Section("session").Key("PROVIDER_CONFIG").MustString(path.Join(AppDataPath, "sessions")), "\" ")
  1368. if SessionConfig.Provider == "file" && !filepath.IsAbs(SessionConfig.ProviderConfig) {
  1369. SessionConfig.ProviderConfig = path.Join(AppWorkPath, SessionConfig.ProviderConfig)
  1370. }
  1371. SessionConfig.CookieName = Cfg.Section("session").Key("COOKIE_NAME").MustString("i_like_gitea")
  1372. SessionConfig.CookiePath = AppSubURL
  1373. SessionConfig.Secure = Cfg.Section("session").Key("COOKIE_SECURE").MustBool(false)
  1374. SessionConfig.Gclifetime = Cfg.Section("session").Key("GC_INTERVAL_TIME").MustInt64(86400)
  1375. SessionConfig.Maxlifetime = Cfg.Section("session").Key("SESSION_LIFE_TIME").MustInt64(86400)
  1376. log.Info("Session Service Enabled")
  1377. }
  1378. // Mailer represents mail service.
  1379. type Mailer struct {
  1380. // Mailer
  1381. QueueLength int
  1382. Name string
  1383. From string
  1384. FromName string
  1385. FromEmail string
  1386. SendAsPlainText bool
  1387. MailerType string
  1388. // SMTP sender
  1389. Host string
  1390. User, Passwd string
  1391. DisableHelo bool
  1392. HeloHostname string
  1393. SkipVerify bool
  1394. UseCertificate bool
  1395. CertFile, KeyFile string
  1396. IsTLSEnabled bool
  1397. // Sendmail sender
  1398. SendmailPath string
  1399. SendmailArgs []string
  1400. }
  1401. var (
  1402. // MailService the global mailer
  1403. MailService *Mailer
  1404. )
  1405. func newMailService() {
  1406. sec := Cfg.Section("mailer")
  1407. // Check mailer setting.
  1408. if !sec.Key("ENABLED").MustBool() {
  1409. return
  1410. }
  1411. MailService = &Mailer{
  1412. QueueLength: sec.Key("SEND_BUFFER_LEN").MustInt(100),
  1413. Name: sec.Key("NAME").MustString(AppName),
  1414. SendAsPlainText: sec.Key("SEND_AS_PLAIN_TEXT").MustBool(false),
  1415. MailerType: sec.Key("MAILER_TYPE").In("", []string{"smtp", "sendmail", "dummy"}),
  1416. Host: sec.Key("HOST").String(),
  1417. User: sec.Key("USER").String(),
  1418. Passwd: sec.Key("PASSWD").String(),
  1419. DisableHelo: sec.Key("DISABLE_HELO").MustBool(),
  1420. HeloHostname: sec.Key("HELO_HOSTNAME").String(),
  1421. SkipVerify: sec.Key("SKIP_VERIFY").MustBool(),
  1422. UseCertificate: sec.Key("USE_CERTIFICATE").MustBool(),
  1423. CertFile: sec.Key("CERT_FILE").String(),
  1424. KeyFile: sec.Key("KEY_FILE").String(),
  1425. IsTLSEnabled: sec.Key("IS_TLS_ENABLED").MustBool(),
  1426. SendmailPath: sec.Key("SENDMAIL_PATH").MustString("sendmail"),
  1427. }
  1428. MailService.From = sec.Key("FROM").MustString(MailService.User)
  1429. if sec.HasKey("ENABLE_HTML_ALTERNATIVE") {
  1430. log.Warn("ENABLE_HTML_ALTERNATIVE is deprecated, use SEND_AS_PLAIN_TEXT")
  1431. MailService.SendAsPlainText = !sec.Key("ENABLE_HTML_ALTERNATIVE").MustBool(false)
  1432. }
  1433. if sec.HasKey("USE_SENDMAIL") {
  1434. log.Warn("USE_SENDMAIL is deprecated, use MAILER_TYPE=sendmail")
  1435. if MailService.MailerType == "" && sec.Key("USE_SENDMAIL").MustBool(false) {
  1436. MailService.MailerType = "sendmail"
  1437. }
  1438. }
  1439. parsed, err := mail.ParseAddress(MailService.From)
  1440. if err != nil {
  1441. log.Fatal(4, "Invalid mailer.FROM (%s): %v", MailService.From, err)
  1442. }
  1443. MailService.FromName = parsed.Name
  1444. MailService.FromEmail = parsed.Address
  1445. if MailService.MailerType == "" {
  1446. MailService.MailerType = "smtp"
  1447. }
  1448. if MailService.MailerType == "sendmail" {
  1449. MailService.SendmailArgs, err = shellquote.Split(sec.Key("SENDMAIL_ARGS").String())
  1450. if err != nil {
  1451. log.Error(4, "Failed to parse Sendmail args: %v", CustomConf, err)
  1452. }
  1453. }
  1454. log.Info("Mail Service Enabled")
  1455. }
  1456. func newRegisterMailService() {
  1457. if !Cfg.Section("service").Key("REGISTER_EMAIL_CONFIRM").MustBool() {
  1458. return
  1459. } else if MailService == nil {
  1460. log.Warn("Register Mail Service: Mail Service is not enabled")
  1461. return
  1462. }
  1463. Service.RegisterEmailConfirm = true
  1464. log.Info("Register Mail Service Enabled")
  1465. }
  1466. func newNotifyMailService() {
  1467. if !Cfg.Section("service").Key("ENABLE_NOTIFY_MAIL").MustBool() {
  1468. return
  1469. } else if MailService == nil {
  1470. log.Warn("Notify Mail Service: Mail Service is not enabled")
  1471. return
  1472. }
  1473. Service.EnableNotifyMail = true
  1474. log.Info("Notify Mail Service Enabled")
  1475. }
  1476. func newWebhookService() {
  1477. sec := Cfg.Section("webhook")
  1478. Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000)
  1479. Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5)
  1480. Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool()
  1481. Webhook.Types = []string{"gitea", "gogs", "slack", "discord", "dingtalk"}
  1482. Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10)
  1483. }
  1484. // NewServices initializes the services
  1485. func NewServices() {
  1486. newService()
  1487. newLogService()
  1488. NewXORMLogService(false)
  1489. newCacheService()
  1490. newSessionService()
  1491. newMailService()
  1492. newRegisterMailService()
  1493. newNotifyMailService()
  1494. newWebhookService()
  1495. }