Skip to content

Commit

Permalink
Provide assets in a correct way
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkm4ntr committed Aug 4, 2016
1 parent cc5805c commit e99dc4b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/main/scala/Plugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Plugin extends gitbucket.core.plugin.Plugin {
"/*" -> new NetworkController
)

override val assetsMappings = Seq("/network" -> "/plugins/network/assets")

override val repositoryMenus = Seq(
(repositoryInfo: RepositoryInfo, context: Context) => Some(Link("network", "Network", "/network", Some("circuit-board")))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,6 @@ trait NetworkControllerBase extends ControllerBase {
html.network(repository)
})

get("/assets/plugins/network/bundle.js") {
contentType = "text/javascript"
val uri = getClass().getResource("bundle.js").toString()
val tmp = uri.split("!")
try {
val fs = FileSystems.getFileSystem(URI.create(tmp(0)))
new String(Files.readAllBytes(fs.getPath(tmp(1))))
} catch {
case e: FileSystemNotFoundException => {
val fs = FileSystems.newFileSystem(URI.create(tmp(0)), new util.HashMap[String, String]())
new String(Files.readAllBytes(fs.getPath(tmp(1))))
}
}
}

get("/:owner/:repository/network/commits") {
contentType = formats("json")
referrersOnly { repository =>
Expand Down
2 changes: 1 addition & 1 deletion src/main/twirl/mrkm4ntr/gitbucket/network.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
@gitbucket.core.html.main("Network", Some(repository)) {
@gitbucket.core.html.menu("network", repository) {
<div id="root"></div>
<script src="@assets/plugins/network/bundle.js"></script>
<script src="@context.path/plugin-assets/network/bundle.js"></script>
}
}
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
entry: ['babel-polyfill', './scripts/index.js'],
output: {
path: __dirname,
filename: 'src/main/resources/mrkm4ntr/gitbucket/network/controller/bundle.js'
filename: 'src/main/resources/plugins/network/assets/bundle.js'
},
module: {
loaders: [
Expand Down

0 comments on commit e99dc4b

Please sign in to comment.