Permalink
Browse files

removed nested duplicate

  • Loading branch information...
1 parent 62d5de4 commit 994d68090c33dd6b248e1792e7675458adcf9858 @brocchini committed Apr 24, 2012
@@ -1,31 +0,0 @@
-package controllers;
-
-import play.*;
-import play.mvc.*;
-
-import java.util.*;
-
-import models.*;
-
-public class Application extends Controller {
-
- public static void index() {
- List<Translation> translations = allTranslations();
- render( translations );
- }
-
- public static void listTranslationsInJson()
- {
- renderJSON( allTranslations() );
- }
-
- private static List<Translation> allTranslations()
- {
- return Translation.findAll();
- }
-
- public static void translateMessageAsText(String sourceText)
- {
- renderText( Translation.translate( sourceText ) );
- }
-}
@@ -1,9 +0,0 @@
-package controllers;
-
-import models.KeyPrefix;
-import play.mvc.Controller;
-
-@CRUD.For(KeyPrefix.class)
-public class KeyPrefixes extends CRUD {
-
-}
@@ -1,5 +0,0 @@
-package controllers;
-
-public class Translations extends CRUD {
-
-}
@@ -1,16 +0,0 @@
-package jobs;
-import models.Translation;
-import play.jobs.Job;
-import play.jobs.OnApplicationStart;
-import play.test.Fixtures;
-
-@OnApplicationStart
-public class Bootstrap extends Job
-{
- public void doJob() {
- // Check if the database is empty
- if(Translation.count() == 0) {
- Fixtures.loadModels("initial-data.yml");
- }
-}
-}
@@ -1,44 +0,0 @@
-package models;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Pattern;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-
-
-import play.db.jpa.Model;
-
-@Entity
-public class KeyPrefix extends Model {
- @Column(unique=true)
- public String prefix;
-
- // Factory method to create a Regex pattern to find words beginning with any of the KeyPrefixes in the database
- public static Pattern pattern()
- {
- final StringBuilder buffer = new StringBuilder();
-
- //Start with a word boundary
- buffer.append("\\b(");
-
- // Concatenate all prefixes with an OR separator "|"
- List<KeyPrefix> all = KeyPrefix.findAll();
- for (KeyPrefix keyPrefix : all)
- {
- buffer.append(java.util.regex.Pattern.quote( keyPrefix.prefix ) );
- buffer.append( "|");
- }
-
- //Remove last separator bar
- buffer.deleteCharAt( buffer.length() - 1 );
-
- // End with a closing word boundary
- buffer.append(")\\w*\\b");
- Pattern p = Pattern.compile( buffer.toString() );
- return p;
-
- }
-
-}
@@ -1,84 +0,0 @@
-package models;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Matcher;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.Table;
-
-
-import play.db.jpa.Model;
-
-/**
- * Translates messages by matching a key within the message
- *
- * @author Mozart Brocchini
- * @since 04/01/2012
- */
-@Entity
-public class Translation extends Model
-{
- @Column(name = "translation_key")
- public String key;
-
- @Column(name = "translation_type", length = 1)
- public String type;
-
- public String message;
-
- public Translation( String key, String type, String message )
- {
- super();
- this.key = key;
- this.type = type;
- this.message = message;
- }
-
- /**
- * This function finds a unique key in a message and looks for
- * a translation in the internal dictionary.
- * @param sourceMessage
- * @return
- */
- public static String translate( String sourceMessage )
- {
- String key = findKey( sourceMessage );
- if( key == null )
- {
- return "";
- }
-
- Translation translation = Translation.find( "byKey", key )
- .first();
- if( translation != null )
- {
- return translation.message;
- }
- return "";
- }
-
- @Override
- public String toString()
- {
- return "Translation [id=" + id + ", key=" + key + ", type=" + type
- + ", message=" + message + "]";
- }
-
- /**
- * Looks for words starting with any of the prefixes
- * @return The first key found in the source message
- */
- public static String findKey( String sourceMessage )
- {
- Matcher m = KeyPrefix.pattern().matcher( sourceMessage );
- if ( m.find() )
- {
- return m.group();
- }
-
- return null;
- }
-
-}
@@ -1,19 +0,0 @@
-#{extends 'main.html' /}
-#{set title:'Home' /}
-
-#{if translations.size()}
- <div class="title">
- <h3>${translations.size()} Translations available</h3>
- </div>
- <div class="allmessages">
- #{list items:translations, as:'oneTranslation'}
- #{display translation:oneTranslation /}
- #{/list}
- </div>
-#{/if}
-
-#{else}
- <div class="empty">
- There is currently no translations to list here.
- </div>
-#{/else}
@@ -1,19 +0,0 @@
-<!DOCTYPE html>
-
-<html>
- <head>
- <title>Not found</title>
- <meta http-equiv="Content-Type" content="text/html; charset=${_response_encoding}"/>
- </head>
- <body>
- #{if play.mode.name() == 'DEV'}
- #{404 result /}
- #{/if}
- #{else}
- <h1>Not found</h1>
- <p>
- ${result.message}
- </p>
- #{/else}
- </body>
-</html>
@@ -1,21 +0,0 @@
-<!DOCTYPE html>
-
-<html>
- <head>
- <title>Application error</title>
- <meta http-equiv="Content-Type" content="text/html; charset=${_response_encoding}"/>
- </head>
- <body>
- #{if play.mode.name() == 'DEV'}
- #{500 exception /}
- #{/if}
- #{else}
- <h1>Oops, an error occured</h1>
- #{if exception instanceof play.exceptions.PlayException}
- <p>
- This exception has been logged with id <strong>${exception.id}</strong>.
- </p>
- #{/if}
- #{/else}
- </body>
-</html>
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-
-<html>
- <head>
- <title>#{get 'title' /}</title>
- <meta charset="${_response_encoding}">
- <link rel="stylesheet" media="screen" href="@{'/public/stylesheets/main.css'}">
- #{get 'moreStyles' /}
- <link rel="shortcut icon" type="image/png" href="@{'/public/images/favicon.png'}">
- <script src="@{'/public/javascripts/jquery-1.6.4.min.js'}" type="text/javascript" charset="${_response_encoding}"></script>
- #{get 'moreScripts' /}
- </head>
- <body>
- #{doLayout /}
- </body>
-</html>
@@ -1,6 +0,0 @@
-*{ Display an translation message }*
-<div class="message">
- key <span class="message-key"> ${_translation.key},</span>
- <span class="message-type"> ${_translation.type == 'D' ? 'Diagnostic': 'Solution'} </span>
- <div class="message-content">${_translation.message.escape().nl2br()}</div>
-</div>
Oops, something went wrong.

0 comments on commit 994d680

Please sign in to comment.