Skip to content
Browse files

added applescript plugin support and a redirect option for the plugin…

… 'api'
  • Loading branch information...
1 parent 0a5887b commit 805ce67c460ace52f8a517c9b350a2af79b71ab1 @kinabalu committed Feb 3, 2010
View
BIN applescript-plugin/Mystic Paste.scpt
Binary file not shown.
View
2 web/src/main/java/com/mysticcoders/mysticpaste/MysticPasteApplication.java
@@ -39,10 +39,12 @@ protected void init() {
super.init();
uploadFolder = new Folder(System.getProperty("java.io.tmpdir"), "wicket-uploads");
+/*
// Ensure folder exists
if(!uploadFolder.mkdirs()) {
throw new RuntimeException("Fatal error: Can't create temp directory for uploads at: " + System.getProperty("java.io.tmpdir"));
}
+*/
addComponentInstantiationListener(getSpringComponentInjector(this));
View
8 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/paste/PasteItemPage.java
@@ -83,6 +83,7 @@ public void setTwitter(boolean twitter) {
protected void onSubmit() {
+/*
final FileUpload upload = fileUploadField.getFileUpload();
if (upload != null)
{
@@ -105,6 +106,7 @@ protected void onSubmit() {
throw new IllegalStateException("Unable to write file");
}
}
+*/
PasteItem pasteItem = PasteForm.this.getModelObject();
if (pasteItem.getContent() == null || pasteItem.getContent().equals("")) {
@@ -147,17 +149,21 @@ public boolean hasSpamKeywords(String content) {
return false;
}
- private FileUploadField fileUploadField;
+/*
+ private FileUploadField fileUploadField;
private FileUpload imageFile;
+*/
public PasteForm(String id, IModel<PasteItem> model) {
super(id, model);
+/*
setMultiPart(true);
setMaxSize(Bytes.kilobytes(1024));
add(fileUploadField = new FileUploadField("imageFile", new PropertyModel(PasteForm.this, "imageFile")));
+*/
add(new CheckBox("private"));
add(new CheckBox("twitter", new PropertyModel<Boolean>(PasteForm.this, "twitter")));
View
5 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/SwfExample.java
@@ -9,12 +9,15 @@
import com.mysticcoders.mysticpaste.web.components.swf.SwfBehavior;
import com.mysticcoders.mysticpaste.web.pages.BasePage;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.model.PropertyModel;
+
+import java.io.Serializable;
public class SwfExample extends BasePage {
private static final long serialVersionUID = 1L;
public SwfExample() {
add(new Label("youtube").add(new SwfBehavior("http://www.youtube.com/v/2LTLEVC-sfQ&hl=en&fs=1&")));
-
}
+
}
View
146 web/src/main/java/com/mysticcoders/mysticpaste/web/servlet/PluginServlet.java
@@ -1,87 +1,97 @@
package com.mysticcoders.mysticpaste.web.servlet;
-import java.io.IOException;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
+import com.mysticcoders.mysticpaste.model.PasteItem;
+import com.mysticcoders.mysticpaste.services.InvalidClientException;
+import com.mysticcoders.mysticpaste.services.PasteService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ApplicationContext;
-import org.springframework.web.context.support.WebApplicationContextUtils;
+public class PluginServlet extends HttpServlet {
+ private final Logger logger = LoggerFactory.getLogger(getClass());
-import com.mysticcoders.mysticpaste.model.PasteItem;
-import com.mysticcoders.mysticpaste.services.InvalidClientException;
-import com.mysticcoders.mysticpaste.services.PasteService;
+ private static final String DEFAULT_LANG = "text";
-public class PluginServlet extends HttpServlet {
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
- private static final String DEFAULT_LANG = "text";
-
- private static PasteService pasteService;
-
- private static PasteService getPasteService(ServletContext sContext) {
- if (pasteService == null) {
- ApplicationContext ctx =WebApplicationContextUtils.getWebApplicationContext(sContext);
- pasteService = (PasteService) ctx.getBean("pasteService");
- }
+ private static PasteService pasteService;
+
+ private static PasteService getPasteService(ServletContext sContext) {
+ if (pasteService == null) {
+ ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(sContext);
+ pasteService = (PasteService) ctx.getBean("pasteService");
+ }
return pasteService;
- }
-
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp)
- throws ServletException, IOException {
- String type = req.getParameter("type");
- String content = req.getParameter("content");
- String fileExtension = req.getParameter("fileExt");
-
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ String type = req.getParameter("type");
+ String content = req.getParameter("content");
+ String fileExtension = req.getParameter("fileExt");
+ String redirect = req.getParameter("redirect");
+
PasteItem item = new PasteItem();
item.setContent(content);
if (fileExtension == null || fileExtension.isEmpty()) {
- item.setType(type == null || type.isEmpty() ? DEFAULT_LANG : type);
+ item.setType(type == null || type.isEmpty() ? DEFAULT_LANG : type);
+ } else {
+ item.setType(mapFileType(fileExtension));
+ }
+
+ try {
+ getPasteService(getServletContext()).createItem("plugin", item);
+ } catch (InvalidClientException e) {
+ e.printStackTrace();
+ }
+
+
+ StringBuilder sb = new StringBuilder("http://");
+ sb.append(req.getServerName());
+ if (req.getServerPort() != 80) {
+ sb.append(":").append(req.getServerPort());
+ }
+
+ sb.append("/view/").append(item.getId());
+
+ if (redirect != null && redirect.equalsIgnoreCase("true")) {
+ resp.sendRedirect(sb.toString());
+
} else {
- item.setType(mapFileType(fileExtension));
+ resp.setHeader("X-Paste-Identifier", "" + item.getId()); // Added to allow pastebin integration with the VIM plugin
+
+ resp.getWriter().print(item.getId());
+ resp.flushBuffer();
}
-
+
+ }
+
+ /**
+ * Map file extensions (i.e. java, cpp, sql, h, js) to types recognized by
+ * our system (jashi types)
+ *
+ * @param fileExtension
+ * @return
+ */
+ private String mapFileType(String fileExtension) {
+ String ret = DEFAULT_LANG;
+ ResourceBundle bundle = ResourceBundle.getBundle("com.mysticcoders.mysticpaste.config.syntax");
try {
- getPasteService(getServletContext()).createItem("plugin", item);
- } catch (InvalidClientException e) {
- e.printStackTrace();
- }
-
-/*
- resp.setHeader("X-Paste-Identifier", ""+item.getId()); // Added to allow pastebin integration with the VIM plugin
-
- resp.getWriter().print(item.getId());
- resp.flushBuffer();
-*/
-
- resp.sendRedirect("http://mysticpaste.com/view/"+item.getId());
- }
-
-
- /**
- * Map file extensions (i.e. java, cpp, sql, h, js) to types recognized by
- * our system (jashi types)
- * @param fileExtension
- * @return
- */
- private String mapFileType(String fileExtension) {
- String ret = DEFAULT_LANG;
- ResourceBundle bundle = ResourceBundle.getBundle("com.mysticcoders.mysticpaste.config.syntax");
- try {
- //lookup the file extension from our properties file to find the SyntaxHighlighter type
- ret = bundle.getString(fileExtension.toLowerCase());
- } catch (MissingResourceException mre) {
- //do nothing, the default will be text
- logger.warn("Could not find a SyntaxHighlighter mapping for the file extension: " + fileExtension);
- }
- return ret;
- }
+ //lookup the file extension from our properties file to find the SyntaxHighlighter type
+ ret = bundle.getString(fileExtension.toLowerCase());
+ } catch (MissingResourceException mre) {
+ //do nothing, the default will be text
+ logger.warn("Could not find a SyntaxHighlighter mapping for the file extension: " + fileExtension);
+ }
+ return ret;
+ }
}
View
2 web/src/main/resources/com/mysticcoders/mysticpaste/web/pages/paste/PasteItemPage.html
@@ -34,9 +34,11 @@
</div>
</div>
+<!--
<div id="paste_image">
<input wicket:id="imageFile" type="file" />
</div>
+-->
<div id="paste_submit">
<input type="submit" wicket:id="paste" accesskey="p" value="Paste" /></div>
</form>
View
29 web/src/main/resources/com/mysticcoders/mysticpaste/web/pages/plugin/PluginPage.html
@@ -7,7 +7,7 @@
<div class="pluginContent">
<div class="pluginHeader">Eclipse Plugin</div>
<div class="pluginText">
- <a href="http://kenai.com/projects/mystic-apps/sources/mystic-apps/show/MysticPasteEclipsePlugin/build/plugins">Download Now</a><br/><br/>
+ <a href="http://github.com/kinabalu/mysticpaste/tree/master/eclipse-plugin/build/plugins/">Download Now</a><br/><br/>
Locate where on your file system Eclipse is installed. Under this directory there should be a "dropins"
folder, this is where the jar you built (or downloaded) for the plugin should reside.<br/>
Restart Eclipse, and voila!<br/>
@@ -21,7 +21,7 @@
<div class="pluginContent">
<div class="pluginHeader">IDEA Plugin</div>
<div class="pluginText">
- <a href="http://kenai.com/projects/mystic-apps/sources/mystic-apps/show/MysticPasteIDEAPlugin/build">Download Now</a><br/><br/>
+ <a href="http://github.com/kinabalu/mysticpaste/tree/master/idea-plugin/build/">Download Now</a><br/><br/>
<strong>To install the MysticPaste Plugin for IDEA:</strong>
@@ -37,7 +37,7 @@
<div class="pluginContent">
<div class="pluginHeader">VIM Plugin</div>
<div class="pluginText">
- <a href="http://kenai.com/projects/mystic-apps/sources/mystic-apps/show/MysticPasteVIMPlugin/build">Download Now</a><br/><br/>
+ <a href="http://github.com/kinabalu/mysticpaste/tree/master/vim-plugin/build/">Download Now</a><br/><br/>
Mystic worked with <a href="http://www.eugeneciurana.com" target="_blank">Eugene Ciurana</a> on a configuration of MysticPaste for his
newly written VIM plugin. Thanks Eugene!
@@ -57,7 +57,7 @@
<div class="pluginContent">
<div class="pluginHeader">Netbeans Plugin</div>
<div class="pluginText">
- <a href="http://kenai.com/projects/mystic-apps/sources/mystic-apps/show/MysticPasteNetbeansPlugin/build">Download Now</a><br/><br/>
+ <a href="http://github.com/kinabalu/mysticpaste/tree/master/netbeans-plugin/build/">Download Now</a><br/><br/>
The MysticPaste Netbeans plugin was developed by <a href="http://blank.jasonwhaley.com" target="_blank">Jason Whaley</a> and is compatible with Netbeans 6.5.
<br /><br />
@@ -75,6 +75,27 @@
</div>
</div>
+ <div class="pluginContent">
+ <div class="pluginHeader">AppleScript Launchbar Plugin</div>
+ <div class="pluginText">
+ <a href="http://kenai.com/projects/mystic-apps/sources/mystic-apps/show/MysticPasteNetbeansPlugin/build">Download Now</a><br/><br/>
+
+ The launchbar plugin was designed to grab any text via Instant Send or contained within the clipboard and running the applescript will automatically paste
+ the contents to MysticPaste.com and give you the full URL in the clipboard and select it with Launchbar.
+
+ <br /><br />
+ <strong>To install and use the MysticPaste Plugin for Launchbar:</strong>
+ <ol>
+ <li>Download the Launchbar plugin</li>
+ <li>Copy the Applescript to ~/Library/Application Support/LaunchBar/Actions</li>
+ <li>Select some text and add to clipboard</li>
+ <li>Type in "Mystic Paste" and hit &lt;enter&gt;</li>
+ <li>See the URL show up in launchbar and also contained within your clipboard for easy pasting</li>
+ </ol>
+
+ </div>
+ </div>
+
</div>
</wicket:extend>
</html>
View
2 web/src/test/java/com/mysticcoders/webapp/TestPastePage.java
@@ -49,7 +49,7 @@ public void setup() {
tester = new WicketTester(new MysticPasteApplication() {
@Override
protected IComponentInstantiationListener getSpringComponentInjector(WebApplication application) {
- return new SpringComponentInjector(application, appctx);
+ return new SpringComponentInjector(application, appctx, true);
}
});
}

0 comments on commit 805ce67

Please sign in to comment.
Something went wrong with that request. Please try again.