/PhotoAlbum/trunk/src/ak/photoalbum/logic/ResourceFactory.java |
---|
File deleted |
/PhotoAlbum/trunk/src/ak/photoalbum/logic/Logic.java |
---|
3,10 → 3,10 |
import java.util.List; |
import java.util.ArrayList; |
import java.util.Arrays; |
import java.util.Comparator; |
import java.util.StringTokenizer; |
import java.util.Map; |
import java.util.Hashtable; |
import java.util.Iterator; |
import java.io.File; |
import java.io.IOException; |
import java.io.FileInputStream; |
23,8 → 23,7 |
import ak.photoalbum.images.Thumbnailer; |
import ak.photoalbum.images.ThumbnailPosition; |
import ak.photoalbum.util.FileUtils; |
import ak.photoalbum.util.FileNameComparator; |
import ak.photoalbum.util.ImagesFilter; |
import ak.photoalbum.util.ResourceFactory; |
import ak.photoalbum.config.ConfigRoot; |
import ak.photoalbum.config.ConfigBranch; |
import ak.photoalbum.config.ConfigDirThumbnail; |
116,9 → 115,9 |
logger.info("starting"); |
config = (ConfigRoot)configDigester.parse(resourceFactory.getAsStream(configPath)); |
for(Iterator i = config.getBranches(); i.hasNext(); ) { |
Branch branch = new Branch((ConfigBranch)i.next()); |
brnaches.put(branch.getUri(), branch); |
for(Iterator i = config.getBranches().iterator(); i.hasNext(); ) { |
Branch branch = new Branch(resourceFactory, (ConfigBranch)i.next()); |
branches.put(branch.getUri(), branch); |
} |
logger.info("started"); |
160,11 → 159,11 |
+ "] not found in [" + dir.getCanonicalPath() + "]"); |
branch.getMetaInfos().clear(); // FIXME make this more intelligent |
setEntryInfo(page, file, false); |
setEntryInfo(current, file, true); |
setEntryInfo(index, dir, true); |
if(pos > 0) setEntryInfo(prev, children[pos-1], true); |
if(pos < children.length-1) setEntryInfo(next, children[pos+1], true); |
setEntryInfo(branch, page, file, false); |
setEntryInfo(branch, current, file, true); |
setEntryInfo(branch, index, dir, true); |
if(pos > 0) setEntryInfo(branch, prev, children[pos-1], true); |
if(pos < children.length-1) setEntryInfo(branch, next, children[pos+1], true); |
} |
protected void setEntryInfo(Branch branch, IndexEntry entry, File file, boolean small) |
172,7 → 171,7 |
{ |
String title = file.getName(); |
int[] size; |
String path = getPath(file); |
String path = getPath(branch, file); |
if(file.isDirectory()) { |
size = branch.getThumbnailer().getDirSize(file); |
193,7 → 192,7 |
entry.setWidth(size[0]); |
entry.setHeight(size[1]); |
MetaInfoItem meta = findMetaInfo(branch.getImagesRoot(), file); |
MetaInfoItem meta = findMetaInfo(branch, branch.getImagesRoot(), file); |
if(meta != null) { |
if(meta.getTitle() != null) { |
entry.setTitle(meta.getTitle()); |
290,7 → 289,7 |
return meta; |
} |
protected MetaInfoItem findMetaInfo(File rootDir, File file) |
protected MetaInfoItem findMetaInfo(Branch branch, File rootDir, File file) |
throws IOException, SAXException |
{ |
file = file.getCanonicalFile(); |
304,7 → 303,7 |
for(; metaItem == null; dir = dir.getParentFile()) { |
if(dir == null) break; |
MetaInfo meta = getMetaInfo(dir); |
MetaInfo meta = getMetaInfo(branch, dir); |
if(meta != null) { |
metaItem = meta.findItem(file); |
} |
344,7 → 343,7 |
table.add(row); |
while(rowPos < branch.getColumns() && pos < children.length) { |
String path = getPath(children[pos]); |
String path = getPath(branch, children[pos]); |
String title = children[pos].getName(); |
int[] size; |
360,7 → 359,7 |
URLEncoder.encode(path, URL_ENCODING), |
title, children[pos].isDirectory(), size[0], size[1]); |
MetaInfoItem meta = findMetaInfo(branch.getImagesRoot(), children[pos]); |
MetaInfoItem meta = findMetaInfo(branch, branch.getImagesRoot(), children[pos]); |
if(meta != null) { |
if(meta.getTitle() != null) { |
entry.setTitle(meta.getTitle()); |
/PhotoAlbum/trunk/src/ak/photoalbum/logic/Branch.java |
---|
0,0 → 1,107 |
package ak.photoalbum.logic; |
import java.util.Comparator; |
import java.util.Map; |
import java.util.Hashtable; |
import java.io.File; |
import java.io.IOException; |
import org.apache.log4j.Logger; |
import ak.photoalbum.images.Thumbnailer; |
import ak.photoalbum.images.ThumbnailPosition; |
import ak.photoalbum.util.FileNameComparator; |
import ak.photoalbum.util.ImagesFilter; |
import ak.photoalbum.util.ResourceFactory; |
import ak.photoalbum.config.ConfigBranch; |
import ak.photoalbum.config.ConfigDirThumbnail; |
public class Branch |
{ |
protected static final int DEFAULT_COLUMNS = 5; |
protected static final int DEFAULT_ROWS = 4; |
private Thumbnailer thumbnailer; |
private ConfigBranch config; |
private File imagesRoot; |
private int columns = DEFAULT_COLUMNS; |
private int rows = DEFAULT_ROWS; |
private ImagesFilter imagesFilter; |
private Comparator fileNameComparator = new FileNameComparator(true); |
private Map metaInfos = new Hashtable(); // <File, MetaInfo> |
public Branch(ResourceFactory resourceFactory, ConfigBranch config) |
throws IOException, LogicException |
{ |
this.config = config; |
this.imagesRoot = new File(config.getImagesRoot()); |
this.imagesFilter = new ImagesFilter(config.getImagesMasks()); |
if(config.getColumns() > 0) this.columns = config.getColumns(); |
if(config.getRows() > 0) this.rows = config.getRows(); |
this.thumbnailer = new Thumbnailer(); |
this.thumbnailer.setImagesRoot(this.imagesRoot); |
this.thumbnailer.setCacheDir(new File(config.getCacheDir())); |
if(config.getThumbnailFormat() != null) |
this.thumbnailer.setFormat(config.getThumbnailFormat()); |
/* |
if(smallWidth != null) |
this.thumbnailer.setSmallWidth(smallWidth.intValue()); |
if(smallHeight != null) |
this.thumbnailer.setSmallHeight(smallHeight.intValue()); |
if(mediumWidth != null) |
this.thumbnailer.setMediumWidth(mediumWidth.intValue()); |
if(mediumHeight != null) |
this.thumbnailer.setMediumHeight(mediumHeight.intValue()); |
*/ |
thumbnailer.setResizer(new ak.photoalbum.images.jiu.JiuResizer()); |
thumbnailer.setImagesFilter(this.imagesFilter); |
/* thumbnailer.setDirTemplate(new File(dirTemplate)); |
thumbnailer.setDirThumbnailPositions( |
parseThumbnailPositions(dirThumbnailPositions));*/ |
thumbnailer.startup(); |
} |
public String getUri() |
{ |
return config.getUri(); |
} |
public Thumbnailer getThumbnailer() |
{ |
return thumbnailer; |
} |
public File getImagesRoot() |
{ |
return imagesRoot; |
} |
public int getColumns() |
{ |
return columns; |
} |
public int getRows() |
{ |
return rows; |
} |
public ImagesFilter getImagesFilter() |
{ |
return imagesFilter; |
} |
public Comparator getFileNameComparator() |
{ |
return fileNameComparator; |
} |
public Map getMetaInfos() |
{ |
return metaInfos; |
} |
} |
/PhotoAlbum/trunk/src/ak/photoalbum/util/ResourceFactory.java |
---|
0,0 → 1,9 |
package ak.photoalbum.util; |
import java.io.InputStream; |
public interface ResourceFactory |
{ |
public InputStream getAsStream(String path); |
} |
/PhotoAlbum/trunk/src/ak/photoalbum/webapp/PathForm.java |
---|
3,25 → 3,13 |
import javax.servlet.http.HttpServletRequest; |
import org.apache.struts.action.ActionError; |
import org.apache.struts.action.ActionErrors; |
import org.apache.struts.action.ActionForm; |
import org.apache.struts.action.ActionMapping; |
public class PathForm |
extends ActionForm |
extends BranchForm |
{ |
protected String branch; |
protected String path; |
public String getBranch() |
{ |
return branch; |
} |
public void setBranch(String branch) |
{ |
this.branch = branch; |
} |
public String getPath() |
{ |
return path; |
/PhotoAlbum/trunk/src/ak/photoalbum/webapp/BuildCacheAction.java |
---|
19,8 → 19,11 |
HttpServletRequest request, HttpServletResponse response) |
throws Exception |
{ |
PathForm theForm = (PathForm)form; |
String branch = theForm.getBranch(); |
// FIXME: show progress bar |
Logic.getLogic().buildCache(); |
Logic.getLogic().buildCache(branch); |
return mapping.findForward("success"); |
} |
/PhotoAlbum/trunk/src/ak/photoalbum/webapp/BranchForm.java |
---|
0,0 → 1,31 |
package ak.photoalbum.webapp; |
import javax.servlet.http.HttpServletRequest; |
import org.apache.struts.action.ActionError; |
import org.apache.struts.action.ActionErrors; |
import org.apache.struts.action.ActionForm; |
import org.apache.struts.action.ActionMapping; |
public class BranchForm |
extends ActionForm |
{ |
protected String branch; |
public String getBranch() |
{ |
return branch; |
} |
public void setBranch(String branch) |
{ |
this.branch = branch; |
} |
public ActionErrors validate(ActionMapping mapping, |
HttpServletRequest request) |
{ |
ActionErrors errors = new ActionErrors(); |
return errors; |
} |
} |
/PhotoAlbum/trunk/src/ak/photoalbum/webapp/ServletResourceFactory.java |
---|
2,7 → 2,7 |
import java.io.InputStream; |
import javax.servlet.ServletContext; |
import ak.photoalbum.logic.ResourceFactory; |
import ak.photoalbum.util.ResourceFactory; |
public class ServletResourceFactory |
implements ResourceFactory |