Author: dieppe
Date: 2008-02-20 14:44:17 +0000 (Wed, 20 Feb 2008)
New Revision: 18081
Added:
trunk/apps/thingamablog/src/net/sf/thingamablog/util/string/
trunk/apps/thingamablog/src/net/sf/thingamablog/util/string/ASCIIconv.java
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
Log:
We don't ask for the freenet path anymore (use the flog title instead);
Some bug fixs;
Modified: trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java
2008-02-20 03:57:05 UTC (rev 18080)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/blog/Weblog.java
2008-02-20 14:44:17 UTC (rev 18081)
@@ -408,7 +408,7 @@
FCPTransport fcp = (FCPTransport) transport;
int index = this.getFrontPageUrl().lastIndexOf("/");
String defaultName = this.getFrontPageUrl().substring(index+1);
- boolean result =
fcp.publishFile(ht,progress,defaultName,getArchivePath());
+ boolean result =
fcp.publishFile(ht,progress,defaultName,getArchivePath(),this.getTitle());
if(!result)
{
//progress.publishFailed(transport.getFailureReason());
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
===================================================================
---
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
2008-02-20 03:57:05 UTC (rev 18080)
+++
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
2008-02-20 14:44:17 UTC (rev 18081)
@@ -48,6 +48,7 @@
import net.atlanticbb.tantlinger.i18n.I18n;
import net.atlanticbb.tantlinger.ui.text.TextEditPopupManager;
+import net.sf.thingamablog.TBGlobals;
import net.sf.thingamablog.blog.TBWeblog;
import net.sf.thingamablog.gui.LabelledItemPanel;
import net.sf.thingamablog.transport.FCPTransport;
@@ -56,6 +57,7 @@
import net.sf.thingamablog.transport.PublishTransport;
import net.sf.thingamablog.transport.SFTPTransport;
import net.sf.thingamablog.util.freenet.fcp.fcpManager;
+import net.sf.thingamablog.util.string.ASCIIconv;
/**
* @author Bob Tantlinger
@@ -187,7 +189,8 @@
FCPTransport t =(FCPTransport)wb.getPublishTransport();
fcpPanel.setMachineNameField(t.getHostname());
fcpPanel.setPortField(Integer.parseInt(t.getPort()));
- fcpPanel.setTitle(wb.getTitle());
+ if (t.getInsertURI() != null)
+ InsertURI=t.getInsertURI();
transportTypeCombo.setSelectedItem(FCP);
tLayout.show(transportsPanel, FCP);
}
@@ -259,7 +262,7 @@
pt.setNode(fcpPanel.getMachineNameField(),fcpPanel.getPortField());
// If we are changing the publish transport after the
Dialog Wizard, we need to create a new key pair
- if(InsertURI == null) {
+ if(InsertURI == null && !(weblog.getPublishTransport()
instanceof FCPTransport)) {
logger.log(Level.INFO,"Creating a new SSK key
pair...");
fcpManager fcp = new fcpManager();
String keys[];
@@ -269,7 +272,9 @@
keys[0]=keys[0].substring("SSK".length());
keys[1]=keys[1].substring("SSK".length());
InsertURI="USK" + keys[0];
-
weblog.setBlogUrls(weblog.getBasePath(),"USK"+keys[1],weblog.getArchiveUrl(),weblog.getMediaUrl());
+ String url="USK" + keys[1];
+ url +=
ASCIIconv.convertNonAscii(weblog.getTitle()) + "/1/";
+
weblog.setBlogUrls(weblog.getBasePath(),url,url,url);
} catch (IOException ex) {
JOptionPane.showMessageDialog(TBPublishTransportPanel.this,
fcpPanel.getMachineNameField() + ":" +
fcpPanel.getPortField() + " : " + ex, i18n.str("key_generation_failure"),
//$NON-NLS-1$ //$NON-NLS-2$
@@ -281,16 +286,6 @@
}
pt.setInsertURI(InsertURI);
pt.setEdition("1");
- pt.setTitle(fcpPanel.getTitle());
- if(weblog.getPublishTransport() == null ||
weblog.getPublishTransport() instanceof LocalTransport){
- String url = weblog.getBaseUrl();
- if(!url.endsWith("/"))
- url += "/";;
- url += fcpPanel.getTitle() + "/1/";
- String arcUrl = url;
- String mediaUrl = url;
- weblog.setBlogUrls(weblog.getBasePath(), url,
arcUrl, mediaUrl);
- }
transport = pt;
}
@@ -308,8 +303,6 @@
return validateOptions(ftpPanel);
if(o == SFTP)
return validateOptions(sftpPanel);
- if(o == FCP)
- return validateOptions(fcpPanel);
return true;
}
@@ -324,18 +317,8 @@
}
return true;
- }
+ }
- private boolean validateOptions(FcpTransportPanel fcp)
- {
- if (fcp.getTitle().contains("/")) {
- JOptionPane.showMessageDialog(TBPublishTransportPanel.this,
- i18n.str("invalid_title_prompt_contains_slash"),
i18n.str("title"), JOptionPane.WARNING_MESSAGE); //$NON-NLS-1$ //$NON-NLS-2$
- return false;
- }
- return true;
- }
-
private class RemoteTransportPanel extends JPanel
{
/**
@@ -491,27 +474,24 @@
private static final long serialVersionUID = 1L;
private JTextField portField;
private JTextField machineNameField;
- private JTextField titleField;
public FcpTransportPanel()
{
portField = new JTextField();
machineNameField = new JTextField();
- titleField = new JTextField();
TextEditPopupManager pm =
TextEditPopupManager.getInstance();
pm.registerJTextComponent(machineNameField);
// Default port
- portField.setText("9481");
+ portField.setText(TBGlobals.getProperty("NODE_PORT"));
//Default machine name
- machineNameField.setText("localhost");
+
machineNameField.setText(TBGlobals.getProperty("NODE_HOSTNAME"));
LabelledItemPanel lip = new LabelledItemPanel();
JPanel p = new JPanel(new BorderLayout());
p.add(portField, BorderLayout.WEST);
p.add(new JPanel(), BorderLayout.CENTER);
lip.addItem(i18n.str("port"), p);
lip.addItem(i18n.str("machineName"),machineNameField);
- lip.addItem(i18n.str("freesite_path"),titleField);
setLayout(new BorderLayout());
add(lip, BorderLayout.CENTER);
}
@@ -536,14 +516,5 @@
public void setMachineNameField(String machineNameField) {
this.machineNameField.setText(machineNameField);
}
-
- public void setTitle(String title){
- this.titleField.setText(title);
- }
-
- public String getTitle(){
- return this.titleField.getText();
- }
-
}
}
\ No newline at end of file
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
===================================================================
---
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
2008-02-20 03:57:05 UTC (rev 18080)
+++
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBWizardDialog.java
2008-02-20 14:44:17 UTC (rev 18081)
@@ -48,6 +48,7 @@
import net.sf.thingamablog.gui.app.TemplateSelectionPanel;
import net.sf.thingamablog.gui.app.WeblogPreviewer;
import net.sf.thingamablog.util.freenet.fcp.fcpManager;
+import net.sf.thingamablog.util.string.ASCIIconv;
@@ -434,8 +435,8 @@
String url = urlField.getText();
if(!url.endsWith("/")) //$NON-NLS-1$
url += "/";; //$NON-NLS-1$
- String arcUrl = url + "archives"; //$NON-NLS-1$
- String mediaUrl = url + "media"; //$NON-NLS-1$
+ String arcUrl = url; //$NON-NLS-1$
+ String mediaUrl = url; //$NON-NLS-1$
weblog.setBlogUrls(path, url, arcUrl, mediaUrl);
weblog.setType(typeCombo.getSelectedItem().toString());
@@ -527,6 +528,11 @@
{
weblog.setTitle(titleField.getText());
weblog.setDescription(textArea.getText());
+ if(weblog.getType().equals("freenet")){
+ String url=weblog.getBaseUrl();
+ url+=ASCIIconv.convertNonAscii(weblog.getTitle())
+ "/1/";
+
weblog.setBlogUrls(weblog.getBasePath(),url,url,url);
+ }
}
public String getTitle()
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
2008-02-20 03:57:05 UTC (rev 18080)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
2008-02-20 14:44:17 UTC (rev 18081)
@@ -32,6 +32,7 @@
import net.sf.thingamablog.util.freenet.fcp.Message;
import net.sf.thingamablog.util.freenet.fcp.Verbosity;
import net.sf.thingamablog.util.freenet.fcp.fcpManager;
+import net.sf.thingamablog.util.string.ASCIIconv;
import src.net.sf.thingamablog.util.io.ReplacingOutputStream;
/**
@@ -46,7 +47,6 @@
private String failMsg;
private boolean hasPublish = false;
private int edition;
- private String title;
/**
* Connects the transport
@@ -110,7 +110,7 @@
return false;
}
- public boolean publishFile(Hashtable ht, PublishProgress tp, String
frontPage, String arcPath){
+ public boolean publishFile(Hashtable ht, PublishProgress tp, String
frontPage, String arcPath, String title){
//We do the publish job for an entire directory
if(!Manager.isConnected()){
logger.log(Level.WARNING,"The connection to the node is not open
!");
@@ -118,7 +118,7 @@
return false;
}
System.out.println("Beginning of the publish process...");
- String dirURI = "freenet:USK@" + insertURI + "/" + title + "/" +
edition + "/";
+ String dirURI = "freenet:USK@" + insertURI + "/" +
ASCIIconv.convertNonAscii(title) + "/" + edition + "/";
System.out.println("Insert URI : " + dirURI);
ClientPutComplexDir putDir = new ClientPutComplexDir("Thingamablog
insert", dirURI);
System.out.println("Default name : " + frontPage);
@@ -225,12 +225,4 @@
}
return uri;
}
-
- public String getTitle(){
- return this.title;
- }
-
- public void setTitle(String title){
- this.title=title;
- }
}
Added:
trunk/apps/thingamablog/src/net/sf/thingamablog/util/string/ASCIIconv.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/util/string/ASCIIconv.java
(rev 0)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/util/string/ASCIIconv.java
2008-02-20 14:44:17 UTC (rev 18081)
@@ -0,0 +1,54 @@
+/*
+ * ASCIIconv.java
+ *
+ * Created on 20 f?vrier 2008, 14:48
+ */
+
+package net.sf.thingamablog.util.string;
+
+/**
+ *
+ * @author dieppe
+ */
+public class ASCIIconv {
+
+ private static final String PLAIN_ASCII =
+ "AaEeIiOoUu" // grave
+ + "AaEeIiOoUuYy" // acute
+ + "AaEeIiOoUuYy" // circumflex
+ + "AaEeIiOoUuYy" // tilde
+ + "AaEeIiOoUuYy" // umlaut
+ + "Aa" // ring
+ + "Cc" // cedilla
+ ;
+
+ private static final String UNICODE =
+ "\u00C0\u00E0\u00C8\u00E8\u00CC\u00EC\u00D2\u00F2\u00D9\u00F9"
+
+"\u00C1\u00E1\u00C9\u00E9\u00CD\u00ED\u00D3\u00F3\u00DA\u00FA\u00DD\u00FD"
+
+"\u00C2\u00E2\u00CA\u00EA\u00CE\u00EE\u00D4\u00F4\u00DB\u00FB\u0176\u0177"
+
+"\u00C2\u00E2\u00CA\u00EA\u00CE\u00EE\u00D4\u00F4\u00DB\u00FB\u0176\u0177"
+
+"\u00C4\u00E4\u00CB\u00EB\u00CF\u00EF\u00D6\u00F6\u00DC\u00FC\u0178\u00FF"
+ +"\u00C5\u00E5"
+ +"\u00C7\u00E7"
+ ;
+
+ // private constructor, can't be instanciated!
+ private ASCIIconv() { }
+
+ // remove accentued from a string and replace with ascii equivalent
+ public static String convertNonAscii(String s) {
+ StringBuffer sb = new StringBuffer();
+ int n = s.length();
+ for (int i = 0; i < n; i++) {
+ char c = s.charAt(i);
+ int pos = UNICODE.indexOf(c);
+ if (pos > -1){
+ sb.append(PLAIN_ASCII.charAt(pos));
+ }
+ else {
+ sb.append(c);
+ }
+ }
+ return sb.toString();
+ }
+}
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
2008-02-20 03:57:05 UTC (rev 18080)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
2008-02-20 14:44:17 UTC (rev 18081)
@@ -481,7 +481,6 @@
transport.setAttribute("port",fpt.getPort());
transport.setAttribute("edition",fpt.getEdition()+"");
transport.setAttribute("insertURI",fpt.getInsertURI());
- transport.setAttribute("title",fpt.getTitle());
}
else
{
@@ -875,7 +874,6 @@
fcp.setNode(transport.getAttributeValue("hostname"),
Integer.parseInt(transport.getAttributeValue("port")));
fcp.setEdition(transport.getAttributeValue("edition"));
fcp.setInsertURI(transport.getAttributeValue("insertURI"));
- fcp.setTitle(transport.getAttributeValue("title"));
pubTransport = fcp;
}
else