Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sluggified

  • Loading branch information...
commit bd57b9d9459307e88d6d55efd2022dceafba3e6a 1 parent c9765b1
@AnaMarjanica authored
View
9 .gitignore
@@ -0,0 +1,9 @@
+.cache
+.classpath
+.project
+.scala_dependencies
+.settings
+target
+.target
+
+project/strap/sbt-launch-*.jar
View
4 Sluggifier/continuous-compilation.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+echo Entering continuous compilation loop ...
+`dirname $0`/sbt.sh --loop --no-jrebel "$@" ~compile
View
4 Sluggifier/open-console.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+echo Firing up the Scala REPL ...
+`dirname $0`/sbt.sh "$@" console
View
6 Sluggifier/sbt.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+PROJECT_DIR=`dirname $(readlink -f $0)`
+PARENT=`basename $PROJECT_DIR`
+
+$PROJECT_DIR/../sbt.sh "project $PARENT" "$@"
View
38 Sluggifier/src/main/scala/hr/element/sluggifier/Sluggify.scala
@@ -0,0 +1,38 @@
+package hr.element.sluggifier
+
+import com.ibm.icu.text.Transliterator
+
+
+
+object Sluggify {
+ def makeSlug(txt: String, replacement: String) = {
+ //convert latin letters to ASCII (ex. đ->d)
+ val txtTrans = transliterate(txt)
+ //convert all to lower case
+ val txtLower = txtTrans.toLowerCase
+ //replace all unsafe and reserved characters
+ convertCharacters(txtLower, replacement)
+ }
+
+ def transliterate(s: String) = {
+ Transliterator.getInstance(TransliterateRules.latinToASCII).transliterate(s)
+ }
+
+/*
+ * URL unsafe characters list
+ * reserved: URLs use some characters for special use in defining their syntax.
+ * reserved: $ & + , / : ; = ? @
+ * unsafe: Some characters present the possibility of being misunderstood within URLs
+ * unsafe: space # % { } | \ ^ ~ [ ] ' "
+ */
+ def convertCharacters(txt: String, replacement: String) = {
+ convertReservedCharacters(convertUnsafeCharacters(txt, replacement), replacement)
+ }
+
+ private def convertReservedCharacters(txt: String, replacement: String) =
+ txt.replaceAll("[$,&,+,,,/,:,;,=,?,@]", replacement)
+
+ private def convertUnsafeCharacters(txt: String, replacement: String) =
+ txt.replaceAll("""[ ,#,%,{,},|,\\,^,~,[,],']""", replacement)
+
+}
View
8 Sluggifier/src/main/scala/hr/element/sluggifier/TransliterateRules.scala
@@ -0,0 +1,8 @@
+package hr.element.sluggifier
+
+object TransliterateRules {
+ /* more rules available at:
+ * http://www.icu-project.org/icu-bin/translit?TEMPLATE_FILE=data/translit_rule_main.html
+ */
+ val latinToASCII = "Latin-ASCII"
+}
View
4 continuous-compilation.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+echo Entering continuous compilation loop ...
+`dirname $0`/sbt.sh --loop --no-jrebel "$@" ~compile
View
5 prepare-workspace.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+echo Performing dependency update for all projects ...
+echo Will also create Eclipse .project and .classpath files ...
+`dirname $0`/sbt.sh --no-jrebel "$@" update eclipse
View
15 project/Dependencies.scala
@@ -0,0 +1,15 @@
+import sbt._
+import Keys._
+
+import Helpers._
+import Dependencies._
+
+object Dependencies {
+ val scalatest = "org.scalatest" %% "scalatest" % "1.7.1" % "test"
+
+ val icu4j = "com.ibm.icu" % "icu4j" % "2.6.1"
+
+
+
+
+}
View
160 project/SharedSettings.scala
@@ -0,0 +1,160 @@
+import sbt._
+import Keys._
+
+import Helpers._
+import Dependencies._
+
+object InitialCommands {
+ val settings = Seq(
+ )
+}
+
+
+// ---------------------------------------------------------------------------
+
+object Default {
+ val settings =
+ Defaults.defaultSettings ++
+ Resolvers.settings ++
+ Publishing.settings ++
+ Format.settings ++ Seq(
+ organization := "hr.element.sluggifier",
+ crossScalaVersions := Seq("2.9.1", "2.9.0-1", "2.9.0"),
+ scalaVersion <<= (crossScalaVersions) { versions => versions.head },
+ scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "UTF-8", "-optimise", "-Yrepl-sync"),
+ javacOptions := Seq("-deprecation", "-encoding", "UTF-8", "-source", "1.6", "-target", "1.6"),
+ unmanagedSourceDirectories in Compile <<= (scalaSource in Compile)( _ :: Nil),
+ unmanagedSourceDirectories in Test <<= (scalaSource in Test )( _ :: Nil)
+ )
+
+
+}
+
+// ---------------------------------------------------------------------------
+
+object Repositories {
+ val ElementNexus = "Element Nexus" at "http://maven.element.hr/nexus/content/groups/public/"
+ val ElementReleases = "Element Releases" at "http://maven.element.hr/nexus/content/repositories/releases/"
+ val ElementSnapshots = "Element Snapshots" at "http://maven.element.hr/nexus/content/repositories/snapshots/"
+ val Maven2 = "Maven2" at "http://repo2.maven.org/maven2/"
+
+
+}
+
+// ---------------------------------------------------------------------------
+
+object Resolvers {
+ import Repositories._
+
+ val settings = Seq(
+ resolvers := Seq(
+ ElementNexus
+ , ElementReleases
+ , ElementSnapshots
+ , Maven2
+ ),
+ externalResolvers <<= resolvers map { rs =>
+ Resolver.withDefaultResolvers(rs, mavenCentral = true, scalaTools = false)
+ }
+ )
+}
+
+// ---------------------------------------------------------------------------
+
+object Publishing {
+ import Repositories._
+
+ val settings = Seq(
+ publishTo <<= (version) { version => Some(
+ if (version.endsWith("SNAPSHOT")) ElementSnapshots else ElementReleases
+ )},
+ credentials += Credentials(Path.userHome / ".publish" / "element.credentials"),
+ publishArtifact in (Compile, packageSrc) := false,
+ publishArtifact in (Compile, packageDoc) := false
+ )
+}
+
+// ---------------------------------------------------------------------------
+
+object Format {
+ // Scalariform plugin
+ import com.typesafe.sbtscalariform._
+ import ScalariformPlugin._
+ import scalariform.formatter.preferences._
+
+ ScalariformKeys.preferences := FormattingPreferences()
+ .setPreference(AlignParameters, false)
+ .setPreference(AlignSingleLineCaseStatements, false)
+ .setPreference(AlignSingleLineCaseStatements.MaxArrowIndent, 40)
+ .setPreference(CompactControlReadability, false)
+ .setPreference(CompactStringConcatenation, false)
+ .setPreference(DoubleIndentClassDeclaration, true)
+ .setPreference(FormatXml, false)
+ .setPreference(IndentLocalDefs, false)
+ .setPreference(IndentPackageBlocks, false)
+ .setPreference(IndentSpaces, 2)
+ .setPreference(IndentWithTabs, false)
+ .setPreference(MultilineScaladocCommentsStartOnFirstLine, true)
+ .setPreference(PlaceScaladocAsterisksBeneathSecondAsterisk, true)
+ .setPreference(PreserveDanglingCloseParenthesis, false)
+ .setPreference(PreserveSpaceBeforeArguments, false)
+ .setPreference(RewriteArrowSymbols, false)
+ .setPreference(SpaceBeforeColon, false)
+ .setPreference(SpaceInsideBrackets, false)
+ .setPreference(SpaceInsideParentheses, false)
+ .setPreference(SpacesWithinPatternBinders, true)
+
+ lazy val settings =
+ ScalariformPlugin.defaultScalariformSettings
+}
+
+// ---------------------------------------------------------------------------
+
+object Helpers {
+ implicit def depToFunSeq(m: ModuleID) = Seq((_: String) => m)
+ implicit def depFunToSeq(fm: String => ModuleID) = Seq(fm)
+ implicit def depSeqToFun(mA: Seq[ModuleID]) = mA.map(m => ((_: String) => m))
+ implicit def warName2SMA(name: String) = (_: String, _: ModuleID, _: Artifact) => name
+
+// ---------------------------------------------------------------------------
+
+ def top(
+ title: String,
+ projectAggs: Seq[sbt.ProjectReference] = Seq()) =
+ Project(
+ title,
+ file("."),
+ settings = Default.settings ++ Seq(
+ name := title,
+ version := "0.0.0"
+ )
+ ) aggregate(projectAggs: _*)
+
+ def parent(
+ title: String,
+ projectAggs: Seq[sbt.ProjectReference] = Seq()) =
+ Project(
+ title,
+ file(title.replace('-', '/')),
+ settings = Default.settings ++ Seq(
+ name := "Sluggifier-" + title,
+ version := "0.0.0"
+ )
+ ) aggregate(projectAggs: _*)
+
+ def project(
+ title: String,
+ ver: String,
+ deps: Seq[Seq[String => ModuleID]] = Seq(),
+ projectDeps: Seq[ClasspathDep[ProjectReference]] = Seq()) =
+ Project(
+ title,
+ file(title.replace('-', '/')),
+ settings = Default.settings ++ Seq(
+ name := "Sluggifier-" + title,
+ version := ver
+ ) :+ (libraryDependencies <++= scalaVersion( sV =>
+ for (depSeq <- deps; dep <- depSeq) yield dep(sV))
+ )
+ ) dependsOn(projectDeps: _*)
+}
View
18 project/Sluggifier.scala
@@ -0,0 +1,18 @@
+import sbt._
+import Keys._
+
+import Helpers._
+import Dependencies._
+
+object Sluggifier extends Build{
+ lazy val sluggifier = project(
+ "Sluggifier",
+ "0.0.1",
+ Seq(
+ icu4j
+ ),
+ Seq(
+ )
+ )
+}
+
View
31 project/plugins.sbt
@@ -0,0 +1,31 @@
+// +-------------------------------------------------------------------------------------+
+// | SBT Eclipse (https://github.com/typesafehub/sbteclipse) |
+// | Creates .project and .classpath files for easy Eclipse project imports |
+// | |
+// | See also: Eclipse downloads (http://www.eclipse.org/downloads/) |
+// | See also: Scala IDE downloads (http://download.scala-ide.org/) |
+// +-------------------------------------------------------------------------------------+
+
+resolvers += Classpaths.typesafeResolver
+
+addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.0.0-RC1")
+
+// +-------------------------------------------------------------------------------------+
+// | SBT Scalariform (https://github.com/typesafehub/sbtscalariform) |
+// | Performs source code formatting |
+// | |
+// | See also: Scalariform reference (http://mdr.github.com/scalariform/) |
+// +-------------------------------------------------------------------------------------+
+
+resolvers += Classpaths.typesafeResolver
+
+addSbtPlugin("com.typesafe.sbtscalariform" % "sbtscalariform" % "0.3.0")
+
+resolvers:= Seq("Apache Maven" at "http://mvnrepository.com/artifact/")
+
+externalResolvers <<= resolvers map { rs =>
+ Resolver.withDefaultResolvers(rs, mavenCentral = true, scalaTools = false)
+}
+
+
+
View
BIN  project/strap/gruj_vs_sbt-launch-0.11.2.jar
Binary file not shown
View
2  sbt.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+java -jar project/strap/sbt-launch-0.11.2.jar
Please sign in to comment.
Something went wrong with that request. Please try again.