diff --git a/doc/activity.md b/doc/activity.md index bc49240..7c45dfb 100644 --- a/doc/activity.md +++ b/doc/activity.md @@ -1,3 +1,5 @@ +Activity Timeline +======== GitBucket records several types of user activity to ```ACTIVITY``` table. Activity types are shown below: type | message | additional information diff --git a/doc/auto_update.md b/doc/auto_update.md index f5c80b7..83aa711 100644 --- a/doc/auto_update.md +++ b/doc/auto_update.md @@ -1,5 +1,5 @@ -# Automatic Schema Updating - +Automatic Schema Updating +======== GitBucket uses H2 database to manage project and account data. GitBucket updates database schema automatically in the first run after the upgrading. To release a new version of GitBucket, add the version definition to the [servlet.AutoUpdate](https://github.com/takezoe/gitbucket/blob/master/src/main/scala/servlet/AutoUpdateListener.scala) at first. diff --git a/doc/comment_action.md b/doc/comment_action.md index fa99f8c..d5f2d39 100644 --- a/doc/comment_action.md +++ b/doc/comment_action.md @@ -1,5 +1,5 @@ -# About Action in Issue Comment - +About Action in Issue Comment +======== After the issue creation at GitBucket, users can add comments or close it. The details are saved at ```ISSUE_COMMENT``` table. diff --git a/doc/directory.md b/doc/directory.md index a18040d..27b4990 100644 --- a/doc/directory.md +++ b/doc/directory.md @@ -1,5 +1,5 @@ -# Directory Structure - +Directory Structure +======== GitBucket persists all data into __HOME/.gitbucket__ in default (In 1.9 or before, HOME/gitbucket is default). This directory has following structure: diff --git a/doc/how_to_run.md b/doc/how_to_run.md index 42536e3..bb14bbc 100644 --- a/doc/how_to_run.md +++ b/doc/how_to_run.md @@ -1,4 +1,5 @@ -# How to run from the source tree +How to run from the source tree +======== for Testers -------- diff --git a/doc/mapping_and_validation.md b/doc/mapping_and_validation.md deleted file mode 100644 index bf66dab..0000000 --- a/doc/mapping_and_validation.md +++ /dev/null @@ -1,71 +0,0 @@ -# Mapping and Validation - -GitBucket uses [scalatra-forms](https://github.com/takezoe/scalatra-forms) to validate request parameters and map them to the scala object. This is inspired by Play2 form mapping / validation. - -At first, define the mapping as following: - -```scala -import jp.sf.amateras.scalatra.forms._ - -case class RegisterForm(name: String, description: String) - -val form = mapping( - "name" -> text(required, maxlength(40)), - "description" -> text() -)(RegisterForm.apply) -``` - -The servlet have to mixed in ```jp.sf.amateras.scalatra.forms.ClientSideValidationFormSupport``` to validate request parameters and take mapped object. It validates request parameters before action. If any errors are detected, it throws an exception. - -```scala -class RegisterServlet extends ScalatraServlet with ClientSideValidationFormSupport { - post("/register", form) { form: RegisterForm => - ... - } -} -``` - -In the view template, you can add client-side validation by adding ```validate="true"``` to your form. Error messages are set to ```span#error-```. - -```html -
- Name: - -
- Description: - -
- -
-``` - -Client-side validation calls ```/validate``` to validate form contents. It returns a validation result as JSON. In this case, form action is ```/register```, so ```/register/validate``` is called before submitting a form. ```ClientSideValidationFormSupport``` adds this JSON API automatically. - -For Ajax request, you have to use '''ajaxGet''' or '''ajaxPost''' to define action. It almost same as '''get''' or '''post'''. You can implement actions which handle Ajax request as same as normal actions. -Small difference is they return validation errors as JSON. - -```scala -ajaxPost("/register", form){ form => - ... -} -``` - -You can call these actions using jQuery as below: - -```javascript -$('#register').click(function(e){ - $.ajax($(this).attr('action'), { - type: 'POST', - data: { - name: $('#name').val(), - mail: $('#mail').val() - } - }) - .done(function(data){ - $('#result').text('Registered!'); - }) - .fail(function(data, status){ - displayErrors($.parseJSON(data.responseText)); - }); -}); -``` diff --git a/doc/notification.md b/doc/notification.md index b2f6ace..90a88bb 100644 --- a/doc/notification.md +++ b/doc/notification.md @@ -1,4 +1,5 @@ -# Notification Email +Notification Email +======== GitBucket sends email to target users by enabling the notification email by an administrator. diff --git a/doc/readme.md b/doc/readme.md index 354d702..c895727 100644 --- a/doc/readme.md +++ b/doc/readme.md @@ -1,10 +1,10 @@ -# Developer's Guide - +Developer's Guide +======== * [How to run from source tree](how_to_run.md) * [Directory Structure](directory.md) - * [Mapping and Validation](mapping_and_validation.md) - * [Authentication in Controller](authentication.md) - * [About Action in Issue Comment](comment_actionb.md) + * [Mapping and Validation](validation.md) + * Authentication in Controller (not yet) + * [About Action in Issue Comment](comment_action.md) * [Activity Types](activity.md) * [Notification Email](notification.md) * [Automatic Schema Updating](auto_update.md) diff --git a/doc/validation.md b/doc/validation.md new file mode 100644 index 0000000..69160fb --- /dev/null +++ b/doc/validation.md @@ -0,0 +1,71 @@ +Mapping and Validation +======== +GitBucket uses [scalatra-forms](https://github.com/takezoe/scalatra-forms) to validate request parameters and map them to the scala object. This is inspired by Play2 form mapping / validation. + +At first, define the mapping as following: + +```scala +import jp.sf.amateras.scalatra.forms._ + +case class RegisterForm(name: String, description: String) + +val form = mapping( + "name" -> text(required, maxlength(40)), + "description" -> text() +)(RegisterForm.apply) +``` + +The servlet have to mixed in ```jp.sf.amateras.scalatra.forms.ClientSideValidationFormSupport``` to validate request parameters and take mapped object. It validates request parameters before action. If any errors are detected, it throws an exception. + +```scala +class RegisterServlet extends ScalatraServlet with ClientSideValidationFormSupport { + post("/register", form) { form: RegisterForm => + ... + } +} +``` + +In the view template, you can add client-side validation by adding ```validate="true"``` to your form. Error messages are set to ```span#error-```. + +```html +
+ Name: + +
+ Description: + +
+ +
+``` + +Client-side validation calls ```/validate``` to validate form contents. It returns a validation result as JSON. In this case, form action is ```/register```, so ```/register/validate``` is called before submitting a form. ```ClientSideValidationFormSupport``` adds this JSON API automatically. + +For Ajax request, you have to use '''ajaxGet''' or '''ajaxPost''' to define action. It almost same as '''get''' or '''post'''. You can implement actions which handle Ajax request as same as normal actions. +Small difference is they return validation errors as JSON. + +```scala +ajaxPost("/register", form){ form => + ... +} +``` + +You can call these actions using jQuery as below: + +```javascript +$('#register').click(function(e){ + $.ajax($(this).attr('action'), { + type: 'POST', + data: { + name: $('#name').val(), + mail: $('#mail').val() + } + }) + .done(function(data){ + $('#result').text('Registered!'); + }) + .fail(function(data, status){ + displayErrors($.parseJSON(data.responseText)); + }); +}); +```