Skip to content

Commit

Permalink
Merge pull request #15 from SIkebe/release/v1.2.0
Browse files Browse the repository at this point in the history
v1.2.0
  • Loading branch information
SIkebe authored Dec 26, 2020
2 parents e0b6cd6 + 657da9c commit 1efac9a
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 58 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
end_of_line = lf

[*.md]
trim_trailing_whitespace = false
23 changes: 23 additions & 0 deletions .github/workflows/scala.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Scala CI

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-18.04
strategy:
matrix:
java: [8, 11, 15]

steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: Run Docker containers
run: docker-compose up -d

- name: Build
run: sbt scalafmtSbtCheck scalafmtCheck
19 changes: 13 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,32 @@
*.log
*~

# sbt specific
# sbt
dist/*
target/
lib_managed/
src_managed/
project/boot/
project/plugins/project/

# Scala-IDE specific
# Scala-IDE
.scala_dependencies
.classpath
.project
.cache
.settings

# IntelliJ specific
# IntelliJ
.idea/
.idea_modules/

# Ensime
.ensime
.ensime_cache/
# Metals
.metals
.bloop
**/metals.sbt

# Visual Studio Code
.vscode

# Docker
docker
22 changes: 11 additions & 11 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
project.git = true
version = 2.0.0
maxColumn = 120
docstrings = JavaDoc

align.tokens = ["%", "%%", {code = "=>", owner = "Case"}]
align.openParenCallSite = false
align.openParenDefnSite = false
continuationIndent.callSite = 2
continuationIndent.defnSite = 2
danglingParentheses = true
project.git = true
version = 2.4.2
maxColumn = 120
docstrings = JavaDoc

align.tokens = ["%", "%%", {code = "=>", owner = "Case"}]
align.openParenCallSite = false
align.openParenDefnSite = false
continuationIndent.callSite = 2
continuationIndent.defnSite = 2
danglingParentheses = true
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2018
Copyright (c) 2018

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
45 changes: 30 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
# gitbucket-navlink-plugin
GitBucket plugin which adds a link to navigation bar

![NavLink settings](images/navlink.gif)

## Compatibility

Plugin version | GitBucket version
:--------------|:--------------------
1.1.X | 4.32.0 -
1.0.1         | 4.23.1 - 4.31.2

## Build from source

Run `sbt assembly` and copy generated `/target/scala-2.13/gitbucket-navlink-plugin-X.X.X.jar` to `~/.gitbucket/plugins/` (If the directory does not exist, create it by hand before copying the jar), or just run `sbt install`.
# gitbucket-navlink-plugin ![Scala CI](https://github.com/SIkebe/gitbucket-navlink-plugin/workflows/Scala%20CI/badge.svg)
GitBucket plugin which adds a link to navigation bar

![NavLink settings](images/navlink.gif)

## Compatibility

Plugin version | GitBucket version
:--------------|:--------------------
1.2.X | 4.35.0 -
1.1.X | 4.32.0 - 4.34.0
1.0.1         | 4.23.1 - 4.31.2

## Development

```bash
# Initialize GitBucket and PostgreSQL containers
docker-compose up -d

# Setup GITBUCKET_HOME
# export GITBUCKET_HOME=/home/sikebe/git/github/gitbucket-navlink-plugin/docker
export GITBUCKET_HOME=<path-to-repository>/docker

# Build and copy assembly to GITBUCKET_HOME/plugins/
sbt install
```

## Build and deploy

Run `sbt assembly` and copy generated `/target/scala-2.13/gitbucket-navlink-plugin-X.X.X.jar` to `GITBUCKET_HOME/plugins/`.
12 changes: 6 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "gitbucket-navlink-plugin"
organization := "com.github.sikebe"
version := "1.1.0"
scalaVersion := "2.13.0"
gitbucketVersion := "4.32.0"
scalacOptions := Seq("-deprecation")
name := "gitbucket-navlink-plugin"
organization := "com.github.sikebe"
version := "1.2.0"
scalaVersion := "2.13.3"
gitbucketVersion := "4.35.0"
scalacOptions := Seq("-deprecation")
30 changes: 30 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: '3.8'

