Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gitbucket/gitbucket-pages-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.8.0
Choose a base ref
...
head repository: gitbucket/gitbucket-pages-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jul 5, 2020

  1. Copy the full SHA
    ba1eb16 View commit details
  2. Update CI build badge

    takezoe committed Jul 5, 2020
    Copy the full SHA
    28415ae View commit details
  3. Copy the full SHA
    b615903 View commit details
  4. Update README.md

    takezoe authored Jul 5, 2020
    Copy the full SHA
    30c0b70 View commit details

Commits on Dec 13, 2020

  1. Ignore Metals specific files

    takezoe committed Dec 13, 2020
    Copy the full SHA
    05c5984 View commit details
  2. Tweak GitHub Actions trigger

    takezoe committed Dec 13, 2020
    Copy the full SHA
    cba8d2f View commit details
  3. Support GitBucket 4.35.0

    takezoe committed Dec 13, 2020
    Copy the full SHA
    4f8bd47 View commit details
  4. Bump to sbt 1.4.4

    takezoe committed Dec 13, 2020
    Copy the full SHA
    1d72ca6 View commit details

Commits on Feb 11, 2021

  1. Use default branch instead of master (#32)

    * use default branch instead of hard coded master
    * ignore .bsp
    yaroot authored Feb 11, 2021
    Copy the full SHA
    31fb5f7 View commit details

Commits on Feb 20, 2021

  1. Copy the full SHA
    320f341 View commit details

Commits on Apr 20, 2021

  1. Copy the full SHA
    3f2baad View commit details

Commits on Aug 25, 2021

  1. Release 1.10.0

    takezoe committed Aug 25, 2021
    Copy the full SHA
    6405d84 View commit details

Commits on Jul 5, 2022

  1. Create CODEOWNERS

    xuwei-k authored Jul 5, 2022
    Copy the full SHA
    054fe53 View commit details
  2. Create dependabot.yml

    xuwei-k authored Jul 5, 2022
    Copy the full SHA
    9bc5bf6 View commit details
  3. Bump actions/checkout from 2 to 3

    Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
    - [Release notes](https://github.com/actions/checkout/releases)
    - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
    - [Commits](actions/checkout@v2...v3)
    
    ---
    updated-dependencies:
    - dependency-name: actions/checkout
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and xuwei-k committed Jul 5, 2022
    Copy the full SHA
    9fededa View commit details
  4. Bump actions/upload-artifact from 2 to 3

    Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
    - [Release notes](https://github.com/actions/upload-artifact/releases)
    - [Commits](actions/upload-artifact@v2...v3)
    
    ---
    updated-dependencies:
    - dependency-name: actions/upload-artifact
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and xuwei-k committed Jul 5, 2022
    Copy the full SHA
    b733121 View commit details
  5. Bump actions/cache from 2 to 3

    Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3.
    - [Release notes](https://github.com/actions/cache/releases)
    - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
    - [Commits](actions/cache@v2...v3)
    
    ---
    updated-dependencies:
    - dependency-name: actions/cache
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and xuwei-k committed Jul 5, 2022
    Copy the full SHA
    094ddbc View commit details
  6. Bump actions/setup-java from 1 to 3 (#39)

    * Bump actions/setup-java from 1 to 3
    
    Bumps [actions/setup-java](https://github.com/actions/setup-java) from 1 to 3.
    - [Release notes](https://github.com/actions/setup-java/releases)
    - [Commits](actions/setup-java@v1...v3)
    
    ---
    updated-dependencies:
    - dependency-name: actions/setup-java
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * Update build.yml
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: kenji yoshida <6b656e6a69@gmail.com>
    dependabot[bot] and xuwei-k authored Jul 5, 2022
    Copy the full SHA
    126035e View commit details
  7. Copy the full SHA
    db9a12d View commit details
  8. Update sbt-scalafmt to 1.5.1

    scala-steward-bot authored and xuwei-k committed Jul 5, 2022
    Copy the full SHA
    e58fd7e View commit details
  9. Update sbt to 1.5.8

    scala-steward-bot authored and xuwei-k committed Jul 5, 2022
    Copy the full SHA
    439a345 View commit details
  10. Update gitbucket to 4.37.2

    scala-steward-bot authored and xuwei-k committed Jul 5, 2022
    Copy the full SHA
    3352152 View commit details
  11. Copy the full SHA
    1f88bce View commit details
  12. Update sbt to 1.6.2

    scala-steward-bot authored and xuwei-k committed Jul 5, 2022
    Copy the full SHA
    4666b27 View commit details

Commits on Jul 10, 2022

  1. Update sbt to 1.7.0

    scala-steward-bot authored and xuwei-k committed Jul 10, 2022
    Copy the full SHA
    e6eae8b View commit details

Commits on Jul 12, 2022

  1. Update sbt to 1.7.1

    scala-steward-bot authored and xuwei-k committed Jul 12, 2022
    Copy the full SHA
    53d4536 View commit details

Commits on Sep 3, 2022

  1. Update gitbucket to 4.38.0

    scala-steward-bot authored and yaroot committed Sep 3, 2022
    Copy the full SHA
    df8e6f7 View commit details

Commits on Sep 10, 2022

  1. Update gitbucket to 4.38.1

    scala-steward-bot authored and xuwei-k committed Sep 10, 2022
    Copy the full SHA
    db0d6d6 View commit details

Commits on Sep 19, 2022

  1. Update scala-library to 2.13.9

    scala-steward-bot authored and xuwei-k committed Sep 19, 2022
    Copy the full SHA
    318dbe7 View commit details

Commits on Sep 20, 2022

  1. Update gitbucket to 4.38.2

    scala-steward-bot authored and xuwei-k committed Sep 20, 2022
    Copy the full SHA
    30f1c70 View commit details

Commits on Oct 3, 2022

  1. Copy the full SHA
    546d9e9 View commit details

Commits on Oct 8, 2022

  1. Copy the full SHA
    37f4db1 View commit details

Commits on Oct 30, 2022

  1. Update gitbucket to 4.38.3

    scala-steward-bot authored and xuwei-k committed Oct 30, 2022
    Copy the full SHA
    ff779e3 View commit details

Commits on Nov 2, 2022

  1. Update gitbucket to 4.38.4

    scala-steward-bot authored and xuwei-k committed Nov 2, 2022
    Copy the full SHA
    ef79ef2 View commit details

Commits on Apr 28, 2023

  1. Update gitbucket to 4.39.0

    scala-steward-bot authored and xuwei-k committed Apr 28, 2023
    Copy the full SHA
    fb0b2ff View commit details

Commits on Apr 30, 2023

  1. Copy the full SHA
    ad71d51 View commit details

Commits on May 12, 2023

  1. Update sbt to 1.8.3

    scala-steward-bot authored and yaroot committed May 12, 2023
    Copy the full SHA
    ac4a20d View commit details

Commits on May 13, 2023

  1. update scalafmt settings

    xuwei-k committed May 13, 2023
    Copy the full SHA
    805eaf2 View commit details

Commits on May 31, 2023

  1. Update scalafmt-core to 3.7.4

    scala-steward-bot authored and yaroot committed May 31, 2023
    Copy the full SHA
    99708b3 View commit details

Commits on Jun 2, 2023

  1. Update sbt to 1.9.0

    scala-steward-bot authored and xuwei-k committed Jun 2, 2023
    Copy the full SHA
    c656da4 View commit details
  2. Copy the full SHA
    636472d View commit details

Commits on Jun 26, 2023

  1. Update sbt to 1.9.1

    scala-steward-bot authored and xuwei-k committed Jun 26, 2023
    Copy the full SHA
    543d8f3 View commit details

Commits on Jul 2, 2023

  1. Copy the full SHA
    00e0816 View commit details

Commits on Jul 4, 2023

  1. Update scalafmt-core to 3.7.6

    scala-steward-bot authored and xuwei-k committed Jul 4, 2023
    Copy the full SHA
    37602a7 View commit details

Commits on Jul 7, 2023

  1. Update scalafmt-core to 3.7.7

    scala-steward-bot authored and xuwei-k committed Jul 7, 2023
    Copy the full SHA
    12b1343 View commit details

Commits on Jul 10, 2023

  1. Update sbt to 1.9.2

    scala-steward-bot authored and yaroot committed Jul 10, 2023
    Copy the full SHA
    eaca8bb View commit details
  2. Update scalafmt-core to 3.7.8

    scala-steward-bot authored and xuwei-k committed Jul 10, 2023
    Copy the full SHA
    e3e2635 View commit details

Commits on Jul 14, 2023

  1. Copy the full SHA
    24d8617 View commit details

Commits on Jul 16, 2023

  1. Update scalafmt-core to 3.7.10

    scala-steward-bot authored and xuwei-k committed Jul 16, 2023
    Copy the full SHA
    ba6e975 View commit details

Commits on Jul 24, 2023

  1. Copy the full SHA
    04bfb68 View commit details
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @takezoe @xuwei-k
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
43 changes: 43 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: build

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [11]
steps:
- uses: actions/checkout@v4
- name: Cache
uses: actions/cache@v4
env:
cache-name: cache-sbt-libs
with:
path: |
~/.ivy2/cache
~/.sbt
~/.coursier
key: build-${{ env.cache-name }}-${{ hashFiles('build.sbt') }}
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.java }}
- uses: sbt/setup-sbt@v1
- name: Run tests
run: |
git clone https://github.com/gitbucket/gitbucket.git
cd gitbucket
sbt publishLocal
cd ../
sbt scalafmtSbtCheck scalafmtCheckAll test
- name: Assembly
run: sbt assembly
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gitbucket-pages-plugin-java${{ matrix.java }}-${{ github.sha }}
path: ./target/scala-2.13/*.jar

33 changes: 31 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
*.iml
.idea/
*.class
*.log

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

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

# IntelliJ specific
.idea/
.idea_modules/

# Ensime
.ensime
.ensime_cache/

# Metals
.bloop/
.metals/
.vscode/
**/metals.sbt
.bsp
5 changes: 3 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
version = "3.9.4"
project.git = true

maxColumn = 120
docstrings = JavaDoc

align.tokens = ["%", "%%", {code = "=>", owner = "Case"}]
align.openParenCallSite = false
align.openParenDefnSite = false
continuationIndent.callSite = 2
continuationIndent.defnSite = 2
danglingParentheses = true
danglingParentheses.preset = true
runner.dialect = scala213source3
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Gitbucket-Pages-Plugin [![Gitter](https://img.shields.io/gitter/room/gitbucket/gitbucket.js.svg?style=flat-square)](https://gitter.im/gitbucket/gitbucket) [![Travis](https://img.shields.io/travis/gitbucket/gitbucket-pages-plugin.svg?style=flat-square)](https://travis-ci.org/gitbucket/gitbucket-pages-plugin)
# Gitbucket-Pages-Plugin [![Gitter](https://img.shields.io/gitter/room/gitbucket/gitbucket.js.svg)](https://gitter.im/gitbucket/gitbucket) [![build](https://github.com/gitbucket/gitbucket-pages-plugin/workflows/build/badge.svg?branch=master)](https://github.com/gitbucket/gitbucket-pages-plugin/actions?query=workflow%3Abuild+branch%3Amaster)

This plugin provides *Project Pages* functionality for
[GitBucket](https://github.com/gitbucket/gitbucket) based repositories.
@@ -38,6 +38,8 @@ version please follow the instruction below**

| pages version | gitbucket version |
| :---: | :---: |
| 1.10.0 | 4.36.0 |
| 1.9.0 | 4.35.0 |
| 1.8.0 | 4.32.0 |
| 1.7.0 | 4.23.0 |
| 1.6.0 | 4.19.0 |
@@ -92,5 +94,4 @@ server {

## CI

- build by [travis-ci](https://travis-ci.org/gitbucket/gitbucket-pages-plugin)

- build by [GitHub Actions](https://github.com/gitbucket/gitbucket-pages-plugin/actions)
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
organization := "gitbucket"
name := "gitbucket-pages-plugin"
scalaVersion := "2.13.0"
version := "1.8.0"
gitbucketVersion := "4.32.0"
scalaVersion := "2.13.16"
version := "1.10.0"
gitbucketVersion := "4.42.1"
scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8", "-feature")

scalafmtOnCompile := true
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.10.11
5 changes: 2 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.0")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0")
addSbtPlugin("io.github.gitbucket" % "sbt-gitbucket-plugin" % "1.5.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.4")
addSbtPlugin("io.github.gitbucket" % "sbt-gitbucket-plugin" % "1.6.0")
9 changes: 5 additions & 4 deletions src/main/scala/Plugin.scala
Original file line number Diff line number Diff line change
@@ -33,14 +33,15 @@ class Plugin extends gitbucket.core.plugin.Plugin {
new Version("1.6.0"),
new Version("1.7.0"),
new Version("1.7.1"),
new Version("1.8.0")
new Version("1.8.0"),
new Version("1.9.0"),
new Version("1.10.0")
)

override val controllers: Seq[(String, ControllerBase)] = Seq("/*" -> new PagesController)

override val repositorySettingTabs = Seq(
(repository: RepositoryInfo, context: Context) => Some(Link("pages", "Pages", s"settings/pages"))
)
override val repositorySettingTabs =
Seq((repository: RepositoryInfo, context: Context) => Some(Link("pages", "Pages", s"settings/pages")))

override val repositoryHooks = Seq(new PagesHook)
}
2 changes: 1 addition & 1 deletion src/main/scala/gitbucket/plugin/model/Pages.scala
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ trait PagesComponent { self: gitbucket.core.model.Profile =>
val userName = column[String]("USER_NAME")
val repositoryName = column[String]("REPOSITORY_NAME")
val source = column[PageSourceType]("SOURCE")
def * = (userName, repositoryName, source) <> ((Page.apply _).tupled, Page.unapply)
def * = (userName, repositoryName, source).<>((Page.apply _).tupled, Page.unapply)
}
}

47 changes: 21 additions & 26 deletions src/main/scala/gitbucket/plugin/pages/pages.scala
Original file line number Diff line number Diff line change
@@ -13,8 +13,9 @@ import org.eclipse.jgit.api.Git
import org.eclipse.jgit.lib.ObjectId
import org.eclipse.jgit.revwalk.RevCommit
import org.scalatra.i18n.Messages
import scala.util.Using

import javax.servlet.http.HttpServletRequest
import scala.util.Using
import scala.annotation.tailrec
import scala.language.implicitConversions

@@ -30,29 +31,36 @@ trait PagesControllerBase extends ControllerBase {
self: AccountService with RepositoryService with PagesService with ReferrerAuthenticator with OwnerAuthenticator =>
import PagesControllerBase._

val optionsForm = mapping("source" -> trim(label("Pages Source", text(required, pagesOption))))(
(source) => OptionsForm(PageSourceType.valueOf(source))
)
val optionsForm: MappingValueType[OptionsForm] = mapping(
"source" -> trim(label("Pages Source", text(required, pagesOption)))
)(source => OptionsForm(PageSourceType.valueOf(source)))

val PAGES_BRANCHES = List("gb-pages", "gh-pages")

def endsWithSlash(): Boolean = request.getServletPath.endsWith("/")

get("/:owner/:repository/pages/*")(referrersOnly { repository =>
renderPage(repository, params("splat"))
})

get("/:owner/:repository/pages")(referrersOnly { repository =>
renderPage(repository, "")
if (endsWithSlash()) {
renderPage(repository, "")
} else {
redirect(s"/${repository.owner}/${repository.name}/pages/")
}
})

private def renderPage(repository: RepositoryInfo, path: String) = {
val defaultBranch = repository.repository.defaultBranch
Using.resource(Git.open(Directory.getRepositoryDir(repository.owner, repository.name))) { git =>
getPageSource(repository.owner, repository.name) match {
case PageSourceType.GH_PAGES =>
renderFromBranch(repository, git, path, PAGES_BRANCHES.collectFirstOpt(resolveBranch(git, _)))
renderFromBranch(repository, git, path, PAGES_BRANCHES.collectFirst(Function.unlift(resolveBranch(git, _))))
case PageSourceType.MASTER =>
renderFromBranch(repository, git, path, resolveBranch(git, "master"))
renderFromBranch(repository, git, path, resolveBranch(git, defaultBranch))
case PageSourceType.MASTER_DOCS =>
renderFromBranch(repository, git, joinPath("docs", path), resolveBranch(git, "master"))
renderFromBranch(repository, git, joinPath("docs", path), resolveBranch(git, defaultBranch))
case PageSourceType.NONE =>
NotFound()
}
@@ -61,7 +69,8 @@ trait PagesControllerBase extends ControllerBase {

get("/:owner/:repository/settings/pages")(ownerOnly { repository =>
val source = getPageSource(repository.owner, repository.name)
html.options(repository, source, flash.get("info"))
val defaultBranch = repository.repository.defaultBranch
html.options(repository, source, defaultBranch, flash.get("info"))
})

post("/:owner/:repository/settings/pages", optionsForm)(ownerOnly { (form, repository) =>
@@ -98,14 +107,14 @@ trait PagesControllerBase extends ControllerBase {
}
}

def resolveBranch(git: Git, name: String) = Option(git.getRepository.resolve(name))
def resolveBranch(git: Git, name: String): Option[ObjectId] = Option(git.getRepository.resolve(name))

// redirect [owner/repo/pages/path] -> [owner/repo/pages/path/]
def shouldRedirect(path: String, path0: String): Boolean =
!isRoot(path) && path0 != path && path0.startsWith(path) && !path.endsWith("/")
!isRoot(path) && path0 != path && path0.startsWith(path) && !endsWithSlash()

def getPageObjectId(git: Git, path: String, revCommit: RevCommit): Option[(String, ObjectId)] = {
listProbablePages(path).collectFirstOpt(getPathObjectIdPair(git, _, revCommit))
listProbablePages(path).collectFirst(Function.unlift(getPathObjectIdPair(git, _, revCommit)))
}

def listProbablePages(path: String): List[String] = {
@@ -133,20 +142,6 @@ trait PagesControllerBase extends ControllerBase {
object PagesControllerBase {
case class OptionsForm(source: PageSourceType)

implicit class listCollectFirst[A](private val lst: List[A]) extends AnyVal {
@tailrec
final def collectFirstOpt[B](f: A => Option[B]): Option[B] = {
lst match {
case head :: tail =>
f(head) match {
case Some(x) => Some(x)
case None => tail.collectFirstOpt(f)
}
case Nil => None
}
}
}

def pagesOption: Constraint = new Constraint() {
override def validate(name: String, value: String, messages: Messages): Option[String] =
PageSourceType.valueOpt(value) match {
4 changes: 2 additions & 2 deletions src/main/scala/gitbucket/plugin/service/PagesService.scala
Original file line number Diff line number Diff line change
@@ -21,8 +21,8 @@ trait PagesService {
.map(t => t.source)
.update(source)

def renameRepository(userName: String, oldRepositoryName: String, newRepositoryName: String)(
implicit s: Session
def renameRepository(userName: String, oldRepositoryName: String, newRepositoryName: String)(implicit
s: Session
): Unit =
Pages
.filter(t => (t.userName === userName.bind) && (t.repositoryName === oldRepositoryName.bind))
7 changes: 4 additions & 3 deletions src/main/twirl/gitbucket/pages/options.scala.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import gitbucket.plugin.model.PageSourceType
@(repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
source: PageSourceType,
defaultBranch: String,
info: Option[Any])(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main("Pages", Some(repository)){
@@ -24,16 +25,16 @@
<div class="radio">
<label>
<input type="radio" name="source" value="@PageSourceType.MASTER.code" @if(source == PageSourceType.MASTER) { checked="checked" }>
<span class="strong">master branch</span><br>
<span class="strong">default branch</span><br>
<div class="normal muted">
Use the <code>master</code> branch for Pages.
Use the <code>@defaultBranch</code> branch for Pages.
</div>
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="source" value="@PageSourceType.MASTER_DOCS.code" @if(source == PageSourceType.MASTER_DOCS) { checked="checked" }>
<span class="strong">master branch /docs folder</span><br>
<span class="strong">default branch /docs folder</span><br>
<div class="normal muted">
Use only the <code>/docs</code> folder for Pages.
</div>