Author: dieppe
Date: 2008-03-09 00:56:05 +0000 (Sun, 09 Mar 2008)
New Revision: 18433
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/messages_fr.properties
trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
Log:
Add an option to publish (or not) an activelink with the flog
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
===================================================================
---
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
2008-03-08 15:18:45 UTC (rev 18432)
+++
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/TBPublishTransportPanel.java
2008-03-09 00:56:05 UTC (rev 18433)
@@ -188,6 +188,10 @@
fcpPanel.setMachineNameField(t.getHostname());
fcpPanel.setPortField(t.getPort());
fcpPanel.setInsertUri("USK@" + t.getInsertURI() + "/");
+ fcpPanel.setActiveLink(t.getActiveLink());
+ if (t.getActiveLink()){
+ fcpPanel.setActiveLinkPath(t.getActiveLinkPath());
+ }
transportTypeCombo.setSelectedItem(FCP);
tLayout.show(transportsPanel, FCP);
}
@@ -257,8 +261,12 @@
} else {
FCPTransport pt = new FCPTransport();
pt.setNode(fcpPanel.getMachineNameField(),fcpPanel.getPortField());
- pt.setInsertURI(fcpPanel.getInsertUri());
- String url = fcpPanel.getRequestUri();
+ pt.setInsertURI(fcpPanel.getInsertUri());
+ pt.setActiveLink(fcpPanel.getActiveLink());
+ if (pt.getActiveLink()){
+ pt.setActiveLinkPath(fcpPanel.getActiveLinkPath());
+ }
+ String url = fcpPanel.getRequestUri();
int firstSlash = url.indexOf('/');
url = url.substring(0,firstSlash+1) +
ASCIIconv.convertNonAscii(weblog.getTitle()) + "/1/";
weblog.setBlogUrls("none",url,url,url);
@@ -453,6 +461,8 @@
private JTextField machineNameField;
private JTextField requestUriField;
private JTextField insertUriField;
+ private JTextField activeLinkPathField;
+ private JCheckBox activeLinkCheckBox;
private JButton generateKeyButton;
public FcpTransportPanel()
{
@@ -460,6 +470,8 @@
machineNameField = new JTextField();
requestUriField = new JTextField();
insertUriField = new JTextField();
+ activeLinkPathField = new JTextField();
+ activeLinkCheckBox = new JCheckBox();
generateKeyButton = new JButton();
TextEditPopupManager pm =
TextEditPopupManager.getInstance();
@@ -468,6 +480,13 @@
TypeListener listener = new TypeListener();
generateKeyButton.addActionListener(listener);
+ activeLinkPathField.setEditable(false);
+ activeLinkCheckBox.addActionListener(new
ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+
activeLinkPathField.setEditable(activeLinkCheckBox.isSelected());
+ }
+ });
+
// Default port
portField.setText(TBGlobals.getProperty("NODE_PORT"));
//Default machine name
@@ -479,8 +498,10 @@
p.add(new JPanel(), BorderLayout.CENTER);
lip.addItem(i18n.str("port"), p);
lip.addItem(i18n.str("machineName"),machineNameField);
+
lip.addItem(i18n.str("add_activeLink"),activeLinkCheckBox);
+
lip.addItem(i18n.str("activeLinkPath"),activeLinkPathField);
lip.addItem(i18n.str("requestUri"),requestUriField);
- lip.addItem(i18n.str("insertUri"),insertUriField);
+ lip.addItem(i18n.str("insertUri"),insertUriField);
lip.addItem("",generateKeyButton);
setLayout(new BorderLayout());
add(lip, BorderLayout.CENTER);
@@ -523,6 +544,22 @@
return this.requestUriField.getText();
}
+ public void setActiveLink(boolean b){
+ this.activeLinkCheckBox.setSelected(b);
+ }
+
+ public boolean getActiveLink(){
+ return this.activeLinkCheckBox.isSelected();
+ }
+
+ public void setActiveLinkPath(String activeLinkPath){
+ this.activeLinkPathField.setText(activeLinkPath);
+ }
+
+ public String getActiveLinkPath(){
+ return this.activeLinkPathField.getText();
+ }
+
private class TypeListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof JButton){
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/messages_fr.properties
===================================================================
---
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/messages_fr.properties
2008-03-08 15:18:45 UTC (rev 18432)
+++
trunk/apps/thingamablog/src/net/sf/thingamablog/gui/properties/messages_fr.properties
2008-03-09 00:56:05 UTC (rev 18433)
@@ -111,3 +111,9 @@
invalid_variable_name_prompt=Les noms de variables ne peuvent comporter que
des lettres, des chiffres ou des underscores (_)
service=Service
file_name=Nom de fichier
+node_config=Configuration de la node
+node_config_panel=Vous pouvez configurer ici votre node.\n Si la configuration
n'est pas bonne, le flog sera publi? localement (vous avez la possibilit? de
changer cela dans la suite du pas ? pas).
+test_config=Tester la configuration
+hostname=Nom ou adresse de la machine h?te du node
+node_config_ok=Configuration de la node correcte
+invalide_node_config=Configuration de la node invalide
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
2008-03-08 15:18:45 UTC (rev 18432)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/transport/FCPTransport.java
2008-03-09 00:56:05 UTC (rev 18433)
@@ -43,10 +43,11 @@
private String insertURI;
private Client client;
private String failMsg;
- private boolean hasPublish = false;
private int edition;
private String hostname;
private int port;
+ private boolean activeLink;
+ private String activeLinkPath;
/**
* Connects the transport
@@ -137,6 +138,17 @@
putDir.addFileEntry(fileEntry);
}
}
+ // If there is an active link set, we publish it
+ if (activeLink) {
+ File file = new File(activeLinkPath);
+ String content = DefaultMIMETypes.guessMIMEType(file.getName());
+ FileEntry fileEntry = new DiskFileEntry("activelink.png", content,
file.getPath());
+ if (fileEntry != null) {
+ System.out.println("File to insert : activelink.png");
+ totalBytes += file.length();
+ putDir.addFileEntry(fileEntry);
+ }
+ }
try {
tp.publishStarted(totalBytes);
client.execute(putDir);
@@ -213,6 +225,22 @@
return this.edition;
}
+ public void setActiveLink(boolean b){
+ this.activeLink = b;
+ }
+
+ public boolean getActiveLink(){
+ return this.activeLink;
+ }
+
+ public void setActiveLinkPath(String activeLinkPath){
+ this.activeLinkPath = activeLinkPath;
+ }
+
+ public String getActiveLinkPath(){
+ return this.activeLinkPath;
+ }
+
private String shortenURI(String uri) {
if (uri.startsWith("freenet:")) {
uri = uri.substring("freenet:".length());
Modified:
trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
===================================================================
--- trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
2008-03-08 15:18:45 UTC (rev 18432)
+++ trunk/apps/thingamablog/src/net/sf/thingamablog/xml/TBPersistFactory.java
2008-03-09 00:56:05 UTC (rev 18433)
@@ -481,6 +481,10 @@
transport.setAttribute("port",fpt.getPort() + "");
transport.setAttribute("edition",fpt.getEdition()+"");
transport.setAttribute("insertURI",fpt.getInsertURI());
+ transport.setAttribute("activeLink",fpt.getActiveLink() +
"");
+ if (fpt.getActiveLink()){
+
transport.setAttribute("activeLinkPath",fpt.getActiveLinkPath());
+ }
}
else
{
@@ -874,6 +878,10 @@
fcp.setNode(transport.getAttributeValue("hostname"),
Integer.parseInt(transport.getAttributeValue("port")));
fcp.setEdition(transport.getAttributeValue("edition"));
fcp.setInsertURI(transport.getAttributeValue("insertURI"));
+
fcp.setActiveLink(Boolean.valueOf(transport.getAttributeValue("activeLink")).booleanValue());
+ if (fcp.getActiveLink()){
+
fcp.setActiveLinkPath(transport.getAttributeValue("activeLinkPath"));
+ }
pubTransport = fcp;
}
else