Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Jenkins 中文社区
Simplified Chinese Plugin
提交
ec85d56c
S
Simplified Chinese Plugin
项目概览
Jenkins 中文社区
/
Simplified Chinese Plugin
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Simplified Chinese Plugin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ec85d56c
编写于
5月 16, 2019
作者:
LinuxSuRen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support to setting community link for a user
上级
1c7e68d6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
107 addition
and
1 deletion
+107
-1
src/main/java/io/jenkins/plugins/localization_zh_cn/CommunityDecorator.java
...enkins/plugins/localization_zh_cn/CommunityDecorator.java
+28
-0
src/main/java/io/jenkins/plugins/localization_zh_cn/UserCommunityProperty.java
...ins/plugins/localization_zh_cn/UserCommunityProperty.java
+61
-0
src/main/resources/io/jenkins/plugins/localization_zh_cn/CommunityDecorator/footer.jelly
...lugins/localization_zh_cn/CommunityDecorator/footer.jelly
+1
-1
src/main/resources/io/jenkins/plugins/localization_zh_cn/UserCommunityProperty/config.jelly
...ins/localization_zh_cn/UserCommunityProperty/config.jelly
+17
-0
未找到文件。
src/main/java/io/jenkins/plugins/localization_zh_cn/CommunityDecorator.java
浏览文件 @
ec85d56c
...
@@ -2,6 +2,7 @@ package io.jenkins.plugins.localization_zh_cn;
...
@@ -2,6 +2,7 @@ package io.jenkins.plugins.localization_zh_cn;
import
hudson.Extension
;
import
hudson.Extension
;
import
hudson.model.PageDecorator
;
import
hudson.model.PageDecorator
;
import
hudson.model.User
;
import
org.kohsuke.stapler.Stapler
;
import
org.kohsuke.stapler.Stapler
;
import
org.kohsuke.stapler.StaplerRequest
;
import
org.kohsuke.stapler.StaplerRequest
;
...
@@ -23,4 +24,31 @@ public class CommunityDecorator extends PageDecorator {
...
@@ -23,4 +24,31 @@ public class CommunityDecorator extends PageDecorator {
return
false
;
return
false
;
}
}
public
boolean
showCommunityLink
()
{
boolean
isCurrentLanguage
=
isCurrentLanguage
();
User
user
=
User
.
current
();
if
(
user
==
null
)
{
return
isCurrentLanguage
;
}
UserCommunityProperty
communityProperty
=
user
.
getProperty
(
UserCommunityProperty
.
class
);
if
(
communityProperty
==
null
)
{
return
isCurrentLanguage
;
}
String
conditionName
=
communityProperty
.
getShowCondition
();
UserCommunityProperty
.
ShowConditions
condition
=
UserCommunityProperty
.
ShowConditions
.
valueOf
(
conditionName
);
switch
(
condition
)
{
case
Always:
return
true
;
case
Never:
return
false
;
case
Chinese:
return
isCurrentLanguage
;
}
return
isCurrentLanguage
;
}
}
}
src/main/java/io/jenkins/plugins/localization_zh_cn/UserCommunityProperty.java
0 → 100644
浏览文件 @
ec85d56c
package
io.jenkins.plugins.localization_zh_cn
;
import
hudson.Extension
;
import
hudson.model.User
;
import
hudson.model.UserProperty
;
import
hudson.model.UserPropertyDescriptor
;
import
org.kohsuke.stapler.DataBoundConstructor
;
import
org.kohsuke.stapler.DataBoundSetter
;
import
javax.annotation.Nonnull
;
public
class
UserCommunityProperty
extends
UserProperty
{
private
String
showCondition
;
@DataBoundConstructor
public
UserCommunityProperty
(){}
public
String
getShowCondition
()
{
return
showCondition
;
}
@DataBoundSetter
public
void
setShowCondition
(
String
showCondition
)
{
this
.
showCondition
=
showCondition
;
}
@Extension
public
static
final
class
DescriptorImpl
extends
UserPropertyDescriptor
{
@Override
public
UserProperty
newInstance
(
User
user
)
{
return
new
UserCommunityProperty
();
}
@Nonnull
@Override
public
String
getDisplayName
()
{
return
"Chinese Community"
;
}
}
public
ShowConditions
[]
getAllConditions
()
{
return
ShowConditions
.
values
();
}
public
String
getConditionDisplay
(
ShowConditions
conditions
)
{
return
conditions
.
getDisplay
();
}
enum
ShowConditions
{
Chinese
(
"Only in Chinese"
),
Always
(
"Always"
),
Never
(
"Never"
);
private
String
display
;
ShowConditions
(
String
display
)
{
this
.
display
=
display
;
}
public
String
getDisplay
()
{
return
display
;
}
}
}
src/main/resources/io/jenkins/plugins/localization_zh_cn/CommunityDecorator/footer.jelly
浏览文件 @
ec85d56c
<?jelly escape-by-default='true'?>
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:st="jelly:stapler">
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:st="jelly:stapler">
<j:if test="${it.
isCurrentLanguage
()}">
<j:if test="${it.
showCommunityLink
()}">
<span>
<span>
<a href="${rootURL}/chinese">Jenkins 中文社区</a>
<a href="${rootURL}/chinese">Jenkins 中文社区</a>
</span>
</span>
...
...
src/main/resources/io/jenkins/plugins/localization_zh_cn/UserCommunityProperty/config.jelly
0 → 100644
浏览文件 @
ec85d56c
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="${%Community Link}" field="showCondition">
<select name="showCondition">
<j:forEach var="condition" items="${instance.getAllConditions()}">
<j:choose>
<j:when test="${condition.name() == instance.showCondition}">
<option value="${condition.name()}" selected="true">${instance.getConditionDisplay(condition)}</option>
</j:when>
<j:otherwise>
<option value="${condition.name()}">${instance.getConditionDisplay(condition)}</option>
</j:otherwise>
</j:choose>
</j:forEach>
</select>
</f:entry>
</j:jelly>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录