Skip to content

Commit

Permalink
Merge pull request #2 from mmoayyed/NEWSREADER-1
Browse files Browse the repository at this point in the history
NEWSREADER-1: Fixes for the single news feed instance.
  • Loading branch information
drewwills committed Apr 4, 2012
2 parents f1a180a + 0a2e024 commit 196c803
Show file tree
Hide file tree
Showing 15 changed files with 259 additions and 33 deletions.
16 changes: 11 additions & 5 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
58 changes: 58 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Project Files #
.cvsignore
.project
*.project
.settings
*.classpath

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
target
bin

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite

# OS generated files #
######################
.DS_Store
ehthumbs.db
Icon?
Thumbs.db
=======
.classpath
!/.project
.project
.settings
target
*.ipr
*.iml
*.iws
*.class
.idea/
.DS_Store
.idea
overlays/
pom.xml.versionsBackup
25 changes: 25 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
Expand All @@ -15,9 +25,24 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
9 changes: 6 additions & 3 deletions src/main/java/org/jasig/portlet/newsreader/Preference.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
package org.jasig.portlet.newsreader;

public class Preference {
public static final String MAX_STORIES = "maxStories";
public static final String SUMMARY_VIEW_STYLE = "summaryView";
public static final String NEW_WINDOW = "newWindow";
public static final String MAX_STORIES = "maxStories";
public static final String SUMMARY_VIEW_STYLE = "summaryView";
public static final String NEW_WINDOW = "newWindow";
public static final String CLASS_NAME = "className";
public static final String FFED_NAME = "name";
public static final String FEED_URL = "url";

private String value;
private Object options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@RequestMapping("HELP")
public class HelpController {

@RequestMapping
@RequestMapping
public String getHelpView() {
return "help";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.portlet.bind.annotation.ActionMapping;
import org.springframework.web.portlet.bind.annotation.RenderMapping;

@Controller
@RequestMapping("EDIT")
Expand All @@ -63,7 +65,7 @@ public void afterPropertiesSet() throws Exception {

}

@RequestMapping
@RenderMapping
protected ModelAndView showForm(RenderRequest request, RenderResponse response) throws Exception {

log.trace("handleRenderRequestInternal");
Expand All @@ -72,6 +74,21 @@ protected ModelAndView showForm(RenderRequest request, RenderResponse response)
PortletPreferences preferences = request.getPreferences();
Map<String, Preference> model = new HashMap<String, Preference>();

Preference name = new Preference();
name.setValue(preferences.getValue(Preference.FFED_NAME, ""));
name.setReadOnly(preferences.isReadOnly(Preference.FFED_NAME));
model.put("name", name);

Preference url = new Preference();
url.setValue(preferences.getValue(Preference.FEED_URL, ""));
url.setReadOnly(preferences.isReadOnly(Preference.FEED_URL));
model.put("url", url);

Preference className = new Preference();
className.setValue(preferences.getValue(Preference.CLASS_NAME, ""));
className.setReadOnly(preferences.isReadOnly(Preference.CLASS_NAME));
model.put("className", className);

Preference max = new Preference();
max.setOptions(optionsMaxStories);
max.setValue(preferences.getValue(Preference.MAX_STORIES, ""));
Expand All @@ -94,7 +111,7 @@ protected ModelAndView showForm(RenderRequest request, RenderResponse response)

}

@RequestMapping
@ActionMapping
public Map<Object, Object> savePreference(ActionRequest request,
ActionResponse response) throws Exception {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Licensed to Jasig under one or more contributor license
* agreements. See the NOTICE file distributed with this work
* for additional information regarding copyright ownership.
* Jasig licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a
* copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.jasig.portlet.newsreader.mvc.portlet.singlefeed;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("HELP")
public class HelpController {

@RequestMapping
public String getHelpView() {
return "helpSingleFeed";
}

}
8 changes: 4 additions & 4 deletions src/main/webapp/WEB-INF/context/applicationContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
xmlns:util="http://www.springframework.org/schema/util"
xmlns:ehcache="http://www.springmodules.org/schema/ehcache"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<!-- EHCache Configuration -->
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/context/importExportContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">

<import resource="applicationContext.xml" />

Expand Down
8 changes: 5 additions & 3 deletions src/main/webapp/WEB-INF/context/portlet/news.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan base-package="org.jasig.portlet.newsreader.mvc.portlet.reader"/>
<context:annotation-config/>
Expand All @@ -43,4 +43,6 @@
<property name="interceptors"><bean class="org.jasig.portlet.newsreader.mvc.MinimizedStateHandlerInterceptor"/></property>
</bean>

<bean class="org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>

</beans>
9 changes: 5 additions & 4 deletions src/main/webapp/WEB-INF/context/portlet/single-feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan base-package="org.jasig.portlet.newsreader.mvc.portlet.singlefeed"/>
<context:annotation-config/>

<bean class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors"><bean class="org.jasig.portlet.newsreader.mvc.MinimizedStateHandlerInterceptor"/></property>
</bean>

<bean class="org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan base-package="org.jasig.portlet.newsreader.mvc.servlet"/>
<context:annotation-config/>
Expand Down
41 changes: 36 additions & 5 deletions src/main/webapp/WEB-INF/jsp/editSingleFeed.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
--%>

<jsp:directive.include file="/WEB-INF/jsp/include.jsp"/>
<portlet:defineObjects/>
<c:set var="n"><portlet:namespace/></c:set>

<script type="text/javascript" src="<rs:resourceURL value="/rs/jquery/1.6.1/jquery-1.6.1.min.js"/>"></script>
<script type="text/javascript" src="<rs:resourceURL value="/rs/jqueryui/1.8.13/jquery-ui-1.8.13.min.js"/>"></script>
<script type="text/javascript"><rs:compressJs>

var ${n} = ${n} || {};
<script type="text/javascript">
var ${n} = ${n} || {};
${n}.jQuery = jQuery.noConflict(true);
${n}.jQuery(function() {
Expand All @@ -36,6 +36,17 @@
var savePrefUrl = '<portlet:actionURL/>';
var $p = $("#news-single-preference"); //find the root element of the protlet to scope dom seraches
$p.find("#name").change(function(e){
$.post(savePrefUrl, {prefName: 'name', prefValue: $(e.target).val()});
});
$p.find("#url").change(function(e){
$.post(savePrefUrl, {prefName: 'url', prefValue: $(e.target).val()});
});
$p.find("#className").change(function(e){
$.post(savePrefUrl, {prefName: 'className', prefValue: $(e.target).val()});
});
$p.find("#max").change(function(e){
$.post(savePrefUrl, {prefName: 'maxStories', prefValue: $(e.target).val()});
});
Expand All @@ -47,16 +58,35 @@
});
});
</script>

</rs:compressJs></script>
<style type="text/css" media="screen">
.preference{
margin:0 0 13px 13px;
}
</style>

<div id="news-single-preference">
<h3>Preferences</h3>


<div class="preference">
<label class="portlet-form-field-label">News feed name:</label>
<input type="text" name="name" value="${name.value}" id="name" size="50">
</div>

<div class="preference">
<label class="portlet-form-field-label">News feed URL:</label>
<input type="text" name="url" value="${url.value}" id="url" size="50">
</div>

<div class="preference">
<label class="portlet-form-field-label">News feed class:</label>
<input size="50" type="text" name="className" value="${className.value}" id="className"
${ className.readOnly ? "readonly='readonly'" : '' }>
</div>

<div class="preference">
<label>Maximum number of stories to display</label>
<select id="max" ${ max.readOnly ? "disabled='disabled'" : ''}>
Expand Down Expand Up @@ -85,5 +115,6 @@
${ newWindow.value == "true" ? "checked='checked'" : '' }
${ newWindow.readOnly ? "disabled='disabled'" : '' }>
</div>

<a href="<portlet:renderURL portletMode="view"/>"><img src="<c:url value="/images/arrow_left.png"/>"> Return to feed</a>
</div>
Loading

0 comments on commit 196c803

Please sign in to comment.