### Start Yobi from Binary Installation Source: https://github.com/naver/yobi/blob/master/README.md Instructions to navigate to the Yobi installation directory and start the Yobi server. Includes commands for both Linux/macOS and Windows environments. ```Bash cd yobi-1.0.0 bin/yobi ``` ```Batch bin/yobi.bat ``` -------------------------------- ### Start Yobi from Source (Activator Console) Source: https://github.com/naver/yobi/blob/master/README.md Commands to start Yobi in production mode (`start`) or development mode (`run`) from within the Play Activator console after the build process is complete. ```Bash start ``` ```Bash run ``` -------------------------------- ### Configure Yobi Home and Configuration Paths Source: https://github.com/naver/yobi/blob/master/README.md Commands to start Yobi while specifying a custom home directory for data and explicitly defining paths for configuration and logger files using Java system properties. ```Bash bin/yobi -Dyobi.home=/home/user/.yobi ``` ```Bash bin/yobi -Dyobi.home=/home/user/.yobi -Dconfig.file=/home/user/.yobi/conf/application.conf -Dlogger.file=/home/user/.yobi/conf/application-logger.xml ``` -------------------------------- ### Configure Java Memory and Yobi Start Options Source: https://github.com/naver/yobi/blob/master/README.md Command to start Yobi with custom Java Virtual Machine (JVM) memory settings and specific Yobi startup parameters, such as enabling evolutions and setting the HTTP port, using the `_JAVA_OPTIONS` environment variable and Activator. ```Bash _JAVA_OPTIONS="-Xmx2048m -Xms2048m" activator "start -DapplyEvolutions.default=true -Dhttp.port=9000" ``` -------------------------------- ### Download and Unzip Yobi Binary Source: https://github.com/naver/yobi/blob/master/README.md Commands to download the Yobi binary package using wget and then extract its contents using unzip. ```Bash wget http://yobi.io/yobi.zip unzip yobi.zip ``` -------------------------------- ### Check Java Development Kit (JDK) Version Source: https://github.com/naver/yobi/blob/master/README.md Commands to verify the installed JDK version, ensuring it meets the requirement of JDK 7 (1.7) or 8 (1.8) for building Yobi from source. ```Bash java -version javac -version ``` -------------------------------- ### Navigate to Play Activator Directory Source: https://github.com/naver/yobi/blob/master/README.md Command to change the current working directory to the unzipped Play Activator folder. ```Bash cd activator-1.2.10-minimal ``` -------------------------------- ### Run Play Activator for Yobi Build Source: https://github.com/naver/yobi/blob/master/README.md Commands to execute the Play Activator from the Yobi source directory, initiating the build process and downloading necessary dependencies. Includes commands for both Linux/macOS and Windows. ```Bash ../activator ``` ```Batch ..\activator ``` -------------------------------- ### Download Yobi Source Code Source: https://github.com/naver/yobi/blob/master/README.md Command to clone the Yobi source code repository using Git. This is the recommended method for obtaining the source. ```Bash git clone https://github.com/naver/yobi.git ``` -------------------------------- ### Navigate to Yobi Source Directory Source: https://github.com/naver/yobi/blob/master/README.md Command to change the current working directory to the cloned Yobi source code folder. ```Bash cd yobi ``` -------------------------------- ### Download Play Activator for Yobi Source Build Source: https://github.com/naver/yobi/blob/master/README.md Commands to download the Play Activator, a build tool required for compiling Yobi from its source code, using either curl or wget. ```Bash curl -O http://downloads.typesafe.com/typesafe-activator/1.2.10/typesafe-activator-1.2.10-minimal.zip ``` ```Bash wget http://downloads.typesafe.com/typesafe-activator/1.2.10/typesafe-activator-1.2.10-minimal.zip ``` -------------------------------- ### Example Yobi Labels API Request with Query Parameters Source: https://github.com/naver/yobi/blob/master/docs/technical/label-typeahead.md Provides a complete example of an HTTP GET request to the `/labels` endpoint, demonstrating the use of `query`, `category`, and `limit` parameters to filter results. ```HTTP GET /labels?query=a&category=Language&limit=3 ``` -------------------------------- ### Unzip Play Activator Archive Source: https://github.com/naver/yobi/blob/master/README.md Command to extract the contents of the downloaded Play Activator ZIP archive. ```Bash unzip typesafe-activator-1.2.10-minimal.zip ``` -------------------------------- ### Upgrade Yobi using Git Pull Source: https://github.com/naver/yobi/blob/master/README.md Command to update the Yobi source code to the latest version using Git, applicable when Yobi was initially cloned via Git. An alternative is to manually download the latest master.zip. ```Bash git pull https://github.com/naver/yobi.git master ``` -------------------------------- ### Basic Highlight.js Initialization for Web Pages Source: https://github.com/naver/yobi/blob/master/public/javascripts/lib/highlight/README.md This snippet demonstrates the fundamental setup for Highlight.js on a web page. It involves linking the library and a stylesheet, then initializing highlighting for all `
` blocks upon page load.
```html
```
--------------------------------
### Highlight.js Usage in Node.js Environments
Source: https://github.com/naver/yobi/blob/master/public/javascripts/lib/highlight/README.md
This section outlines how to install Highlight.js via NPM for Node.js applications and provides examples for programmatically highlighting code. It covers both highlighting with a known language and automatic language detection.
```bash
npm install highlight.js
```
```python
python3 tools/build.py -tnode lang1 lang2 ..
```
```javascript
var hljs = require('highlight.js');
// If you know the language
hljs.highlight(lang, code).value;
// Automatic language detection
hljs.highlightAuto(code).value;
```
--------------------------------
### Markdown Headers Syntax
Source: https://github.com/naver/yobi/blob/master/app/views/help/markdown.scala.html
Demonstrates how to create different levels of headers using Markdown syntax. Examples for H1, H2, and H3 are provided, showing both the input syntax and the rendered output.
```Markdown Input
# This is an H1
## This is an H2
### This is an H3
```
```Markdown Output
# This is an H1 ## This is an H2 ### This is an H3
```
--------------------------------
### Example Content-Range Header in Yobi API Response
Source: https://github.com/naver/yobi/blob/master/docs/technical/label-typeahead.md
Illustrates a practical example of the `Content-Range` header, showing how it indicates the number of returned items out of the total available.
```HTTP
Content-Range: items 8/10
```
--------------------------------
### Configure NProgress Minimum Progress Value
Source: https://github.com/naver/yobi/blob/master/app/views/layout.scala.html
This JavaScript snippet configures the NProgress library, setting the minimum progress value to 0.6. This ensures the progress bar always starts at a visible point during page loading, improving user experience.
```JavaScript
NProgress.configure({ minimum: 0.6 });
```
--------------------------------
### Yobi Access Log Format Example
Source: https://github.com/naver/yobi/blob/master/docs/logging.md
Illustrates the Yobi access log format, which extends the Apache Combined Log Format by adding processing time at the end. Notes on specific field behaviors are also provided.
```Log Format
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] \"GET /apache_pb.gif\" 200\n- \"http://www.example.com/start.html\" \"Mozilla/4.08 [en] (Win98; I ;Nav)\"
70ms
```
--------------------------------
### Initialize New Git Repository and Connect to Yobi Project (Shell)
Source: https://github.com/naver/yobi/blob/master/app/views/code/nohead.scala.html
These shell commands guide users through initializing a new local Git repository and linking it to a Yobi project. The process involves creating a project directory, initializing Git, adding an initial README, committing changes, setting the remote origin to the Yobi project's URL, and pushing the local repository to the remote.
```Shell
mkdir @project.name
cd @project.name/
echo "# @project.name" > README.md
git init
git add README.md
git commit -m "Hello @utils.Config.getSiteName"
git remote add origin @getCodeURL(project)
git push origin master
```
--------------------------------
### Initialize Yobi UI Dropdown Components
Source: https://github.com/naver/yobi/blob/master/app/views/common/scripts.scala.html
Iterates through button groups with a `data-name` attribute and initializes `yobi.ui.Dropdown` instances for them, unless their activation is explicitly set to 'manual'. This automates the setup of interactive dropdown menus.
```JavaScript
var sActivation;
$(".btn-group\[data-name\]").each(function(i, el){
sActivation = $(el).attr("data-activate");
if(typeof sActivation == "undefined" || sActivation != "manual"){
(new yobi.ui.Dropdown({"elContainer":el}));
}
});
```
--------------------------------
### Java Imports for Play Framework Template
Source: https://github.com/naver/yobi/blob/master/app/views/git/partial_branch.scala.html
This snippet shows the necessary Java import statements for a Play Framework template, enabling access to `TemplateHelper` utilities and `URLEncoder` for URL manipulation.
```Java
@import utils.TemplateHelper._
@import java.net.URLEncoder
```
--------------------------------
### Yobi Authentication and Authorization Annotations Overview
Source: https://github.com/naver/yobi/blob/master/docs/ko/technical/validation-with-annotation.md
Lists the core annotations used in Yobi for authentication and authorization checks, applicable to `/loginId/projectName/**` URL patterns. The `application.context` setting in `conf/application.conf` is removed from the URL pattern before application.
```APIDOC
@IsOnlyGitAvailable
@IsCreatable
@IsAllowed
@With(AnonymousCheckAction.class)
@With(NullProjectCheckAction.class)
@With(DefaultProjectCheckAction.class)
```
--------------------------------
### Define Template Parameters in Scala Template
Source: https://github.com/naver/yobi/blob/master/app/views/layout.scala.html
This snippet defines the parameters expected by a Scala template, including a title (String), theme (String), and content (Html). These parameters are passed to the template for rendering dynamic content.
```Scala Template
@(title: String)(theme:String)(content: Html)
```
--------------------------------
### Play Framework Twirl Template for Page Layout and Messages
Source: https://github.com/naver/yobi/blob/master/app/views/error/internalServerError_default.scala.html
This snippet demonstrates how to define parameters for a Play Framework Twirl template, apply a site layout, and display localized messages. It shows the use of a default message key for error handling and linking to an application route for navigation.
```Scala
@(messageKey:String = "error.internalServerError")
@siteLayout(Messages(messageKey), utils.MenuType.SITE_HOME) {
@Messages(messageKey)
[@Messages("menu.home")](@routes.Application.index\(\))
}
```
--------------------------------
### Initialize Project Home JavaScript Module
Source: https://github.com/naver/yobi/blob/master/app/views/project/home.scala.html
This JavaScript snippet initializes the `project.Home` module upon document readiness. It passes various URLs for API endpoints related to project labels, general labels, label categories, and project overview updates, along with jQuery selectors for UI elements and the project ID, enabling dynamic client-side functionality.
```JavaScript
@common.markdown(project)
$(document).ready(function(){
$yobi.loadModule("project.Home", {
"sURLProjectLabels": "@routes.ProjectApp.labels(project.owner, project.name)",
"sURLLabels" : "@routes.LabelApp.labels()",
"sURLLabelCategories": "@routes.LabelApp.categories()",
"welLabelBoard": $('#label-board'),
"welLabelEditorToggle": $('#label-editor-toggle'),
"nProjectId" : "@project.id",
"sURLProject" : "@routes.ProjectApp.projectOverviewUpdate(project.owner, project.name)"
});
});
```
--------------------------------
### Initializing Project Member Module with jQuery
Source: https://github.com/naver/yobi/blob/master/app/views/project/members.scala.html
This JavaScript snippet uses jQuery's `$(document).ready()` function to ensure that the 'project.Member' module is loaded and initialized only after the entire DOM is ready. It passes a configuration object containing the URL for user data retrieval.
```JavaScript
$(document).ready(function(){ $yobi.loadModule("project.Member", { "sActionURL": "@routes.UserApp.users()" }); });
```
--------------------------------
### Toggle Introduction and Notification Learn More Functionality
Source: https://github.com/naver/yobi/blob/master/app/views/index/index.scala.html
This JavaScript snippet handles UI interactions on page load using jQuery. It allows toggling the visibility of an introduction section, persisting its state in local storage. It also implements a 'learn more' toggle for notification messages, expanding or collapsing their content and adjusting height based on user clicks, while preventing action on specific child elements.
```JavaScript
$(document).ready(function(){
$("#toggleIntro").click(function(){
$(".site-guide-outer").toggleClass("hide");
localStorage.setItem("yobi-intro", !$(".site-guide-outer").hasClass("hide"));
});
if(localStorage.getItem("yobi-intro") != "false"){
$(".site-guide-outer").removeClass("hide");
}
$('.notification-wrap').on('click','[data-toggle="learnmore"]',function(event) {
var sTargetId = $(this).data('target'),
welMessage = $('#'+sTargetId),
nHeight;
if(event.target.localName =='a' || event.target.localName =='img') {
return ;
}
welMessage.toggleClass('nowrap');
nHeight = (welMessage.hasClass('nowrap')) ? '' : $(welMessage).find('.message').height();
$(welMessage).css('min-height',nHeight);
});
});
```
--------------------------------
### Example: Migrating play.mvc.Action Return Type
Source: https://github.com/naver/yobi/blob/master/docs/ko/Play2.2_Migraion.md
This example illustrates how to adapt existing `play.mvc.Action` return statements from `Result` to `Promise` using `Promise.pure` in Play 2.2.
```Java
AS-IS: return forbidden();
TO-BE: return Promise.pure((SimpleResult) forbidden()));
```
--------------------------------
### APIDOC: @IsAllowed Parameters
Source: https://github.com/naver/yobi/blob/master/docs/ko/technical/validation-with-annotation.md
Parameters for the `@IsAllowed` annotation.
```APIDOC
value: Operation - The operation to check (e.g., READ, UPDATE).
resourceType: ResourceType - The type of resource for which permission is being checked. Defaults to PROJECT.
```
--------------------------------
### JavaScript Initialization for Yobi Issue List Page
Source: https://github.com/naver/yobi/blob/master/app/views/issue/list.scala.html
This JavaScript snippet executes on document ready, initializing the 'issue.List' module using '$yobi.loadModule'. It also configures a keyboard shortcut ('N') to navigate to the new issue creation form, dynamically generating the URL using Play Framework's route helper.
```JavaScript
$(function(){ // issue.List $yobi.loadModule("issue.List"); // ShortcutKey yobi.ShortcutKey.setKeymapLink({ "N": "@routes.IssueApp.newIssueForm(project.owner, project.name)" }); });
```
--------------------------------
### Initializing Yobi Board Write Module and User Mention Feature
Source: https://github.com/naver/yobi/blob/master/app/views/board/create.scala.html
This JavaScript snippet, executed on document ready, initializes the client-side 'board.Write' module for creating new posts. It configures the module with the target textarea for the editor and sets up the `yobi.Mention` plugin, providing the API endpoint for fetching mention suggestions.
```JavaScript
$(function(){
$yobi.loadModule("board.Write", {
"sMode" : "new",
"elTextarea": 'textarea\\[data-editor-mode=\"content-body\\\\]'
});
yobi.Mention({
"target": 'textarea\\[id^=editor-\\\]',
"url" : "@Html(routes.ProjectApp.mentionList(project.owner, project.name).toString())"
});
});
```
--------------------------------
### APIDOC: @IsCreatable Parameters
Source: https://github.com/naver/yobi/blob/master/docs/ko/technical/validation-with-annotation.md
Parameters for the `@IsCreatable` annotation.
```APIDOC
value: ResourceType - The type of resource for which creation permission is being checked.
```
--------------------------------
### Markdown Blockquotes Syntax
Source: https://github.com/naver/yobi/blob/master/app/views/help/markdown.scala.html
Explains how to create blockquotes using the '>' character, including examples for multi-line and multi-paragraph blockquotes.
```Markdown Input
> Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
>
> Aenean commodo ligula eget dolor.
```
```Markdown Output
> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. > > Aenean commodo ligula eget dolor.
```
--------------------------------
### Yobi Labels API Endpoint Definition
Source: https://github.com/naver/yobi/blob/master/docs/technical/label-typeahead.md
Defines the primary HTTP GET endpoint for accessing project labels within the Yobi API.
```APIDOC
GET /labels
```
--------------------------------
### Java: Check Project Existence with NullProjectCheckAction
Source: https://github.com/naver/yobi/blob/master/docs/ko/technical/validation-with-annotation.md
This annotation verifies if a project corresponding to the URL pattern exists. Responds with 403 Forbidden if the project is not found.
```Java
@With(NullProjectCheckAction.class)
public static Result enroll(String loginId, String projectName) {
// 코드 생략
}
```
--------------------------------
### Java: Check for Anonymous User with AnonymousCheckAction
Source: https://github.com/naver/yobi/blob/master/docs/ko/technical/validation-with-annotation.md
This annotation verifies if the current request is from an anonymous user. If so, it displays an alert window and redirects to the login form.
```Java
@With(AnonymousCheckAction.class)
public static Result userIssues(String state, String format, int pageNum) {
// 코드 생략
}
```
--------------------------------
### Initialize Yobi Script Path and Document Ready Handlers
Source: https://github.com/naver/yobi/blob/master/app/views/common/scripts.scala.html
Sets the base path for Yobi scripts and encapsulates various client-side initializations within the jQuery `document.ready` function. This ensures that UI components and event handlers are set up after the DOM is fully loaded.
```JavaScript
$yobi.setScriptPath("@getJSPath");
$(document).ready(function(){
// tooltip
$(document.body).on("mouseenter", "\[data-toggle=tooltip\]", function(){
$(this).tooltip("show");
});
// jquery.placeholder plugin initiator
$('input\[type=text\], textarea').placeholder();
// current language set!
if (typeof window.moment == "function" && typeof window.moment.lang == "function") {
moment.lang("@implicitJavaLang.language");
}
// yobi.Dropdown
var sActivation;
$(".btn-group\[data-name\]").each(function(i, el){
sActivation = $(el).attr("data-activate");
if(typeof sActivation == "undefined" || sActivation != "manual"){
(new yobi.ui.Dropdown({"elContainer":el}));
}
});
// yobi.ShortcutKey
// Set CTRL+ENTER as submit form on INPUT/TEXTAREA
yobi.ShortcutKey.attach("CTRL+ENTER", function(htInfo){
if(htInfo.bFormInput){
$(htInfo.welTarget.parents("form").get(0)).submit();
}
});
@requestHeader.session.get("loginId") match {
case Some(v) => {
yobi.ShortcutKey.setKeymapLink({
"P": "@routes.UserApp.userInfo(v)"
});
}
case None => {
}
}
// yobi.Files
yobi.Files.init({
"sListURL" : "@routes.AttachmentApp.getFileList()",
"sUploadURL": "@routes.AttachmentApp.uploadFile()"
});
// ajax for issue link detail(ui.IssuePreview)
$(document).on("mouseenter", ".issueLink", function(){
var welTarget = $(this);
welTarget.tooltip({
"title": "@Messages("site.massMail.loading")",
"placement": "right"
}).tooltip("show");
$.getJSON(welTarget.attr("href"), function(htData){
if(welTarget.tooltip){
welTarget.tooltip("hide");
}
welTarget.popover({
"title" : htData.title.replace('<', '<'),
"content" : $yobi.xssClean(htData.body),
"html" : true,
"placement": "right",
"trigger" : "hover"
}).popover("show");
});
});
$(document).on("mouseleave", ".issueLink", function(){
var welTarget = $(this);
welTarget.tooltip("destroy");
welTarget.popover("hide");
});
if(navigator.userAgent.match(/MSIE (\[0-9\])\\./)){
$('.unsupported').show();
}
// notify flash messages
@for(key <- Context.current().flash().keySet) {
@if(key != utils.Constants.TITLE && key != utils.Constants.DESCRIPTION){
$yobi.notify("@Messages(Context.current().flash().get(key))", 3000);
}
@if(key == utils.Constants.TITLE){
$yobi.alert("@Messages(Context.current().flash().get(key))", null, "@Messages(Context.current().flash().get(utils.Constants.DESCRIPTION))");
}
}
$('\\[data-toggle="search-scope"\\]').on('click', function() {
$('form\\[name="gnb-search-form"\\]').attr('action', $(this).data('action'));
$('#gnb-search-scope-title').text($(this).text());
});
yobi.OriginalMessage.hide($("\\[data-via-email\\]"));
});
```
--------------------------------
### Example Yobi Labels API JSON Response
Source: https://github.com/naver/yobi/blob/master/docs/technical/label-typeahead.md
Shows a typical JSON array response containing project labels that match the specified request conditions.
```JSON
["@Formula","A# (Axiom)","A# .NET"]
```
--------------------------------
### Clone SVN Repository and Perform Initial Commit
Source: https://github.com/naver/yobi/blob/master/app/views/code/nohead_svn.scala.html
This shell script demonstrates how to clone an SVN repository associated with a Yobi project, navigate into the project directory, create a README.md file, add it to the repository, and commit it as the first revision. It utilizes dynamic values for the repository URL, username, and project name, which are resolved by the Yobi application.
```Shell
svn co @CodeApp.getURL(project) --username @UserApp.currentUser().loginId
cd @project.name/
echo "# @project.name" > README.md
svn add README.md
svn commit -m "first commit"
```
--------------------------------
### APIDOC: @IsAllowed Supported Resource Types
Source: https://github.com/naver/yobi/blob/master/docs/ko/technical/validation-with-annotation.md
Lists the `ResourceType` values currently supported by the `@IsAllowed` annotation. Additional types require modification to the `Resource.getResourceObject` method.
```APIDOC
PROJECT
MILESTONE
BOARD_POST
ISSUE_POST
ISSUE_LAVEL
PULL_REQUEST
COMMIT_COMMENT
```
--------------------------------
### Clone an Existing Yobi Project Git Repository (Shell)
Source: https://github.com/naver/yobi/blob/master/app/views/code/nohead.scala.html
This sequence of shell commands demonstrates how to clone an existing Git repository from a Yobi project. It includes steps to navigate into the new directory, create a basic README file, commit it, and push the initial changes to the remote 'master' branch. The `@getCodeURL(project)` placeholder will be replaced with the actual repository URL.
```Shell
git clone @getCodeURL(project)
cd @project.name/
echo "# @project.name" > README.md
git add README.md
git commit -m "Hello @utils.Config.getSiteName"
git push origin master
```
--------------------------------
### Initialize Yobi Board List Pagination and Shortcuts with jQuery
Source: https://github.com/naver/yobi/blob/master/app/views/board/list.scala.html
This JavaScript snippet, executed on document ready, initializes the board list page's client-side functionalities. It uses '$yobi.loadModule' to set up pagination based on the total page count and dynamically configures keyboard shortcuts for actions like creating a new post, conditional on project settings. It includes embedded Play Framework template syntax for dynamic values.
```JavaScript
$(document).ready(function() { $yobi.loadModule("board.List", { "elPagination": $('#pagination'), "nTotalPages" : @page.getTotalPageCount }); @if(project.menuSetting.board) { yobi.ShortcutKey.setKeymapLink({ "N": "@routes.BoardApp.newPostForm(project.owner, project.name)" }); } });
```
--------------------------------
### Initialize Yobi File Management Module
Source: https://github.com/naver/yobi/blob/master/app/views/common/scripts.scala.html
Initializes the `yobi.Files` module with URLs for listing and uploading files. This sets up the client-side components responsible for handling file attachments and uploads within the application.
```JavaScript
yobi.Files.init({
"sListURL" : "@routes.AttachmentApp.getFileList()",
"sUploadURL": "@routes.AttachmentApp.uploadFile()"
});
```
--------------------------------
### Initialize User Settings Module with jQuery
Source: https://github.com/naver/yobi/blob/master/app/views/user/edit_notifications.scala.html
This JavaScript snippet uses jQuery's `$(function(){...})` shorthand to ensure the code executes only after the DOM is fully loaded. It then calls `$yobi.loadModule("user.Setting")` to initialize a specific client-side module responsible for user account settings functionalities.
```JavaScript
$(function(){ $yobi.loadModule("user.Setting"); });
```
--------------------------------
### Configure Tab Replacement in Highlight.js
Source: https://github.com/naver/yobi/blob/master/public/javascripts/lib/highlight/README.md
This configuration example demonstrates how to customize the handling of TAB characters within code blocks. Tabs can be replaced with a fixed number of spaces or a custom `` element for specific styling, applied before highlighting.
```html
```
--------------------------------
### Play Framework Template Parameter Declaration
Source: https://github.com/naver/yobi/blob/master/app/views/git/partial_branch.scala.html
This snippet declares the `pull` variable as an instance of `PullRequest` within the Play Framework template, making pull request data accessible for rendering.
```Play Framework Template
@(pull: PullRequest)
```
--------------------------------
### Render Project Layout and Code Navigation Menu
Source: https://github.com/naver/yobi/blob/master/app/views/code/diff.scala.html
This section utilizes the `projectLayout` helper to set up the page's overall structure and includes a `projectMenu` for navigation within the code section. It dynamically generates links for files, commits, and branches based on the project type.
```Scala
@projectLayout(Messages("code.commits") + " @" + commit.getId, project, utils.MenuType.CODE) {
@projectMenu(project, utils.MenuType.CODE, "main-menu-only")
* [@Messages("code.files")](@routes.CodeApp.codeBrowser(project.owner, project.name))
* [@Messages("code.commits")](@routes.CodeHistoryApp.historyUntilHead(project.owner, project.name))
@if(project.isGit()) {* [@Messages("title.branches")](@routes.BranchApp.branches(project.owner, project.name))
}
```
--------------------------------
### Initialize Yobi User Signup Module (JavaScript)
Source: https://github.com/naver/yobi/blob/master/app/views/user/signup.scala.html
This JavaScript snippet initializes the `user.SignUp` module provided by Yobi when the document is ready. It configures the module with URLs for checking if a user ID or email is already in use, facilitating client-side validation during the signup process.
```JavaScript
$(document).ready(function() { $yobi.loadModule("user.SignUp", { "sLogindIdCheckUrl" : "@routes.UserApp.isUsed("")", "sEmailCheckUrl" : "@routes.UserApp.isEmailExist("")" }); });
```
--------------------------------
### Explicitly Setting Language for Highlight.js
Source: https://github.com/naver/yobi/blob/master/public/javascripts/lib/highlight/README.md
This example demonstrates how to explicitly define the language for a code block by assigning a class to the `` or `` element. This approach is recommended when Highlight.js's autodetection might fail, especially for short code fragments.
```html
...
```
--------------------------------
### Client-Side JavaScript Initialization for Board Post View
Source: https://github.com/naver/yobi/blob/master/app/views/board/view.scala.html
Initializes client-side functionalities for the board post view using jQuery. It loads the 'board.View' module with watch/unwatch URLs, sets up keyboard shortcuts for navigation and actions (list, new post, edit), and configures the mention feature for textareas.
```JavaScript
$(document).ready(function(){
$yobi.loadModule("board.View", {
"sWatchUrl" : "@routes.WatchApp.watch(post.asResource.asParameter)",
"sUnwatchUrl": "@routes.WatchApp.unwatch(post.asResource.asParameter)"
});
// yobi.ShortcutKey
yobi.ShortcutKey.setKeymapLink({
"L": "@urlToPostings"
@if(project.menuSetting.board) {
,"N": "@routes.BoardApp.newPostForm(project.owner, project.name)"
}
@if(isAllowed(UserApp.currentUser(), post.asResource(), Operation.UPDATE)){
,"E": "@routes.BoardApp.editPostForm(project.owner, project.name, post.getNumber)"
}
});
// yobi.Mention
yobi.Mention({
"target": "textarea[id^=editor-]",
"url" : "@Html(routes.ProjectApp.mentionList(project.owner, project.name, post.getNumber, post.asResource().getType.resource()).toString())"
});
});
```
--------------------------------
### Render Yobi User Signup Form (Play Framework Template)
Source: https://github.com/naver/yobi/blob/master/app/views/user/signup.scala.html
This Play Framework template snippet renders the user signup form, including fields for ID, name, email, password, and re-typing password. It uses `Messages` for internationalization and `routes` for linking to the login form. The `siteLayout` helper is used for the overall page structure.
```Play Framework Template
@Html(Messages("title.signupFor", utils.Config.getSiteName))
============================================================
@Messages("app.description")
@Messages("user.signupId")
@Messages("user.name")
@Messages("user.email")
@Messages("user.password")
@Messages("validation.retypePassword")
@Messages("user.signupBtn")
@Messages("user.isAlreadySignupUser") [@Messages("title.login")](@routes.UserApp.loginForm\(\))
```
--------------------------------
### Generate Project Navigation Links in Play Framework Template
Source: https://github.com/naver/yobi/blob/master/app/views/project/partial_settingmenu.scala.html
This Scala Play Framework template snippet demonstrates how to generate a list of navigation links for various project-related actions such as settings, members, issue labels, transfer, delete, and VCS changes. It utilizes `@Messages` for localization and `@routes` to dynamically generate URLs based on the project owner and name.
```Scala
* [@Messages("project.setting")](@routes.ProjectApp.settingForm\(project.owner, project.name\))
* [@Messages("project.member")@if(project.enrolledUsers.size>0){@project.enrolledUsers.size}](@routes.ProjectApp.members\(project.owner, project.name\))
* [@Messages("issue.label")](@routes.IssueLabelApp.labelsForm\(project.owner, project.name\))
* [@Messages("project.transfer")](@routes.ProjectApp.transferForm\(project.owner, project.name\))
* [@Messages("project.delete")](@routes.ProjectApp.deleteForm\(project.owner, project.name\))
* [@Messages("project.changeVCS")](@routes.ProjectApp.changeVCS\(project.owner, project.name\))
```
--------------------------------
### Define Github Username Validation Rules
Source: https://github.com/naver/yobi/blob/master/docs/technical/name-validation.md
Github usernames are restricted to alphanumeric characters and dashes. A key constraint is that usernames are not allowed to start with a dash. This rule ensures consistency and prevents potential parsing issues within the Github platform.
```Specification
Github usernames: Allowed: alphanumeric, dash. Constraint: cannot start with dash.
```
--------------------------------
### Loading Project Fork JavaScript Module
Source: https://github.com/naver/yobi/blob/master/app/views/git/fork.scala.html
This JavaScript snippet ensures that the 'project.Fork' module is loaded and initialized once the DOM is fully ready. It utilizes jQuery's `$(document).ready()` function to execute the `$yobi.loadModule()` utility, which is responsible for dynamically loading Yobi-specific modules.
```JavaScript
$(document).ready(function() { $yobi.loadModule("project.Fork"); });
```
--------------------------------
### Output Concatenated Strings in Scala Play Framework Template
Source: https://github.com/naver/yobi/blob/master/app/views/partial_diff_line.scala.html
This snippet demonstrates direct concatenation and output of template parameters `prefix` and `content`. The `@` symbol is used to embed Scala expressions directly into the template output.
```Scala
@prefix@content
```
--------------------------------
### Map Keyboard Shortcuts for Project Navigation (JavaScript)
Source: https://github.com/naver/yobi/blob/master/app/views/projectMenu.scala.html
This JavaScript code defines a 'htKeyMap' object that maps keyboard keys to project navigation URLs. It dynamically adds mappings based on project menu settings (e.g., 'B' for Board, 'C' for Code) and user roles ('Q' for Admin settings if the user is a 'manager'). This map is then passed to a global Yobi module for client-side navigation.
```JavaScript
$(document).ready(function(){ var htKeyMap = { "H": "@routes.ProjectApp.project(project.owner, project.name)" @if(project.menuSetting.board) { ,"B": "@routes.BoardApp.posts(project.owner, project.name)" } @if(project.menuSetting.code) { ,"C": "@routes.CodeApp.codeBrowser(project.owner, project.name)" } @if(project.menuSetting.issue) { ,"I": "@routes.IssueApp.issues(project.owner, project.name,\"open\")" } @if(project.menuSetting.milestone) { ,"M": "@routes.MilestoneApp.milestones(project.owner, project.name)" } @if(project.menuSetting.pullRequest && project.vcs.equals("GIT")){ ,"F": "@getPullRequestURL(project)" } @requestHeader.session.get("loginId") match { case Some(role) if role.equals("manager") => { "Q": "@routes.ProjectApp.settingForm(project.owner, project.name)" } case _ => { } } }; $yobi.loadModule("project.Global", { "htKeyMap": htKeyMap, "sRepoURL": "@CodeApp.getURLWithLoginId(project)" }); });
```
--------------------------------
### Displaying Localized Messages in Twirl
Source: https://github.com/naver/yobi/blob/master/app/views/project/partial_issuelabels_editlabel.scala.html
These Twirl template snippets demonstrate how to display localized messages using the `Messages` helper. It retrieves the messages associated with the keys 'button.save' and 'button.cancel', which is a standard approach for internationalization in web applications.
```Twirl
@Messages("button.save")
@Messages("button.cancel")
```
--------------------------------
### Load Project Setting Module with jQuery
Source: https://github.com/naver/yobi/blob/master/app/views/project/setting.scala.html
Initializes the client-side 'project.Setting' module using the Yobi `$yobi.loadModule` function once the DOM is ready, typically for handling form submissions or dynamic UI elements on the project settings page.
```JavaScript
$(document).ready(function(){
$yobi.loadModule("project.Setting");
});
```
--------------------------------
### Format History 'How' with Title and Action Links (Play Template)
Source: https://github.com/naver/yobi/blob/master/app/views/project/partial_history.scala.html
Formats the 'how' part of a history entry, typically describing the action performed. It includes both a short title and the action description, each linked to the history item's URL.
```Play Framework Template
@makeHistoryHow(history:History) = {[@history.getShortTitle](@history.getUrl) [@history.getHow](@history.getUrl) }
```
--------------------------------
### Define Template Parameters in Scala Play Framework
Source: https://github.com/naver/yobi/blob/master/app/views/partial_diff_line.scala.html
This snippet defines the input parameters for a Scala Play Framework template, including types for string, integer, and boolean values. These parameters are used to pass data into the template for rendering.
```Scala
@(klass: String, prefix: String, num: Integer, numA: Integer, numB: Integer, content: String, isEndOfLineMissing: Boolean = false)
```
--------------------------------
### Java: Check Project Existence and Read Permissions with DefaultProjectCheckAction
Source: https://github.com/naver/yobi/blob/master/docs/ko/technical/validation-with-annotation.md
This annotation verifies if a project corresponding to the URL pattern exists and if the current user has read access. Responds with 403 Forbidden if the project is not found or the user lacks read permission.
```Java
@With(DefaultProjectCheckAction.class)
public static Result editIssue(String ownerName, String projectName, Long number) {
// 코드 생략
}
```
--------------------------------
### Project Layout and Menu Inclusion
Source: https://github.com/naver/yobi/blob/master/app/views/code/view.scala.html
This Play template snippet sets up the overall page layout for the project, specifically for the code section. It uses the `projectLayout` helper to define the main structure and includes a `projectMenu` for navigation.
```Play Template
@projectLayout(Messages("menu.code"), project, utils.MenuType.CODE){
@projectMenu(project, utils.MenuType.CODE, "main-menu-only")
}
```
--------------------------------
### Get User Avatar URL from History Object (Play Template)
Source: https://github.com/naver/yobi/blob/master/app/views/project/partial_history.scala.html
A helper function that retrieves the user's avatar URL from a `History` object. If `getUserAvatarUrl` is null, it defaults to a placeholder image path provided by `routes.Assets.at`.
```Play Framework Template
@userAvatarUrlOnHistory(history:History) = @{ if(history.getUserAvatarUrl != null){ history.getUserAvatarUrl } else { routes.Assets.at("images/default-avatar-64.png") } }
```
--------------------------------
### Define and Render a Basic Page Layout in Play Framework
Source: https://github.com/naver/yobi/blob/master/app/views/siteLayout.scala.html
This snippet defines a standard page layout template in Play Framework, accepting a title, menu type, and HTML content. It imports utility functions and renders a common navigation bar, the provided content, and a common footer, ensuring consistent page structure across the application.
```Scala
@(title: String, menuType:utils.MenuType)(content: Html)
@import utils._
@layout(Messages(title))("") {
@common.navbar(menuType, null, null)
@content
@common.footer()
}
```
--------------------------------
### Import Utility Class in Scala Play Framework Template
Source: https://github.com/naver/yobi/blob/master/app/views/partial_diff_line.scala.html
This snippet demonstrates how to import a utility class, `DiffRenderer`, within a Scala Play Framework template. Imports allow templates to access helper functions and objects from other parts of the application.
```Scala
@import utils.TemplateHelper.DiffRenderer._
```
--------------------------------
### Conditionally Render HTML in Scala Play Framework Template
Source: https://github.com/naver/yobi/blob/master/app/views/partial_diff_line.scala.html
This snippet uses an `if` condition to conditionally render an `Html` object, `noNewlineAtEof`, based on the `isEndOfLineMissing` boolean parameter. This is useful for controlling output formatting, such as handling missing newlines at the end of a file.
```Scala
@if(isEndOfLineMissing){@Html(noNewlineAtEof)}
```
--------------------------------
### Safely Access Optional Values in Scala Play Framework Template
Source: https://github.com/naver/yobi/blob/master/app/views/partial_diff_line.scala.html
These snippets show how to safely access optional integer values (`numA`, `numB`) using `Option.getOrElse("")`. If the option is `None`, an empty string is used, preventing `NoSuchElementException`.
```Scala
@Option(numA).getOrElse("")
@Option(numB).getOrElse("")
```
--------------------------------
### Play Template Page Parameters and Imports
Source: https://github.com/naver/yobi/blob/master/app/views/code/partial_view_folder.scala.html
This snippet defines the parameters passed to the Play Framework template, including `Project` object, `JsonNode` for files, branch name, and list path. It also includes necessary imports for `utils.TemplateHelper.CodeBrowser._` and `java.net.URLEncoder`.
```Scala
@(project:Project, files:com.fasterxml.jackson.databind.JsonNode, branch:String, listPath:String) @import utils.TemplateHelper.CodeBrowser._ @import java.net.URLEncoder
```
--------------------------------
### Initialize Yobi Site Mass Mail Module (JavaScript)
Source: https://github.com/naver/yobi/blob/master/app/views/site/massMail.scala.html
This JavaScript snippet initializes the 'site.MassMail' module within the Yobi application. It uses jQuery's $(document).ready() to ensure the script runs after the DOM is loaded. The module is configured with URLs for mail lists and project lists, which are dynamically generated by Play Framework routes.
```JavaScript
$(document).ready(function(){ $yobi.loadModule("site.MassMail", { "sURLMailList": "@routes.SiteApp.mailList()", "sURLProjects": "@routes.ProjectApp.projects()" }); });
```
--------------------------------
### Get User Page URL from History Object (Play Template)
Source: https://github.com/naver/yobi/blob/master/app/views/project/partial_history.scala.html
A helper function that returns the user's page URL from a `History` object. If `getUserPageUrl` is not null, it returns the URL; otherwise, it returns '#'. This ensures a valid link is always provided.
```Play Framework Template
@userPageUrlOnHistory(history:History) = @{ if(history.getUserPageUrl != null) { history.getUserPageUrl } else { "#" } }
```
--------------------------------
### Conditionally Render Content for Site Administrators
Source: https://github.com/naver/yobi/blob/master/app/views/layout.scala.html
This template snippet demonstrates conditional rendering based on whether the current user is a site administrator. If the user is an administrator, it displays two localized messages using the 'Messages' helper, providing specific content for privileged users.
```Scala Template
@if(UserApp.isSiteAdminLoggedInSession){
@Messages("user.siteAdminLoggedInAffix") @Messages("user.siteAdminLoggedInAffix.maxim")
}
```
--------------------------------
### Play Framework Template Definition and Imports
Source: https://github.com/naver/yobi/blob/master/app/views/project/setting.scala.html
Defines the parameters passed to the Play template and imports necessary helper libraries for rendering the project settings page.
```Scala
@(message: String)(projectForm: play.data.Form[Project], project: Project, branches: List[String])
@import helper._
@import utils.TemplateHelper._
@import utils.TemplateHelper.Branches._
```
--------------------------------
### Play Framework Template Message and Route Helpers
Source: https://github.com/naver/yobi/blob/master/app/views/common/loginDialog.scala.html
These snippets illustrate the use of Play Framework's @Messages helper for internationalization and @routes helper for generating URLs within HTML templates, commonly found in the Yobi project's views.
```Play Framework Template
@Messages("user.login.key")
```
```Play Framework Template
@Messages("user.password")
```
```Play Framework Template
@Messages("button.login")
```
```Play Framework Template
@Messages("title.rememberMe")
```
```Play Framework Template
[@Messages("title.resetPassword")](@routes.PasswordResetApp.lostPassword())
```
```Play Framework Template
[@Messages("title.signup")](@routes.UserApp.signupForm)
```
--------------------------------
### Load Yobi Client-Side Module with Project Context
Source: https://github.com/naver/yobi/blob/master/app/views/code/nohead_svn.scala.html
This JavaScript snippet shows how to load a specific Yobi client-side module, 'code.Nohead', after the DOM is fully loaded. It passes the current project's name as a configuration parameter to the module, allowing the module to access project-specific data or context.
```JavaScript
$(document).ready(function(){
$yobi.loadModule("code.Nohead", { "sProjectName": "@project.name" });
});
```
--------------------------------
### Get Menu Type based on Target in Scala Play
Source: https://github.com/naver/yobi/blob/master/app/views/error/notfound.scala.html
This function maps a given target string (e.g., 'issue_post', 'board_post') to a corresponding utils.MenuType enum value, used for navigation within the Yobi project. It handles various target types and provides a default for unknown types.
```Scala
@getMenuType(target:String) = @{
target match {
case "issue_post" => utils.MenuType.ISSUE
case "board_post" => utils.MenuType.BOARD
case "milestone" => utils.MenuType.MILESTONE
case _ => utils.MenuType.PROJECT_HOME
}
}
```
--------------------------------
### JavaScript: Initialize Review List Module
Source: https://github.com/naver/yobi/blob/master/app/views/reviewthread/list.scala.html
This JavaScript snippet initializes the 'review.List' module using Yobi's custom module loader. It passes configuration options including the pagination element, total page count, and the search form element.
```JavaScript
$(function(){
$yobi.loadModule("review.List", {
"elPagination": $("#pagination"),
"nTotalPages" : @page.getTotalPageCount(),
"welSearchForm": $("form[name='search']")
});
});
```
--------------------------------
### Define Rules for Email Address Local-Part
Source: https://github.com/naver/yobi/blob/master/docs/technical/name-validation.md
According to RFC 5322, an email address consists of a local-part and a domain. Specifically, the 'dot-atom-text' rule dictates that the local-part cannot start or end with a period ('.'). This prevents malformed email addresses like '.foo@mail.com' or 'foo.@mail.com' while allowing 'foo.bar@mail.com'.
```Specification
addr-spec = local-part "@" domain
```
--------------------------------
### Define Basic Template Layout with Message Parameter
Source: https://github.com/naver/yobi/blob/master/app/views/site/setting.scala.html
This snippet illustrates a template definition that accepts a `message` parameter of type `String`. It then invokes a `siteMngLayout` component or function, passing the `message` to it. The `TODO` placeholder indicates that the layout's content is pending implementation.
```Template
@(message: String) @siteMngLayout(message) { TODO }
```
--------------------------------
### JavaScript for Yobi Issue Detail Page Initialization
Source: https://github.com/naver/yobi/blob/master/app/views/issue/view.scala.html
This JavaScript code initializes client-side functionalities for the issue detail page. It loads the 'yobi.issue.View' module with issue-specific data and URLs, configures keyboard shortcuts for navigation and actions (like editing), and sets up the 'yobi.Mention' feature for textareas.
```JavaScript
$(function(){
// yobi.issue.View
$yobi.loadModule("issue.View", {
"issueId" : "@issue.id",
"nextState": "@issue.nextState().toString.toLowerCase",
"urls" : {
"watch" : "@routes.WatchApp.watch(issue.asResource.asParameter)",
"unwatch" : "@routes.WatchApp.unwatch(issue.asResource.asParameter)",
"timeline" : "@routes.IssueApp.timeline(project.owner, project.name, issue.getNumber)",
"nextState" : "@routes.IssueApp.nextState(project.owner, project.name, issue.getNumber)",
"massUpdate": "@routes.IssueApp.massUpdate(project.owner, project.name)"
}
});
// yobi.ShortcutKey
yobi.ShortcutKey.setKeymapLink({
"L": "@urlToIssues"
@if(project.menuSetting.issue) {
,"N": "@routes.IssueApp.newIssueForm(project.owner, project.name)"
}
@if(isAllowed(UserApp.currentUser(), issue.asResource(), Operation.UPDATE)) {
,"E": "@routes.IssueApp.editIssueForm(project.owner, project.name, issue.getNumber)"
}
});
// yobi.Mention
yobi.Mention({
"target": 'textarea\\[id\\^=editor-\\]',
"url" : "@Html(routes.ProjectApp.mentionList(project.owner, project.name, issue.getNumber, issue.asResource().getType.resource()).toString())"
});
});
```
--------------------------------
### Java: Check Specific Resource Operation Permission with IsAllowed
Source: https://github.com/naver/yobi/blob/master/docs/ko/technical/validation-with-annotation.md
Extends `DefaultProjectCheckAction` by verifying if the current user has a specific operation permission on a given resource type. Returns 403 Forbidden if the project is missing, read permission is denied, or the user is not allowed to perform the specified operation on the resource.
```Java
@IsAllowed(Operation.READ)
public static Result issues(String ownerName, String projectName, String state, String format, int pageNum) throws WriteException, IOException {
// 코드 생략
}
```
```Java
@IsAllowed(value = Operation.UPDATE, resourceType = ResourceType.BOARD_POST)
public static Result editPostForm(String owner, String projectName, Long number) {
// 코드 생략
}
```
--------------------------------
### Manage Project Enrollment for Guest Users
Source: https://github.com/naver/yobi/blob/master/app/views/project/header.scala.html
This section handles the display and actions for guest users regarding project enrollment. It checks if the user is a guest and then whether they have already enrolled or are prompted to enroll, providing appropriate messages and action buttons.
```Scala
@if(ProjectUser.isGuest(project, UserApp.currentUser)) {* @if(User.enrolled(project)) {
@Messages("project.you.want.to.be.a.member", project)
@Messages("project.member.enrollment.help")
[@Messages("button.cancel.enrollment")](@routes.EnrollProjectApp.cancelEnroll(project.owner, project.name))
} else {
@Messages("project.you.may.want.to.be.a.member", project)
@Messages("project.member.enrollment.will.help")
[@Messages("button.new.enrollment")](@routes.EnrollProjectApp.enroll(project.owner, project.name))
}
}
```
--------------------------------
### Java: Check Resource Creation Permission with IsCreatable
Source: https://github.com/naver/yobi/blob/master/docs/ko/technical/validation-with-annotation.md
Extends `DefaultProjectCheckAction` by verifying if the current user can create a specific resource type within the project. Returns 403 Forbidden if the project is missing, read permission is denied, or the user lacks creation rights for the specified resource type.
```Java
@IsCreatable(ResourceType.BOARD_POST)
public static Result newPostForm(String userName, String projectName) {
// 코드 생략
}
```
--------------------------------
### Load Organization Setting Module with jQuery
Source: https://github.com/naver/yobi/blob/master/app/views/organization/setting.scala.html
This JavaScript snippet uses jQuery's document ready function to ensure the DOM is fully loaded before executing. It then calls `$yobi.loadModule("organization.Setting")`, which is a custom function to dynamically load and initialize the client-side module responsible for the organization settings page's interactive features.
```JavaScript
$(function() { $yobi.loadModule("organization.Setting") })
```