[Tynstep-svn] r255 - in trunk/step: step-core/src/main/java/com/tyndalehouse/step/core/data/entities step-core/src/main/java/com/tyndalehouse/step/core/guice/providers step-core/src/main/java/com/tyndalehouse/step/core/models step-core/src/main/java/com/tyndalehouse/step/core/service step-core/src/main/java/com/tyndalehouse/step/core/service/impl step-core/src/main/resources step-core/src/test/java/com/tyndalehouse/step/core step-core/src/test/java/com/tyndalehouse/step/core/scratch step-web/src/main/java/com/tyndalehouse/step/guice/providers step-web/src/main/java/com/tyndalehouse/step/models step-web/src/main/java/com/tyndalehouse/step/rest/controllers step-web/src/main/java/com/tyndalehouse/step/rest/framework step-web/src/main/webapp step-web/src/main/webapp/js step-web/src/main/webapp/libs step-web/src/main/webapp/libs/menu step-web/src/test/java/com/tyndalehouse/step/rest/controllers step-web/src/test/java/com/tyndalehouse/step/rest/framework
ChrisBurrell at crosswire.org
ChrisBurrell at crosswire.org
Tue Apr 24 13:30:42 MST 2012
Author: ChrisBurrell
Date: 2012-04-24 13:30:42 -0700 (Tue, 24 Apr 2012)
New Revision: 255
Added:
trunk/step/step-core/src/test/java/com/tyndalehouse/step/core/scratch/
trunk/step/step-core/src/test/java/com/tyndalehouse/step/core/scratch/ScratchTest.java
Modified:
trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/data/entities/User.java
trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/guice/providers/TestData.java
trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/models/ClientSession.java
trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/BibleInformationService.java
trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/JSwordService.java
trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/BibleInformationServiceImpl.java
trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/JSwordServiceImpl.java
trunk/step/step-core/src/main/resources/step.core.properties
trunk/step/step-web/src/main/java/com/tyndalehouse/step/guice/providers/ClientSessionProvider.java
trunk/step/step-web/src/main/java/com/tyndalehouse/step/models/WebSessionImpl.java
trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/controllers/BibleController.java
trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/framework/FrontController.java
trunk/step/step-web/src/main/webapp/js/init.js
trunk/step/step-web/src/main/webapp/js/passage.js
trunk/step/step-web/src/main/webapp/js/top_menu.js
trunk/step/step-web/src/main/webapp/js/ui_hooks.js
trunk/step/step-web/src/main/webapp/libs/jquery-shout.js
trunk/step/step-web/src/main/webapp/libs/menu/ddsmoothmenu.css
trunk/step/step-web/src/main/webapp/topmenu.html
trunk/step/step-web/src/test/java/com/tyndalehouse/step/rest/controllers/BibleControllerTest.java
trunk/step/step-web/src/test/java/com/tyndalehouse/step/rest/framework/FrontControllerTest.java
Log:
TYNSTEP-108, filtering available versions to current language (either User profile or locale of browser) + Ancient Greek and Hebrew.
Modified: trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/data/entities/User.java
===================================================================
--- trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/data/entities/User.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/data/entities/User.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -38,6 +38,9 @@
@Column
private String country;
+ @Column
+ private String language;
+
/**
* @return the id
*/
@@ -121,4 +124,18 @@
public void setSalt(final byte[] salt) {
this.salt = salt.clone();
}
+
+ /**
+ * @return the language
+ */
+ public String getLanguage() {
+ return this.language;
+ }
+
+ /**
+ * @param language the language to set
+ */
+ public void setLanguage(final String language) {
+ this.language = language;
+ }
}
Modified: trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/guice/providers/TestData.java
===================================================================
--- trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/guice/providers/TestData.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/guice/providers/TestData.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -4,6 +4,10 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import com.avaje.ebean.EbeanServer;
import com.avaje.ebean.Transaction;
import com.google.inject.Inject;
@@ -13,6 +17,7 @@
import com.tyndalehouse.step.core.data.entities.Bookmark;
import com.tyndalehouse.step.core.data.entities.History;
import com.tyndalehouse.step.core.data.entities.User;
+import com.tyndalehouse.step.core.service.JSwordService;
import com.tyndalehouse.step.core.service.UserDataService;
/**
@@ -23,9 +28,11 @@
*/
@Singleton
public class TestData {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestData.class);
private final EbeanServer ebean;
private final UserDataService userService;
private final int numCryptoIterations;
+ private final JSwordService jsword;
/**
* @param ebean the ebean server to persist objects with
@@ -33,20 +40,42 @@
* @param numCryptoIterations the number of iterations to perform - we need since we hook in to the user
* data service from a different viewpoint
* @param loader the loader that should be called upon installation mainly
+ * @param jsword jsword services
*/
@Inject
public TestData(final EbeanServer ebean, final UserDataService userService,
- @Named("app.security.numIterations") final int numCryptoIterations, final Loader loader) {
+ @Named("app.security.numIterations") final int numCryptoIterations, final Loader loader,
+ @Named("test.data.modules") final String coreModules, final JSwordService jsword) {
this.ebean = ebean;
this.userService = userService;
this.numCryptoIterations = numCryptoIterations;
+ this.jsword = jsword;
final User u = getUser();
createBookmarks(u);
createHistory(u);
loader.init();
+
+ loadDefaultJSwordModules(coreModules);
}
/**
+ * installs core jsword modules
+ *
+ * @param coreModules a comma separated list of modules
+ */
+ private void loadDefaultJSwordModules(final String coreModules) {
+ final String[] modules = StringUtils.split(coreModules, ",");
+ for (final String m : modules) {
+ if (!this.jsword.isInstalled(m)) {
+ this.jsword.installBook(m);
+ LOGGER.info("Installing {} module", m);
+ } else {
+ LOGGER.info("Book {} already installed", m);
+ }
+ }
+ }
+
+ /**
* creates a history item for the test user
*
* @param u the user
Modified: trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/models/ClientSession.java
===================================================================
--- trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/models/ClientSession.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/models/ClientSession.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -20,4 +20,9 @@
* @return the IP address
*/
String getIpAddress();
+
+ /**
+ * @return the preferred language of the user
+ */
+ String getLanguage();
}
Modified: trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/BibleInformationService.java
===================================================================
--- trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/BibleInformationService.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/BibleInformationService.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -18,9 +18,12 @@
/**
* Queries Jsword to return all the installed versions of the bible
*
+ * @param locale the locale of the requester
+ * @param allVersions a boolean indicating whether all versions should be returned
+ *
* @return all the available versions of the bible
*/
- List<BibleVersion> getAvailableBibleVersions();
+ List<BibleVersion> getAvailableBibleVersions(boolean allVersions, String locale);
/**
* This method selects passage text and forms XML for the client. This is done server side so that the
Modified: trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/JSwordService.java
===================================================================
--- trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/JSwordService.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/JSwordService.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -44,6 +44,16 @@
List<Book> getInstalledModules(BookCategory... bibleCategory);
/**
+ * looks up any installed module
+ *
+ * @param bibleCategory the categories of the modules to be returned
+ * @param allVersions indicates all versions of the bible
+ * @param locale specifies a particular language of interest + defaults
+ * @return a list of bible books
+ */
+ List<Book> getInstalledModules(boolean allVersions, String locale, BookCategory... bibleCategory);
+
+ /**
* Gets the features for a module
*
* @param version the initials of the book to look up
@@ -98,4 +108,5 @@
* @return a list of matching bible book names
*/
List<String> getBibleBookNames(String bookStart, String version);
+
}
Modified: trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/BibleInformationServiceImpl.java
===================================================================
--- trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/BibleInformationServiceImpl.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/BibleInformationServiceImpl.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -46,9 +46,10 @@
}
@Override
- public List<BibleVersion> getAvailableBibleVersions() {
+ public List<BibleVersion> getAvailableBibleVersions(final boolean allVersions, final String locale) {
LOGGER.info("Getting bible versions");
- return getSortedSerialisableList(this.jsword.getInstalledModules(BookCategory.BIBLE));
+ return getSortedSerialisableList(this.jsword.getInstalledModules(allVersions, locale,
+ BookCategory.BIBLE));
}
@Override
Modified: trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/JSwordServiceImpl.java
===================================================================
--- trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/JSwordServiceImpl.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-core/src/main/java/com/tyndalehouse/step/core/service/impl/JSwordServiceImpl.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -4,6 +4,7 @@
import static org.apache.commons.lang.StringUtils.isBlank;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.apache.commons.lang.StringUtils.isNotEmpty;
+import static org.apache.commons.lang.Validate.notNull;
import static org.crosswire.jsword.book.BookCategory.BIBLE;
import java.net.URI;
@@ -62,7 +63,10 @@
*/
@Singleton
public class JSwordServiceImpl implements JSwordService {
+ private static final String ANCIENT_GREEK = "grc";
+ private static final String ANCIENT_HEBREW = "hbo";
private static final Logger LOGGER = LoggerFactory.getLogger(JSwordServiceImpl.class);
+
private final List<Installer> bookInstallers;
/**
@@ -75,12 +79,13 @@
this.bookInstallers = installers;
}
- /**
- * @param bibleCategory the categories of books that should be considered
- * @return returns a list of installed modules
- */
@Override
- public List<Book> getInstalledModules(final BookCategory... bibleCategory) {
+ public List<Book> getInstalledModules(final boolean allVersions, final String locale,
+ final BookCategory... bibleCategory) {
+ if (!allVersions) {
+ notNull(locale, "Locale was not passed by requester");
+ }
+
if (bibleCategory == null || bibleCategory.length == 0) {
return new ArrayList<Book>();
}
@@ -96,13 +101,25 @@
@Override
@SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation")
public boolean test(final Book b) {
- return categories.contains(b.getBookCategory());
+ return categories.contains(b.getBookCategory())
+ && (allVersions || ANCIENT_GREEK.equals(b.getLanguage().getCode())
+ || ANCIENT_HEBREW.equals(b.getLanguage().getCode()) || locale.equals(b
+ .getLanguage().getCode()));
}
};
return Books.installed().getBooks(bf);
}
/**
+ * @param bibleCategory the categories of books that should be considered
+ * @return returns a list of installed modules
+ */
+ @Override
+ public List<Book> getInstalledModules(final BookCategory... bibleCategory) {
+ return getInstalledModules(true, null, bibleCategory);
+ }
+
+ /**
* @param bibleCategory the list of books that should be considered
* @return a list of all modules
*/
Modified: trunk/step/step-core/src/main/resources/step.core.properties
===================================================================
--- trunk/step/step-core/src/main/resources/step.core.properties 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-core/src/main/resources/step.core.properties 2012-04-24 20:30:42 UTC (rev 255)
@@ -13,6 +13,7 @@
#Test data related questions
test.data.load=true
+test.data.modules=ABPGRK,Byz,Tisch,LXX,SBLGNT,OxfordTR,Elzevir,WHNU,TR,Antoniades,KJV,ESV,Tyndale,YLT,NETfree,ASV,FreMartin,FreSegond,ChiUns,StrongsGreek,Robinson,StrongsHebrew
# Database parameters - these will vary depending on the connection
app.db.driver=org.h2.Driver
Added: trunk/step/step-core/src/test/java/com/tyndalehouse/step/core/scratch/ScratchTest.java
===================================================================
--- trunk/step/step-core/src/test/java/com/tyndalehouse/step/core/scratch/ScratchTest.java (rev 0)
+++ trunk/step/step-core/src/test/java/com/tyndalehouse/step/core/scratch/ScratchTest.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -0,0 +1,39 @@
+package com.tyndalehouse.step.core.scratch;
+
+import org.junit.Test;
+
+/**
+ * A default test to do whatever we want
+ *
+ * @author Chris
+ *
+ */
+public class ScratchTest {
+ // @Test
+ // public void testListOfVersions() throws InstallException {
+ // final String[] split = StringUtils.split(
+ // "www.crosswire.org,/ftpmirror/pub/sword/packages/rawzip,/ftpmirror/pub/sword/raw", ",");
+ // final HttpSwordInstaller i = new HttpSwordInstaller();
+ //
+ // i.setHost(split[0]);
+ // i.setPackageDirectory(split[1]);
+ // i.setCatalogDirectory(split[2]);
+ //
+ // i.reloadBookList();
+ //
+ // final List<Book> books = i.getBooks();
+ //
+ // for (final Book book : books) {
+ // if (book.getBookCategory().equals(BookCategory.DICTIONARY)
+ // && book.getLanguage().getCode().equals("en")) {
+ // System.out.println(book.getLanguage().getCode() + " " + book.getInitials());
+ // }
+ // }
+ //
+ // }
+
+ @Test
+ public void simpleTest() {
+
+ }
+}
Property changes on: trunk/step/step-core/src/test/java/com/tyndalehouse/step/core/scratch/ScratchTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/step/step-web/src/main/java/com/tyndalehouse/step/guice/providers/ClientSessionProvider.java
===================================================================
--- trunk/step/step-web/src/main/java/com/tyndalehouse/step/guice/providers/ClientSessionProvider.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/main/java/com/tyndalehouse/step/guice/providers/ClientSessionProvider.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -1,5 +1,6 @@
package com.tyndalehouse.step.guice.providers;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import com.google.inject.Inject;
@@ -18,21 +19,23 @@
@RequestScoped
public class ClientSessionProvider implements Provider<ClientSession> {
private final HttpSession session;
+ private final HttpServletRequest request;
/**
* We inject the HttpSession in so that we can reference the jSessionId in the cookie
*
+ * @param request the http request
* @param session the http session containing the jSessionId
*/
@Inject
- public ClientSessionProvider(final HttpSession session) {
+ public ClientSessionProvider(final HttpServletRequest request, final HttpSession session) {
+ this.request = request;
this.session = session;
-
}
@Override
public ClientSession get() {
// check if this has the IP address in it
- return new WebSessionImpl(this.session.getId());
+ return new WebSessionImpl(this.session.getId(), this.request.getLocale().getISO3Language());
}
}
Modified: trunk/step/step-web/src/main/java/com/tyndalehouse/step/models/WebSessionImpl.java
===================================================================
--- trunk/step/step-web/src/main/java/com/tyndalehouse/step/models/WebSessionImpl.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/main/java/com/tyndalehouse/step/models/WebSessionImpl.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -11,14 +11,16 @@
public class WebSessionImpl implements ClientSession {
private String sessionId;
private String ipAddress;
+ private String language;
/**
* creates a web session
*
* @param id the id of the session
*/
- public WebSessionImpl(final String id) {
+ public WebSessionImpl(final String id, final String language) {
this.sessionId = id;
+ this.language = language;
}
/**
@@ -50,4 +52,16 @@
public void setIpAddress(final String ipAddress) {
this.ipAddress = ipAddress;
}
+
+ @Override
+ public String getLanguage() {
+ return this.language;
+ }
+
+ /**
+ * @param language the language to set
+ */
+ public void setLanguage(final String language) {
+ this.language = language;
+ }
}
Modified: trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/controllers/BibleController.java
===================================================================
--- trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/controllers/BibleController.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/controllers/BibleController.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -11,8 +11,12 @@
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
+import com.google.inject.Provider;
import com.google.inject.Singleton;
+import com.tyndalehouse.step.core.data.entities.Session;
+import com.tyndalehouse.step.core.data.entities.User;
import com.tyndalehouse.step.core.models.BibleVersion;
+import com.tyndalehouse.step.core.models.ClientSession;
import com.tyndalehouse.step.core.models.EnrichedLookupOption;
import com.tyndalehouse.step.core.models.LookupOption;
import com.tyndalehouse.step.core.service.BibleInformationService;
@@ -30,16 +34,21 @@
private static final long serialVersionUID = -5176839737814243641L;
private static final Logger LOGGER = LoggerFactory.getLogger(BibleController.class);
private final BibleInformationService bibleInformation;
+ private final Provider<Session> serverSession;
+ private final Provider<ClientSession> clientSession;
/**
* creates the controller giving access to bible information
*
* @param bibleInformation the service allowing access to biblical material
+ * @param serverSession session
*/
@Inject
- public BibleController(final BibleInformationService bibleInformation) {
-
+ public BibleController(final BibleInformationService bibleInformation,
+ final Provider<Session> serverSession, final Provider<ClientSession> clientSession) {
this.bibleInformation = bibleInformation;
+ this.serverSession = serverSession;
+ this.clientSession = clientSession;
LOGGER.debug("Created Bible Controller");
}
@@ -50,10 +59,23 @@
*/
@Cacheable(true)
public List<BibleVersion> getBibleVersions() {
- return this.bibleInformation.getAvailableBibleVersions();
+ return this.bibleInformation.getAvailableBibleVersions(true, null);
}
/**
+ * a REST method that returns version of the Bible that are available
+ *
+ * @param allVersions boolean to indicate whether all versions should be returned
+ * @return all versions of modules that are considered to be Bibles.
+ */
+ @Cacheable(true)
+ public List<BibleVersion> getBibleVersions(final String allVersions) {
+ final User user = this.serverSession.get().getUser();
+ final String language = user == null ? this.clientSession.get().getLanguage() : user.getLanguage();
+ return this.bibleInformation.getAvailableBibleVersions(Boolean.valueOf(allVersions), language);
+ }
+
+ /**
* a REST method that returns text from the Bible
*
* @param version the initials identifying the version
Modified: trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/framework/FrontController.java
===================================================================
--- trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/framework/FrontController.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/main/java/com/tyndalehouse/step/rest/framework/FrontController.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -134,6 +134,33 @@
// CHECKSTYLE:ON
}
+ // /**
+ // * casts objects to the appropriate types
+ // *
+ // * @param parameterTypes the parameter types expected
+ // * @param args the arguments passed in
+ // * @return the set of cast arguments
+ // */
+ // private Object[] parseArgs(final Class<?>[] parameterTypes, final String[] args) {
+ // final Object[] newArgs = new String[parameterTypes.length];
+ //
+ // for (int ii = 0; ii < parameterTypes.length; ii++) {
+ // // deal with nulls
+ // if (ii > args.length) {
+ // newArgs[ii] = null;
+ // } else {
+ // if (boolean.class.equals(parameterTypes[ii])) {
+ // newArgs[ii] = Boolean.valueOf(args[ii]);
+ // } else {
+ // newArgs[ii] = args[ii];
+ // }
+ // }
+ // }
+ //
+ // // TODO Auto-generated method stub
+ // return null;
+ // }
+
/**
* We attempt here to rethrow the exception that caused the invocation target exception, so that we can
* handle it nicely for the user
Modified: trunk/step/step-web/src/main/webapp/js/init.js
===================================================================
--- trunk/step/step-web/src/main/webapp/js/init.js 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/main/webapp/js/init.js 2012-04-24 20:30:42 UTC (rev 255)
@@ -80,22 +80,18 @@
}
function initMenu() {
- ddsmoothmenu.init({
- mainmenuid: "topMenu-ajax", //menu DIV id
- zIndexStart: 1000,
- orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
- classname: 'ddsmoothmenu topMenu', //class added to menu's outer DIV
- //customtheme: ["#1c5a80", "#18374a"],
- contentsource: ["topMenu", "topmenu.html"]
- });
-// new TopMenu($("#topMenu-ajax");
+ $.get("topmenu.html", function(data) {
+ var topMenu = $("#topMenu");
+ topMenu.html(data);
+ new TopMenu($("#topMenu-ajax"));
+ });
$.get("panemenu.html", function(data) {
var menusToBe = $(".innerMenus");
menusToBe.html(data);
menusToBe.each(function(index, value) {
- new ToolbarMenu(index, value);
+ new ToolbarMenu(index, value);
});
});
}
@@ -151,33 +147,18 @@
var strongedVersions = [];
var ii = 0;
- $.getJSON(BIBLE_GET_BIBLE_VERSIONS, function(data) {
- var parsedResponse = $.map(data, function(item) {
+ $.getJSON(BIBLE_GET_BIBLE_VERSIONS + "false", function(versionsFromServer) {
+
+ $.each(versionsFromServer, function(index, item) {
var showingText = "[" + item.initials + "] " + item.name;
- var features = "";
-
- //add to strongs if applicable
if(item.hasStrongs) {
- features += " " + "<span class='versionFeature strongsFeature' title='Supports Strongs concordance'>S</span>";
- features += " " + "<span class='versionFeature interlinearFeature' title='Supports interlinear feature'>I</span>";
strongedVersions[ii++] = { label: showingText, value: item.initials};
}
-
- if(item.hasMorphology) {
- features += " " + "<span class='versionFeature morphologyFeature' title='Supports morphology feature'>M</span>";
- }
-
- //return response for dropdowns
- return {
- label : showingText,
- value : item.initials,
- features: features
- }
});
//add the ALL Version, by iterating through all found versions and adding them as the value
var allVersionsKey = "";
- var passages = initPassages(parsedResponse, options);
+ var passages = initPassages(versionsFromServer, options);
initInterlinearPopup(strongedVersions);
initModules(passages);
});
Modified: trunk/step/step-web/src/main/webapp/js/passage.js
===================================================================
--- trunk/step/step-web/src/main/webapp/js/passage.js 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/main/webapp/js/passage.js 2012-04-24 20:30:42 UTC (rev 255)
@@ -5,7 +5,7 @@
* @param passageContainer the passage Container containing the whole control
* @param versions the list of versions to use to populate the dropdown
*/
-function Passage(passageContainer, versions, passageId) {
+function Passage(passageContainer, rawServerVersions, passageId) {
var self = this;
this.container = passageContainer;
this.version = $(".passageVersion", passageContainer);
@@ -17,7 +17,7 @@
//read state from the cookie
this.setInitialPassage();
- this.initVersionsTextBox(versions);
+ this.initVersionsTextBox(rawServerVersions);
this.initReferenceTextBox();
@@ -40,6 +40,10 @@
self.changePassage();
});
+ this.passage.hear("version-list-refresh", function(selfElement, versions) {
+ self.refreshVersionsTextBox(versions);
+ });
+
this.bookmarkButton.hear("bookmark-passage-" + this.passageId, function(selfElement, data) {
self.bookmarkButton.click();
});
@@ -51,15 +55,45 @@
});
};
+
/**
+ * refreshes the list attached to the version dropdown
+ */
+Passage.prototype.refreshVersionsTextBox = function(rawServerVersions) {
+ //need to make server response adequate for autocomplete:
+ var parsedVersions = $.map(rawServerVersions, function(item) {
+ var showingText = "[" + item.initials + "] " + item.name;
+ var features = "";
+ //add to Strongs if applicable, and therefore interlinear
+ if(item.hasStrongs) {
+ features += " " + "<span class='versionFeature strongsFeature' title='Supports Strongs concordance'>S</span>";
+ features += " " + "<span class='versionFeature interlinearFeature' title='Supports interlinear feature'>I</span>";
+ }
+
+ //add morphology
+ if(item.hasMorphology) {
+ features += " " + "<span class='versionFeature morphologyFeature' title='Supports morphology feature'>M</span>";
+ }
+
+ //return response for dropdowns
+ return {
+ label : showingText,
+ value : item.initials,
+ features: features
+ }
+ });
+
+ this.version.autocomplete({source: parsedVersions});
+};
+
+/**
* Sets up the autocomplete for the versions dropdown
*/
-Passage.prototype.initVersionsTextBox = function(versions) {
+Passage.prototype.initVersionsTextBox = function(rawServerVersions) {
var self = this;
// set up autocomplete
this.version.autocomplete({
- source : versions,
minLength: 0,
delay: 0,
select : function(event, ui) {
@@ -79,6 +113,7 @@
.appendTo( ul )
}
+ this.refreshVersionsTextBox(rawServerVersions)
};
Passage.prototype.initReferenceTextBox = function() {
Modified: trunk/step/step-web/src/main/webapp/js/top_menu.js
===================================================================
--- trunk/step/step-web/src/main/webapp/js/top_menu.js 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/main/webapp/js/top_menu.js 2012-04-24 20:30:42 UTC (rev 255)
@@ -3,38 +3,36 @@
* Represents the menu that will be at the top of the passage container
*/
function TopMenu(menuRoot) {
- this.menuRoot = $(menuRoot);
var self = this;
+ this.menuRoot = menuRoot;
+
ddsmoothmenu.init({
- mainmenuid: menuRoot.id, //menu DIV id
+ mainmenuid: menuRoot.attr("id"), //menu DIV id
zIndexStart: 1000,
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu topMenu', //class added to menu's outer DIV
- //customtheme: ["#1c5a80", "#18374a"],
- contentsource: ["topMenu", "topmenu.html"]
+ contentsource: "markup"
});
this.setDefaultOptions();
-// $(menuRoot).hear("pane-menu-toggle-item-" + this.passageId, function(selfElement, menuOptionName) {
-// self.toggleMenuItem(menuOptionName);
-// });
+ $(menuRoot).hear("pane-menu-toggle-item", function(selfElement, menuOption) {
+ self.toggleMenuItem(menuOption);
+ });
+
+ this.setupHearers();
}
-/**
- * @param selected true to select
- * @param menuItem the item name
- */
-TopMenu.prototype.selectMenuItem = function(menuItem, selected) {
- if(selected) {
- this.tickMenuItem(menuItem);
- } else {
- this.untickMenuItem(menuItem);
- }
-}
+TopMenu.prototype.setupHearers = function() {
+ this.menuRoot.hear("topmenu-LIMIT_AVAILABLE_MODULES", function(selfElement, enabled) {
+ var versions = $.getSafe(BIBLE_GET_BIBLE_VERSIONS + enabled, function(versions) {
+ // send events to passages and reload - then change init function
+ $.shout("version-list-refresh", versions);
+ });
+ });
+};
-
/**
* toggles the tick next to the element
* @param name of the element
@@ -44,13 +42,11 @@
var matchedSelectedIcon = $(this.getItemSelector(selectedItem)).children(".selectingTick");
if(matchedSelectedIcon.length) {
this.untickMenuItem(selectedItem);
+ $.shout("topmenu-" + selectedItem, false);
} else {
this.tickMenuItem(selectedItem);
+ $.shout("topmenu-" + selectedItem, true);
}
-
- //fire off options?
- //fire-off an event indicating that menu options have changed!
-// $.shout("toolbar-menu-options-changed-" + this.passageId);
}
}
@@ -88,10 +84,17 @@
* sets up the default options for the menu
*/
TopMenu.prototype.setDefaultOptions = function() {
- this.toggleMenuItem("LIMIT_AVAILABLE_MODULES");
+// this.toggleMenuItem("LIMIT_AVAILABLE_MODULES");
}
/**
+ * returns true if item is selected
+ */
+TopMenu.prototype.isItemSelected = function(name) {
+ return getItemSelector(name).children("img.selectingTick").length != 0;
+}
+
+/**
* returns all menu items matching the name specified
* TODO could add cache here based on name
*/
Modified: trunk/step/step-web/src/main/webapp/js/ui_hooks.js
===================================================================
--- trunk/step/step-web/src/main/webapp/js/ui_hooks.js 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/main/webapp/js/ui_hooks.js 2012-04-24 20:30:42 UTC (rev 255)
@@ -59,8 +59,16 @@
/** a simpler toggler for the menu items */
function toggleMenuItem(menuItem) {
- //the hook needs to find the passage id
- $.shout("pane-menu-toggle-item-" + getPassageId(menuItem), menuItem.name);
+ //the hook needs to find the passage id if we're a sub menu
+ var eventName = "pane-menu-toggle-item";
+ var passageId = getPassageId(menuItem);
+ if(passageId) {
+ eventName += "-" + passageId;
+ } else {
+ //append passage
+ }
+
+ $.shout(eventName, menuItem.name);
};
function changePassage(element, passageReference) {
Modified: trunk/step/step-web/src/main/webapp/libs/jquery-shout.js
===================================================================
--- trunk/step/step-web/src/main/webapp/libs/jquery-shout.js 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/main/webapp/libs/jquery-shout.js 2012-04-24 20:30:42 UTC (rev 255)
@@ -13,7 +13,9 @@
jQuery.extend(
{
_jq_shout: {},
+
shout: function (event, data){
+ console.log(event);
if(this._jq_shout.registry[event] != null) {
jQuery.each(this._jq_shout.registry[event],
function (){
Modified: trunk/step/step-web/src/main/webapp/libs/menu/ddsmoothmenu.css
===================================================================
--- trunk/step/step-web/src/main/webapp/libs/menu/ddsmoothmenu.css 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/main/webapp/libs/menu/ddsmoothmenu.css 2012-04-24 20:30:42 UTC (rev 255)
@@ -1,12 +1,12 @@
/* top menu */
.topMenu {
- background-color: #147000; /*background of menu bar (default state)*/
+ background-color: #629914; /*background of menu bar (default state)*/
border-bottom: 1px solid white;
}
/*Top level menu link items style*/
.topMenu ul li a,.ddsmoothmenu ul li label {
- background-color: #147000; /*background of menu items (default state)*/
+ background-color: #629914; /*background of menu items (default state)*/
border-right: 1px solid white;
color: white;
}
@@ -158,6 +158,10 @@
border-top-width: 0;
}
+#topMenu .ddsmoothmenu ul li ul li a {
+ width: 250px !important;
+}
+
/* Holly Hack for IE \*/
* html .ddsmoothmenu {
height: 1%;
Modified: trunk/step/step-web/src/main/webapp/topmenu.html
===================================================================
--- trunk/step/step-web/src/main/webapp/topmenu.html 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/main/webapp/topmenu.html 2012-04-24 20:30:42 UTC (rev 255)
@@ -13,7 +13,7 @@
<ul>
<li><a href="#" class="notYetImplemented">Install Bibles [Coming soon]</a></li>
<li><a href="#" class="notYetImplemented">Update [Coming soon]</a></li>
- <li><a href="#" name="LIMIT_AVAILABLE_MODULES" onclick="toggleMenuItem(this);">Show only my Bibles in my language</a></li>
+ <li><a href="#" name="LIMIT_AVAILABLE_MODULES" onclick="toggleMenuItem(this);">Show Bibles from every language</a></li>
<li><a href="#" class="notYetImplemented">User preferences [Coming soon]</a></li>
</ul>
</li>
Modified: trunk/step/step-web/src/test/java/com/tyndalehouse/step/rest/controllers/BibleControllerTest.java
===================================================================
--- trunk/step/step-web/src/test/java/com/tyndalehouse/step/rest/controllers/BibleControllerTest.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/test/java/com/tyndalehouse/step/rest/controllers/BibleControllerTest.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -8,11 +8,15 @@
import java.util.ArrayList;
import java.util.List;
+import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
+import com.tyndalehouse.step.core.guice.providers.ServerSessionProvider;
import com.tyndalehouse.step.core.models.LookupOption;
import com.tyndalehouse.step.core.service.BibleInformationService;
+import com.tyndalehouse.step.guice.providers.ClientSessionProvider;
/**
* tests the bible controller
@@ -22,16 +26,31 @@
*/
public class BibleControllerTest {
private final BibleInformationService bibleInformation = mock(BibleInformationService.class);
- private final BibleController testController = new BibleController(this.bibleInformation);
+ @Mock
+ private ServerSessionProvider serverSessionProvider;
+ @Mock
+ private ClientSessionProvider clientSessionProvider;
+
+ private BibleController testController;
+
/**
+ * sets the test up
+ */
+ @Before
+ public void setup() {
+ this.testController = new BibleController(this.bibleInformation, this.serverSessionProvider,
+ this.clientSessionProvider);
+ }
+
+ /**
* tests that we call correct method
*/
@Test
public void testGetBibleVersions() {
// do test
this.testController.getBibleVersions();
- verify(this.bibleInformation).getAvailableBibleVersions();
+ verify(this.bibleInformation).getAvailableBibleVersions(true, null);
}
/**
Modified: trunk/step/step-web/src/test/java/com/tyndalehouse/step/rest/framework/FrontControllerTest.java
===================================================================
--- trunk/step/step-web/src/test/java/com/tyndalehouse/step/rest/framework/FrontControllerTest.java 2012-04-24 13:13:39 UTC (rev 254)
+++ trunk/step/step-web/src/test/java/com/tyndalehouse/step/rest/framework/FrontControllerTest.java 2012-04-24 20:30:42 UTC (rev 255)
@@ -3,7 +3,9 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
@@ -29,13 +31,10 @@
import com.avaje.ebean.EbeanServer;
import com.google.inject.Injector;
import com.tyndalehouse.step.core.exceptions.StepInternalException;
+import com.tyndalehouse.step.core.guice.providers.ServerSessionProvider;
import com.tyndalehouse.step.core.service.BibleInformationService;
+import com.tyndalehouse.step.guice.providers.ClientSessionProvider;
import com.tyndalehouse.step.rest.controllers.BibleController;
-import com.tyndalehouse.step.rest.framework.ClientErrorResolver;
-import com.tyndalehouse.step.rest.framework.ControllerCacheKey;
-import com.tyndalehouse.step.rest.framework.FrontController;
-import com.tyndalehouse.step.rest.framework.ResponseCache;
-import com.tyndalehouse.step.rest.framework.StepRequest;
/**
* tests the front controller parsing process
@@ -47,6 +46,7 @@
@RunWith(MockitoJUnitRunner.class)
public class FrontControllerTest {
private FrontController fcUnderTest;
+
@Mock
private Injector guiceInjector;
@@ -61,6 +61,11 @@
@Mock
private StepRequest stepRequest;
+ @Mock
+ private ServerSessionProvider serverSessionProvider;
+ @Mock
+ private ClientSessionProvider clientSessionProvider;
+
/**
* Simply setting up the FrontController under test
*/
@@ -146,7 +151,8 @@
@Test
public void testGetControllerMethod() throws IllegalAccessException, InvocationTargetException {
final BibleInformationService bibleInfo = mock(BibleInformationService.class);
- final BibleController controllerInstance = new BibleController(bibleInfo);
+ final BibleController controllerInstance = new BibleController(bibleInfo, this.serverSessionProvider,
+ this.clientSessionProvider);
// when
final Method controllerMethod = this.fcUnderTest.getControllerMethod("getBibleVersions",
@@ -154,7 +160,7 @@
// then
controllerMethod.invoke(controllerInstance);
- verify(bibleInfo).getAvailableBibleVersions();
+ verify(bibleInfo).getAvailableBibleVersions(anyBoolean(), anyString());
}
/**
More information about the Tynstep-svn
mailing list