Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Karasiq committed Mar 9, 2016
1 parent b270d7c commit 297035f
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 25 deletions.
Binary file modified frontend/files/favicon.ico
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ final class NanoboardController(implicit ec: ExecutionContext, ctx: Ctx.Owner) e
}

def deletePending(post: NanoboardMessageData): Unit = {
pngGenerationPanel.deletePost(post)
pngGenerationPanel.posts() = pngGenerationPanel.posts.now.filterNot(_.hash == post.hash)
}

override def context: Rx[NanoboardContext] = thread.context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.karasiq.nanoboard.frontend.components

import com.karasiq.bootstrap.BootstrapImplicits._
import com.karasiq.bootstrap.form.{Form, FormInput}
import com.karasiq.bootstrap.grid.GridSystem
import com.karasiq.bootstrap.{Bootstrap, BootstrapHtmlComponent}
import com.karasiq.nanoboard.frontend.api.{NanoboardApi, NanoboardMessageData}
import com.karasiq.nanoboard.frontend.components.post.NanoboardPost
Expand Down Expand Up @@ -55,7 +56,7 @@ final class PngGenerationPanel(implicit ec: ExecutionContext, ctx: Ctx.Owner, co
if (posts.nonEmpty) Bootstrap.well(
marginTop := 20.px,
h3("Pending posts"),
for (p posts) yield NanoboardPost(showParent = true, showAnswers = false, p)
for (p posts) yield GridSystem.mkRow(NanoboardPost(showParent = true, showAnswers = false, p))
) else ()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,36 @@ final class ThreadContainer(val context: Var[NanoboardContext], postsPerPage: In
msg
}

context.now match {
val newPosts = context.now match {
case NanoboardContext.Recent(0)
if (posts.now.length == postsPerPage) {
posts() = post +: posts.now.dropRight(1)
post +: posts.now.dropRight(1)
} else {
posts() = post +: posts.now
post +: posts.now
}

case NanoboardContext.Thread(hash, 0) if post.parent.contains(hash)
val (opPost, answers) = posts.now.partition(_.hash == hash)
if (answers.length >= postsPerPage) {
posts() = opPost ++ Some(post) ++ answers.dropRight(1)
opPost ++ Some(post) ++ answers.dropRight(1)
} else {
posts() = opPost ++ Some(post) ++ answers
opPost ++ Some(post) ++ answers
}

case NanoboardContext.Thread(post.hash, _)
val (_, answers) = posts.now.partition(_.hash == post.hash)
posts() = post +: answers
post +: answers

case _
posts() = posts.now.collect {
case msg @ NanoboardMessageData(_, hash, _, answers) if post.parent.contains(hash)
msg.copy(answers = answers + 1)
posts.now
}

case msg
msg
}
posts() = newPosts.collect {
case msg @ NanoboardMessageData(_, hash, _, answers) if post.parent.contains(hash)
msg.copy(answers = answers + 1)

case msg
msg
}
}

Expand Down
3 changes: 2 additions & 1 deletion library/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
nanoboard {
client-version = "karasiq-nanoboard v1.0.4"
version = 1.0.4
client-version = karasiq-nanoboard v${nanoboard.version}
encryption-key = "nano"
bitmessage {
chan-address = "BM-2cWzzuoiF7pxchwiF5obVmXaQKFywETu7k"
Expand Down
13 changes: 12 additions & 1 deletion src/main/resources/reference.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
nanoboard {
external-config-file = nanoboard.conf
max-post-size = 70k
max-post-size = 66k

database {
url = "jdbc:h2:file:"${user.home}/.nanoboard/index
Expand Down Expand Up @@ -32,4 +32,15 @@ nanoboard {
username = "nanoapi"
password = "nano"
}
}

akka.http {
server {
server-header = nanoboard/${nanoboard.version}
idle-timeout = 24h
}

client {
user-agent-header = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.52 Safari/537.36 OPR/31.0.1889.50 (Edition beta)"
}
}
16 changes: 9 additions & 7 deletions src/main/scala/com/karasiq/nanoboard/server/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ object Main extends App {
// Imageboards PNG
val messageSource = UrlPngSource.fromConfig(config)
val updateInterval = FiniteDuration(config.getDuration("nanoboard.scheduler.update-interval", TimeUnit.MILLISECONDS), TimeUnit.MILLISECONDS)
Source.tick(10 seconds, updateInterval, ())
.flatMapConcat(_ Source.fromPublisher(db.stream(Place.list())))
.flatMapMerge(8, messageSource.imagesFromPage)
.filterNot(cache.contains)
.alsoTo(Sink.foreach(image cache += image))
.flatMapMerge(8, messageSource.messagesFromImage)
.runWith(dbMessageSink)

actorSystem.scheduler.schedule(10 seconds, updateInterval) {
Source.fromPublisher(db.stream(Place.list()))
.flatMapMerge(4, messageSource.imagesFromPage)
.filterNot(cache.contains)
.alsoTo(Sink.foreach(image cache += image))
.flatMapMerge(8, messageSource.messagesFromImage)
.runWith(dbMessageSink)
}

// REST server
val server = NanoboardServer(dispatcher)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ private[server] final class NanoboardMessageStream extends GraphStage[FanInShape
val messages: Inlet[NanoboardMessage] = Inlet("MessageStream")
val output: Outlet[NanoboardMessage] = Outlet("MessageOutput")

override def shape: FanInShape2[Set[String], NanoboardMessage, NanoboardMessage] = new FanInShape2(input, messages, output)
override def shape = new FanInShape2(input, messages, output)

override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) {
override def createLogic(inheritedAttributes: Attributes) = new GraphStageLogic(shape) {
private var subscription = Set.empty[String]

def request(): Unit = {
Expand Down

0 comments on commit 297035f

Please sign in to comment.