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