Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/plugins/org.drftpd.plugins.linkmanager.latestdir/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: build.xml 2072 2010-09-18 22:01:23Z djb61 $ -->
<project name="org.drftpd.plugins.linkmanager.latestdir"
default="build">
<property name="plugin.family" value="plugins/master" />
<target name="build">
<buildplugin />
</target>
<target name="clean">
<cleanplugin />
</target>
</project>
33 changes: 33 additions & 0 deletions src/plugins/org.drftpd.plugins.linkmanager.latestdir/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" ?>
<!DOCTYPE plugin PUBLIC "-//JPF//Java Plug-in Manifest 1.0" "http://jpf.sourceforge.net/plugin_1_0.dtd">
<!-- $Id: plugin.xml freasy $ -->
<plugin id="org.drftpd.plugins.linkmanager.latestdir" version="3.0.0">
<doc>
<doc-text> This plugin provides LatestDir to the Link Manager</doc-text>
</doc>
<attributes>
<attribute id="DefaultBuild" value="false" />
<attribute id="MustBuild" value="false" />
</attributes>
<requires>
<import plugin-id="org.drftpd.commands.zipscript" />
<import plugin-id="org.drftpd.plugins.linkmanager" exported="true" />
<import plugin-id="master" exported="true" reverse-lookup="true" />
</requires>

<runtime>
<library id="org.drftpd.plugins.linkmanager.types.latestdir" path="classes/" type="code">
<export prefix="*" />
</library>
</runtime>

<extension plugin-id="org.drftpd.plugins.linkmanager" point-id="LinkType" id="LatestDir">
<parameter id="ClassName" value="org.drftpd.plugins.linkmanager.types.latestdir.LatestDir"/>
<parameter id="TypeName" value="LatestDir"/>
</extension>

<extension plugin-id="master" point-id="Plugin" id="LatestDirManager">
<parameter id="Class" value="org.drftpd.plugins.linkmanager.types.latestdir.LatestDirManager"/>
</extension>

</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#how much links shall be produced
maxcount=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
################################################################################
# LATESTDIR:
#
# This will just make links of last races
#
# x.type=LATESTDIR
# x.dirname=/_LAST_RACES_
# x.section=*
# x.exclude=
# x.sectionexclude=^(?i)(pre|staff|speedtests)$
# x.deleteon=*
# x.linkname=(last)-${dirname}
# x.addparentdir=^(?i)(((cd|dvd|dis[ck])[1-9])|sample|subs|rarfix)$
#
################################################################################
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* This file is part of DrFTPD, Distributed FTP Daemon.
*
* DrFTPD is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* DrFTPD is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DrFTPD; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
package org.drftpd.plugins.linkmanager.types.latestdir;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import org.drftpd.commands.zipscript.vfs.ZipscriptVFSDataSFV;
import org.drftpd.exceptions.NoAvailableSlaveException;
import org.drftpd.exceptions.SlaveUnavailableException;
import org.drftpd.plugins.linkmanager.LinkType;
import org.drftpd.vfs.DirectoryHandle;

/**
* @author freasy
* @version $Id: LatestDir.java freasy $
*/

