Skip to content

Commit

Permalink
updated libraries, cleanup build, added FAL license, default to wikim…
Browse files Browse the repository at this point in the history
…edia commons, code cleanups
  • Loading branch information
Herr Ritschwumm committed Jan 18, 2014
1 parent 92f50de commit 908057b
Show file tree
Hide file tree
Showing 28 changed files with 199 additions and 193 deletions.
15 changes: 7 additions & 8 deletions build.sbt
Expand Up @@ -2,22 +2,21 @@ name := "commonist"

organization := "de.djini"

version := "0.8.0"
version := "0.9.0"

scalaVersion := "2.10.3"

libraryDependencies ++= Seq(
"de.djini" %% "scutil" % "0.34.0" % "compile",
"de.djini" %% "scjson" % "0.37.0" % "compile",
"de.djini" %% "scmw" % "0.33.0" % "compile",
"de.djini" %% "scutil" % "0.40.0" % "compile",
"de.djini" %% "scmw" % "0.40.0" % "compile",
"org.apache.sanselan" % "sanselan" % "0.97-incubator" % "compile",
"org.simplericity.macify" % "macify" % "1.6" % "compile"
)

scalacOptions ++= Seq(
"-deprecation",
"-unchecked",
// "-language:implicitConversions",
"-language:implicitConversions",
// "-language:existentials",
// "-language:higherKinds",
// "-language:reflectiveCalls",
Expand Down Expand Up @@ -58,7 +57,7 @@ osxappSettings

osxappBundleName := "commonist"

osxappBundleIcons := file("src/main/osxapp/commonist.icns")
osxappBundleIcons := baseDirectory.value / "src/main/osxapp/commonist.icns"

osxappVm := OracleJava7()

Expand All @@ -82,13 +81,13 @@ webstartGenConfig := Some(GenConfig(
))

webstartKeyConfig := Some(KeyConfig(
keyStore = file("etc/keyStore"),
keyStore = baseDirectory.value / "etc/keyStore",
storePass = "0xDEADBEEF",
alias = "signFiles",
keyPass = "0xDEADBEEF"
))

webstartManifest := Some(file("etc/manifest.mf"))
webstartManifest := Some(baseDirectory.value / "etc/manifest.mf")

webstartJnlpConfigs := Seq(JnlpConfig(
fileName = "commonist.jnlp",
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
@@ -1 +1 @@
sbt.version=0.13.0
sbt.version=0.13.1
10 changes: 5 additions & 5 deletions project/plugins.sbt
@@ -1,9 +1,9 @@
addSbtPlugin("de.djini" % "xsbt-webstart" % "0.13.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.3.0")

addSbtPlugin("de.djini" % "xsbt-scriptstart" % "0.13.0")
addSbtPlugin("de.djini" % "xsbt-webstart" % "0.15.0")

addSbtPlugin("de.djini" % "xsbt-osxapp" % "0.8.0")
addSbtPlugin("de.djini" % "xsbt-scriptstart" % "0.15.0")

addSbtPlugin("de.djini" % "xsbt-zipper" % "0.6.0")
addSbtPlugin("de.djini" % "xsbt-osxapp" % "0.11.0")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.2.5")
addSbtPlugin("de.djini" % "xsbt-zipper" % "0.7.0")
7 changes: 7 additions & 0 deletions src/main/doc/changes.txt
@@ -1,3 +1,10 @@
0.9.0 18jan14
change added FAL license
change mediawiki was a stupid default for the wiki,
using commons again.
change updated libraries.
change build with sbt 0.13.1

0.8.0 24nov13
change changed all wikis to use https
change use scmw-0.33.0 to use new httpclient 4.3.1
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/licenses.txt
Expand Up @@ -49,6 +49,9 @@
# Non-free licenses:
{{Copyright by Wikimedia}} Wikimedia logos

# Other copyleft licenses:
{{FAL}} Copyleft: This work of art is free; you can redistribute it and/or modify it according to terms of the Free Art License.

## OLD
#{{self2|GFDL|cc-by-sa-2.5,2.0,1.0}} Own work, copyleft: Multi-license with GFDL and Creative Commons CC-BY-SA-2.5 and older versions (2.0 and 1.0)
#{{self2|GFDL|cc-by-2.5}} Own work, attribution required (Multi-license with GFDL and Creative Commons CC-BY 2.5)
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/messages_de.properties
Expand Up @@ -61,12 +61,13 @@ status.gallery.error=konnte Galerie nicht \u00e4ndern ({0})

# callback queries
query.upload.title=Problem beim Upload
query.upload.body=Es geht um die Datei {0}:\n{1}\nDennoch hochladen und gegebenenfalls überschreiben?
query.upload.ignoreFileexists.message=Datei ist bereits vorhanden und würde überschrieben.
query.upload.body=Es geht um die Datei {0}:\n{1}\nDennoch hochladen und gegebenenfalls \u00fcberschreiben?
query.upload.ignoreFileexists.message=Datei ist bereits vorhanden und w\u00fcrde \u00fcberschrieben.
query.upload.ignoreFilewasdeleted.message=Datei wurde schon einmal gel\u00f6scht.
query.upload.ignoreDuplicate.message=Datei ist ein Duplikat von {1}.
query.upload.ignoreDuplicateArchive.message=Datei ist ein Archiv-Duplikat von {1}.

# action buttons
upload.upload=Hochladen
upload.abort=Abbrechen

16 changes: 8 additions & 8 deletions src/main/resources/wikis.txt
@@ -1,11 +1,3 @@
# other
# kamelopedia _ http://kamelopedia.mormo.org/api.php
mediawiki _ https://www.mediawiki.org/w/api.php

# wikia
wikia foto https://foto.wikia.com/api.php
wikia uncyclopedia https://uncyclopedia.wikia.com/api.php

# wikimedia
wikimedia commons https://commons.wikimedia.org/w/api.php
wikimedia meta https://meta.wikimedia.org/w/api.php
Expand Down Expand Up @@ -101,3 +93,11 @@ wiktionary nl https://nl.wiktionary.org/w/api.php
wiktionary pl https://pl.wiktionary.org/w/api.php
wiktionary pt https://pt.wiktionary.org/w/api.php
wiktionary sv https://sv.wiktionary.org/w/api.php

# other
# kamelopedia _ http://kamelopedia.mormo.org/api.php
mediawiki _ https://www.mediawiki.org/w/api.php

# wikia
wikia foto https://foto.wikia.com/api.php
wikia uncyclopedia https://uncyclopedia.wikia.com/api.php
17 changes: 8 additions & 9 deletions src/main/scala/commonist/Commonist.scala
Expand Up @@ -10,7 +10,7 @@ import bsh.EvalError

import org.simplericity.macify.eawt._

import scutil.Implicits._
import scutil.implicits._
import scutil.platform._
import scutil.io.Files._
import scutil.gui.SwingApp
Expand Down Expand Up @@ -39,18 +39,18 @@ object Commonist extends SwingApp with Logging {
private val etcDir = PWD / "etc"
private val resourcesDir = PWD / "src" / "main" / "resources"
private val resourcePrefix = "/"
INFO("settings directory: " + settingsDir)
INFO("etc directory: " + etcDir)
INFO("resources directory: " + resourcesDir)
INFO("settings directory", settingsDir)
INFO("etc directory", etcDir)
INFO("resources directory", resourcesDir)
settingsDir.mkdirs()
require(settingsDir.exists, "settings directory cannot be created")
private val loader = new Loader(settingsDir, etcDir, resourcesDir, resourcePrefix)

val programIcon = null
val programHeading = "The Commonist " + Constants.VERSION
val programHeading = s"The Commonist ${commonist.BuildInfo.version}"

private val userLanguage = SystemProperties.user.language
INFO("using user language: " + userLanguage)
INFO("using user language", userLanguage)
loadMessages(userLanguage)

private val licenses = loadLicenses()
Expand Down Expand Up @@ -93,8 +93,7 @@ object Commonist extends SwingApp with Logging {
doQuit()
}
}
"/commonist-128.png" |> getClass.getResource |> ImageIO.read |>
macifyApplication.setApplicationIconImage
macifyApplication setApplicationIconImage ("/commonist-128.png" |> getClass.getResource |> ImageIO.read)
macifyApplication.removeAboutMenuItem()
macifyApplication.removePreferencesMenuItem()

Expand Down Expand Up @@ -178,7 +177,7 @@ object Commonist extends SwingApp with Logging {
/** load language file for the language or en if not successful and returns the used language */
private def loadMessages(language:String) {
val defaultURL = loader resourceURL "messages_default.properties" getOrError "cannot load messages_default.properties"
val userLangURL = loader resourceURL ("messages_" + language + ".properties")
val userLangURL = loader resourceURL (s"messages_${language}.properties")
Messages init (defaultURL, userLangURL)
}

Expand Down
1 change: 0 additions & 1 deletion src/main/scala/commonist/Constants.scala
Expand Up @@ -4,7 +4,6 @@ import javax.swing.BorderFactory

/** constants used throughout the application */
object Constants {
val VERSION = BuildInfo.version
val ENABLE_API_WRITE = true // if false the API is dry-running
val ENABLE_GALLERY = true

Expand Down
13 changes: 7 additions & 6 deletions src/main/scala/commonist/Parser.scala
Expand Up @@ -4,7 +4,8 @@ import java.io._
import java.net._
import java.util.regex._

import scutil.Implicits._
import scutil.implicits._
import scutil.io.Charsets.utf_8
import scutil.log._

import scmw._
Expand Down Expand Up @@ -71,11 +72,11 @@ object Parser extends Logging {

private def parseURL[T](url:URL)(parseLine:String=>Iterable[T]):Seq[T] =
slurpLines(url)
.map { _.trim }
.filter { _.nonEmpty }
.filter { !_.startsWith("#") }
.flatMap { parseLine }
.map { _.trim }
.filter { _.nonEmpty }
.filter { !_.startsWith("#") }
.flatMap { parseLine }

private def slurpLines(url:URL):Seq[String] =
new BufferedReader(new InputStreamReader(url.openStream, "UTF-8")) use { _.readLines() }
(url withReader utf_8) { _.readLines() }
}
6 changes: 3 additions & 3 deletions src/main/scala/commonist/task/ChangeDirectoryTask.scala
Expand Up @@ -3,7 +3,7 @@ package commonist.task
import java.io.File
import javax.swing.Icon

import scutil.Implicits._
import scutil.implicits._
import scutil.log._

import commonist._
Expand All @@ -26,13 +26,13 @@ final class ChangeDirectoryTask(mainWindow:MainWindow, imageListUI:ImageListUI,
// TODO handle null
val listed = directory
.childrenWhere { file:File => file.isFile && !file.isHidden }
.getOrElse { WARN("directory does not exist: " + directory); return }
.getOrElse { WARN("directory does not exist", directory); return }

// TODO duplicate code
val sorted = listed sortBy { _.getPath }

val (readable,unreadable) = sorted partition { _.canRead }
unreadable foreach { it => WARN("cannot read: " + it) }
unreadable foreach { it => WARN("cannot read", it) }

val max = readable.length
var cur = 0
Expand Down
37 changes: 20 additions & 17 deletions src/main/scala/commonist/task/UploadFilesTask.scala
Expand Up @@ -7,7 +7,7 @@ import javax.swing.JOptionPane

import scala.collection.JavaConverters._

import scutil.Implicits._
import scutil.implicits._
import scutil.io.Charsets
import scutil.gui.SwingUtil._
import scutil.log._
Expand Down Expand Up @@ -90,16 +90,16 @@ final class UploadFilesTask(
val loginResult = api login (commonData.user.trim, commonData.password)
loginResult match {
case LoginSuccess(userName) =>
INFO("login successful: " + userName)
INFO("login successful", userName)
statusUILater halt ("status.login.successful", wikiName)
true
case LoginFailure(code) =>
INFO("login failed: " + code)
INFO("login failed", code)
// TODO more detail
statusUILater halt ("status.login.wrongpw", wikiName)
false
case LoginError(code) =>
INFO("login error: " + code)
INFO("login error", code)
statusUILater halt ("status.login.error", wikiName, code)
false
}
Expand Down Expand Up @@ -158,25 +158,25 @@ final class UploadFilesTask(
val uploaded = api upload (name, "", text, watch, file, callback)
uploaded match {
case UploadSuccess(fileName, pageTitle) =>
INFO("upload successful: " + fileName + " to " + pageTitle)
INFO("upload successful", fileName, pageTitle)
statusUILater halt ("status.upload.successful", fileName, pageTitle)
imageListUILater uploadFinished (file, true)
upload copy (name=fileName, title=pageTitle)
case UploadAborted(warnings) =>
ERROR("upload aborted: " + fileName)
ERROR("upload aborted", fileName)
statusUILater halt ("status.upload.error", fileName, "aborted")
imageListUILater uploadFinished (file, false)
// TODO just remove it from the list?
// TODO more detail
upload copy (error="aborted: " + renderWarnings(warnings))
upload copy (error=s"aborted: ${renderWarnings(warnings)}")
case UploadFailure(code) =>
// TODO more detail
ERROR("upload failed: " + fileName + " because " + code)
ERROR("upload failed", fileName, code)
statusUILater halt ("status.upload.error", fileName, code)
imageListUILater uploadFinished (file, false)
upload copy (error=code)
case UploadError(code) =>
ERROR("upload error: " + fileName + " because " + code)
ERROR("upload error", fileName, code)
statusUILater halt ("status.upload.error", fileName, code)
imageListUILater uploadFinished (file, false)
upload copy (error=code)
Expand All @@ -199,6 +199,9 @@ final class UploadFilesTask(

private def renderFile(name:String):String =
"[[:" + (Namespace file name) + "]]"

private def renderLink(s:String):String =
"[[" + s + "]]"

/*
statusUILater halt ("status.gallery.error", e.getMessage)
Expand All @@ -216,33 +219,33 @@ final class UploadFilesTask(
sucesses.asJava,
failures.asJava
)
val summary = uploadTemplates gallerySummary (Constants.VERSION, failures.size)
val summary = uploadTemplates gallerySummary (commonist.BuildInfo.version, failures.size)
val text = uploadTemplates galleryDescription (common, batch)

// backup gallery text
val backup = settingsDir / "gallery.txt"
INFO("writing gallery to: " + backup)
INFO("writing gallery", backup)
backup writeString (Charsets.utf_8, text)

statusUILater indeterminate ("status.gallery.loading", "[[" + title + "]]")
statusUILater indeterminate ("status.gallery.loading", renderLink(title))
val editResult = api edit (title, summary, None, { oldText =>
statusUILater indeterminate ("status.gallery.storing", "[[" + title + "]]")
statusUILater indeterminate ("status.gallery.storing", renderLink(title))
val newText = text + "\n\n" + (TextUtil2 trimLF oldText)
Some(newText)
})
editResult match {
case EditSuccess(pageTitle) =>
statusUILater halt ("status.gallery.updated", "[[" + title + "]]")
statusUILater halt ("status.gallery.updated", renderLink(title))
case EditAborted =>
// will not happen
case EditFailure(code) =>
// TODO more detail
statusUILater halt ("status.gallery.error", code + " in [[" + title + "]]")
statusUILater halt ("status.gallery.error", code + " in " + renderLink(title))
case EditError(code) =>
statusUILater halt ("status.gallery.error", code + " in [[" + title + "]]")
statusUILater halt ("status.gallery.error", code + " in " + renderLink(title))
}
}

/*
statusUILater halt ("status.logout.error", wikiName, e.getMessage)
if (!success) { statusUILater halt ("status.logout.failed", wikiName); return }
Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/commonist/task/upload/UploadTemplates.scala
Expand Up @@ -6,7 +6,7 @@ import java.net._
import net.psammead.minibpp.Compiler
import bsh.Interpreter

import scutil.Implicits._
import scutil.implicits._
import scutil.log._

import commonist.data._
Expand All @@ -16,7 +16,7 @@ import commonist.util._
final class UploadTemplates(loader:Loader, wiki:WikiData) extends Logging {
/** edit summary for writing a gallery */
def gallerySummary(version:String, failureCount:Int):String =
"commonist " + version + ((failureCount != 0) cata ("", ", " + failureCount + " errors"))
"commonist " + version + ((failureCount != 0) cata ("", s", ${failureCount} errors"))

/** compiles into wikitext */
def galleryDescription(common:Common, batch:Batch):String =
Expand All @@ -33,11 +33,11 @@ final class UploadTemplates(loader:Loader, wiki:WikiData) extends Logging {
))

private def template(typ:String, data:Map[String,AnyRef]):String = {
val specific = typ + "_" + wiki.family + (wiki.site map { "_" + _ } getOrElse "") + ".bpp"
val specific = typ + "_" + wiki.family + (wiki.site cata ("", "_" + _)) + ".bpp"
val generic = typ + "_default.bpp"
val url = (loader resourceURL specific) orElse
(loader resourceURL generic) getOrError
("neither specific template: " + specific + " nor generic template: " + generic + " could be found")
(s"neither specific template: ${specific} nor generic template: ${generic} could be found")
try {
compile(url, data) |> TextUtil2.restrictEmptyLines |> TextUtil2.trimLF
}
Expand Down

0 comments on commit 908057b

Please sign in to comment.