services:
gitbucket:
image: gitbucket/gitbucket:4
restart: always
ports:
- 8080:8080
volumes:
- ./docker:/gitbucket
depends_on:
- db
environment:
- GITBUCKET_DB_URL=jdbc:postgresql://db/gitbucket
- GITBUCKET_DB_USER=gitbucket
- GITBUCKET_DB_PASSWORD=gitbucket
- GITBUCKET_BASE_URL=http://localhost:8080
- GITBUCKET_HOME=./gitbucket
command: bash -c 'while !</dev/tcp/db/5432; do sleep 1; done; sleep 10; java -jar /opt/gitbucket.war'

db:
image: postgres:13.1-alpine
restart: always
ports:
- "5432:5432"
environment:
- POSTGRES_DB=gitbucket
- POSTGRES_USER=gitbucket
- POSTGRES_PASSWORD=gitbucket
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --locale=C
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 1.2.8
sbt.version = 1.4.4
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
addSbtPlugin("io.github.gitbucket" % "sbt-gitbucket-plugin" % "1.5.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.3")
addSbtPlugin("io.github.gitbucket" % "sbt-gitbucket-plugin" % "1.5.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2")
12 changes: 5 additions & 7 deletions src/main/scala/Plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,18 @@ class Plugin extends gitbucket.core.plugin.Plugin with NavLinkSettingsService {
override val versions: List[Version] = List(
new Version("1.0.0"),
new Version("1.0.1"),
new Version("1.1.0")
new Version("1.1.0"),
new Version("1.2.0")
)

override val controllers = Seq(
"/*" -> new NavLinkSettingsController()
)

override val globalMenus = Seq(
(_: Context) => Some(Link("navlink", navLinkSettings.globalMenuName, navLinkSettings.globalMenuPath))
)
override val globalMenus =
Seq((_: Context) => Some(Link("navlink", navLinkSettings.globalMenuName, navLinkSettings.globalMenuPath)))

override val systemSettingMenus = Seq(
(_: Context) => Some(Link("navlink", "NavLink", "navlink/settings"))
)
override val systemSettingMenus = Seq((_: Context) => Some(Link("navlink", "NavLink", "navlink/settings")))

val navLinkSettings = loadNavLinkSettings()
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait NavLinkSettingsControllerBase extends ControllerBase {

saveNavLinkSettings(form)
reload(request.getServletContext(), loadSystemSettings(), request2Session(request).conn)
flash += "info" -> "Successfully updated NavLink."
flash.update("info", "Successfully updated NavLink.")
redirect("/navlink/settings")
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.io.File
import gitbucket.core.util.Directory._
import gitbucket.core.util.SyntaxSugars._
import NavLinkSettingsService._
import scala.util.Using

trait NavLinkSettingsService {

Expand All @@ -14,17 +15,13 @@ trait NavLinkSettingsService {
defining(new java.util.Properties()) { props =>
props.setProperty(GlobalMenuName, settings.globalMenuName)
props.setProperty(GlobalMenuPath, settings.globalMenuPath)
using(new java.io.FileOutputStream(NavLinkConf)) { out =>
props.store(out, null)
}
Using.resource(new java.io.FileOutputStream(NavLinkConf)) { out => props.store(out, null) }
}

def loadNavLinkSettings(): NavLinkSettings =
defining(new java.util.Properties()) { props =>
if (NavLinkConf.exists) {
using(new java.io.FileInputStream(NavLinkConf)) { in =>
props.load(in)
}
Using.resource(new java.io.FileInputStream(NavLinkConf)) { in => props.load(in) }
}
NavLinkSettings(
getValue[String](props, GlobalMenuName, ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
</form>
</div>
</div>
}}
}}
2 changes: 1 addition & 1 deletion src/main/twirl/sikebe/gitbucket/navlink/sidebar.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
</ul>
</div>
</div>
@body
@body

0 comments on commit 1efac9a

Please sign in to comment.