public class LatestDir extends LinkType {

public LatestDir(Properties p, int confnum, String type) {
super(p, confnum, type);
}

/*
* This just passes the target dir through to creating the Link
* No special setup is needed for this type.
*/
@Override
public void doCreateLink(DirectoryHandle targetDir) {
createLink(targetDir,targetDir.getPath(),targetDir.getName());
}

/*
* This just passes the target dir through to creating the Link
* No special setup is needed for this type.
*/
@Override
public void doDeleteLink(DirectoryHandle targetDir) {
deleteLink(targetDir,targetDir.getPath(),targetDir.getName());

}

public void doFixLink(DirectoryHandle dirHandle) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* This file is part of DrFTPD, Distributed FTP Daemon.
*
* DrFTPD is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* DrFTPD is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DrFTPD; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
package org.drftpd.plugins.linkmanager.types.latestdir;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Properties;

import org.drftpd.PropertyHelper;
import org.drftpd.GlobalContext;


import org.bushe.swing.event.annotation.AnnotationProcessor;
import org.bushe.swing.event.annotation.EventSubscriber;
import org.drftpd.PluginInterface;
import org.drftpd.commands.zipscript.vfs.ZipscriptVFSDataSFV;
import org.drftpd.event.ReloadEvent;
import org.drftpd.event.DirectoryFtpEvent;
import org.drftpd.exceptions.NoAvailableSlaveException;
import org.drftpd.exceptions.SlaveUnavailableException;
import org.drftpd.plugins.linkmanager.LinkManager;
import org.drftpd.plugins.linkmanager.LinkType;
import org.drftpd.vfs.event.VirtualFileSystemInodeDeletedEvent;
import org.drftpd.vfs.DirectoryHandle;
import org.drftpd.vfs.LinkHandle;
/**
* @author freasy
* @version $Id: LatestDirManager.java freasy $
*/

public class LatestDirManager implements PluginInterface {
private LinkManager _linkmanager;

private ArrayList<DirectoryHandle> _links;

private HashMap<String, DirectoryHandle> _map;

private int _count;

@Override
public void startPlugin() {
AnnotationProcessor.process(this);
loadManager();
}

@Override
public void stopPlugin(String reason) {
AnnotationProcessor.unprocess(this);
}

@EventSubscriber
public void onReloadEvent(ReloadEvent event) {
loadManager();
}

private void loadManager() {
_linkmanager = LinkManager.getLinkManager();
_links = new ArrayList<DirectoryHandle>();
_map = new HashMap<String, DirectoryHandle>();
Properties _props = GlobalContext.getGlobalContext().getPluginsConfig().getPropertiesForPlugin("latestdir.conf");
_count = Integer.parseInt(PropertyHelper.getProperty(_props, "maxcount","10"));
for (LinkType link : _linkmanager.getLinks()) {
if (link.getEventType().equals("latestdir")) {
DirectoryHandle dir = new DirectoryHandle(link.getDirName(null));
try {
for(LinkHandle linkH : dir.getSortedLinksUnchecked())
{
_links.add(linkH.getTargetDirectoryUnchecked());
_map.put(linkH.getTargetDirectoryUnchecked().getPath(), linkH.getTargetDirectoryUnchecked());
}

while(_links.size() > _count)
{
link.doDeleteLink(_links.get(0));
_map.remove(_links.get(0).getPath());
_links.remove(0);
}
} catch (Exception e) {}
}
}
}

/*
* Handle the MKD command to make links
*/
@EventSubscriber
public void onDirectoryFtpEvent(DirectoryFtpEvent event)
{
if(!event.getCommand().equalsIgnoreCase("MKD"))
return;

String rls = event.getDirectory().getPath().replaceAll(".*/(.*)", "$1");

for (LinkType link : _linkmanager.getLinks()) {
if (link.getEventType().equals("latestdir")) {
if(!rls.matches(link.getExclude()))
{
if(_map.get(event.getDirectory().getPath()) == null)
{
link.doCreateLink(event.getDirectory());
_links.add(event.getDirectory());
_map.put(event.getDirectory().getPath(), event.getDirectory());
}
if(_links.size() > _count)
{
link.doDeleteLink(_links.get(0));
_links.remove(0);
_map.remove(event.getDirectory().getPath());
}
}
}
}
}
}
12 changes: 12 additions & 0 deletions src/plugins/org.drftpd.plugins.linkmanager.nfomissing/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id: build.xml 2072 2010-09-18 22:01:23Z djb61 $ -->
<project name="org.drftpd.plugins.linkmanager.nfomissing"
default="build">
<property name="plugin.family" value="plugins/master" />
<target name="build">
<buildplugin />
</target>
<target name="clean">
<cleanplugin />
</target>
</project>
32 changes: 32 additions & 0 deletions src/plugins/org.drftpd.plugins.linkmanager.nfomissing/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" ?>
<!DOCTYPE plugin PUBLIC "-//JPF//Java Plug-in Manifest 1.0" "http://jpf.sourceforge.net/plugin_1_0.dtd">
<!-- $Id: plugin.xml 2026 2010-02-14 15:33:15Z CyBeR $ -->
<plugin id="org.drftpd.plugins.linkmanager.nfomissing" version="3.0.0">
<doc>
<doc-text> This plugin provides NfoMissing to the Link Manager</doc-text>
</doc>
<attributes>
<attribute id="DefaultBuild" value="false" />
<attribute id="MustBuild" value="false" />
</attributes>
<requires>
<import plugin-id="org.drftpd.plugins.linkmanager" exported="true" />
<import plugin-id="master" exported="true" reverse-lookup="true" />
</requires>

<runtime>
<library id="org.drftpd.plugins.linkmanager.types.nfomissing" path="classes/" type="code">
<export prefix="*" />
</library>
</runtime>

<extension plugin-id="org.drftpd.plugins.linkmanager" point-id="LinkType" id="NFOMissing">
<parameter id="ClassName" value="org.drftpd.plugins.linkmanager.types.nfomissing.NFOMissing"/>
<parameter id="TypeName" value="NFOMissing"/>
</extension>

<extension plugin-id="master" point-id="Plugin" id="NFOMissinganager">
<parameter id="Class" value="org.drftpd.plugins.linkmanager.types.nfomissing.NFOMissingManager"/>
</extension>

</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
################################################################################
# NFOMISSING:
#
# This will find all directories excluding the REGEX set that do not
# have an NFO and place a create a link to said directory in /_NO_NFO_
#
# x.addparentdir is used for only adding a missing link to folders
# that have a match here, or a folder with no subfolders.
# IE: /section1/sub-section1/rls1 - we don't want a no-nfo for sub-section1
#
# x.type=NFOMISSING
# x.dirname=/_NO_NFO_
# x.section=*
# x.exclude=^/(.*)/(?i)(((cd|dvd|dis[ck])[1-9])|sample|subs|rarfix)$
# x.sectionexclude=^(?i)(pre|staff|speedtests)$
# x.deleteon=*
# x.linkname=(no-nfo)-${dirname}
# x.addparentdir=^(?i)(((cd|dvd|dis[ck])[1-9])|sample|subs|rarfix)$
#
################################################################################
Loading