Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

keeping up with the spammers

  • Loading branch information...
commit 2a4955e9df497ef648031d9a69620846b48b866b 1 parent 4a5cb11
@kinabalu authored
Showing with 270 additions and 211 deletions.
  1. +12 −12 pom.xml
  2. +1 −5 web/pom.xml
  3. +1 −1  web/src/main/filters/filters-DEV.properties
  4. +48 −6 web/src/main/java/com/mysticcoders/mysticpaste/model/PasteItem.java
  5. +0 −1  web/src/main/java/com/mysticcoders/mysticpaste/persistence/hibernate/PasteItemDaoImpl.java
  6. +99 −0 web/src/main/java/com/mysticcoders/mysticpaste/utils/StringUtils.java
  7. +0 −4 web/src/main/java/com/mysticcoders/mysticpaste/web/components/highlighter/HighlighterPanel.html
  8. +1 −39 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/history/HistoryPage.java
  9. +10 −88 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/paste/PasteItemPage.java
  10. +18 −3 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/PasteAsTextResource.java
  11. +3 −1 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/ViewPastePage.html
  12. +44 −36 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/ViewPastePage.java
  13. +3 −0  web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/ViewPrivatePage.html
  14. +8 −0 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/ViewPrivatePage.java
  15. +7 −0 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/ViewPublicPage.java
  16. +2 −2 web/src/main/resources/log4j.properties
  17. +1 −1  web/src/main/webapp/assets/css/jquery.wysiwyg.css
  18. +2 −2 web/src/main/webapp/assets/css/style.css
  19. +7 −7 web/src/main/webapp/assets/fonts/titillium/stylesheet.css
  20. +3 −3 web/src/main/webapp/assets/js/facebox.js
View
24 pom.xml
@@ -15,13 +15,9 @@
<developers>
<developer>
- <name>Craig Tataryn</name>
- <email>ctataryn@mysticcoders.com</email>
- </developer>
- <developer>
- <name>Guillermo Castro</name>
- <email>gcastro@mysticcoders.com</email>
- <timezone>-6</timezone>
+ <name>Andrew Lombardi</name>
+ <email>andrew@mysticcoders.com</email>
+ <timezone>-8</timezone>
</developer>
<developer>
<name>Johan Edstrom</name>
@@ -32,9 +28,13 @@
<email>sforsyth@mysticcoders.com</email>
</developer>
<developer>
- <name>Andrew Lombardi</name>
- <email>andrew@mysticcoders.com</email>
- <timezone>-8</timezone>
+ <name>Guillermo Castro</name>
+ <email>gcastro@mysticcoders.com</email>
+ <timezone>-6</timezone>
+ </developer>
+ <developer>
+ <name>Craig Tataryn</name>
+ <email>ctataryn@mysticcoders.com</email>
</developer>
</developers>
@@ -66,7 +66,7 @@
<!-- WICKET DEPENDENCIES -->
<dependency>
<groupId>org.apache.wicket</groupId>
- <artifactId>wicket</artifactId>
+ <artifactId>wicket-core</artifactId>
<version>${wicket.version}</version>
</dependency>
<dependency>
@@ -272,7 +272,7 @@
</dependencyManagement>
<properties>
- <wicket.version>1.5-SNAPSHOT</wicket.version>
+ <wicket.version>1.5.3</wicket.version>
<jetty.version>6.1.4</jetty.version>
<spring.version>3.0.0.RELEASE</spring.version>
<hibernate.version>3.5.0-Final</hibernate.version>
View
6 web/pom.xml
@@ -79,10 +79,6 @@
<id>jboss</id>
<url>http://repository.jboss.org/maven2</url>
</repository>
- <repository>
- <id>mystic</id>
- <url>http://maven.mysticcoders.com/repository</url>
- </repository>
</repositories>
<dependencies>
@@ -94,7 +90,7 @@
<!-- WICKET DEPENDENCIES -->
<dependency>
<groupId>org.apache.wicket</groupId>
- <artifactId>wicket</artifactId>
+ <artifactId>wicket-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.wicket</groupId>
View
2  web/src/main/filters/filters-DEV.properties
@@ -6,7 +6,7 @@ jdbc.password=yil2SNcOT5KB
# Hibernate properties
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
-hibernate.show_sql=true
+hibernate.show_sql=false
hibernate.use_outer_join=true
hibernate.cache.use_query_cache=true
View
54 web/src/main/java/com/mysticcoders/mysticpaste/model/PasteItem.java
@@ -5,10 +5,8 @@
import javax.persistence.*;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.text.SimpleDateFormat;
+import java.util.*;
/**
* @author <a href="mailto:gcastro@mysticcoders.com">Guillermo Castro</a>
@@ -34,11 +32,13 @@
@NamedQuery(name = "item.count",
query = "select count(item) from PasteItem item where item.isPrivate <> true AND item.abuseFlag <> true"),
@NamedQuery(name = "item.children",
- query = "from PasteItem item where item.parent = :pasteItem")
+ query = "from PasteItem item where item.parent = :pasteItem AND item.isPrivate <> true AND item.abuseFlag <> true")
})
public class PasteItem implements Serializable {
private static final long serialVersionUID = -6467870857777145137L;
+ private static SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
+
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ITEM_ID")
@@ -238,6 +238,9 @@ public int getContentLineCount() {
int new_line_count = 0;
int old_line_count = 0;
+ System.out.println("Original: "+(originalPaste!=null?originalPaste.length():0)+ " line(s)");
+ System.out.println("Revised: "+(revisedPaste!=null?revisedPaste.length():0)+ " line(s)");
+
List<String> original = Arrays.asList(originalPaste.split("\n"));
List<String> revised = Arrays.asList(revisedPaste.split("\n"));
@@ -287,4 +290,43 @@ public int getContentLineCount() {
return new Object[]{changedLines, diffText.toString()}; // TODO this is UGGGGGLY
}
-}
+
+
+ public static String getElapsedTimeSincePost(PasteItem pasteItem) {
+ String returnString;
+
+ Calendar today = Calendar.getInstance();
+ Calendar postDate = Calendar.getInstance();
+ postDate.setTime(pasteItem.getTimestamp());
+
+ long time = today.getTimeInMillis() - postDate.getTimeInMillis();
+ long mins = time / 1000 / 60;
+ long hours = mins / 60;
+ long days = hours / 24;
+
+ if (days > 30) {
+ // If it is more than 30 days old... just show the post date
+ returnString = "Posted " + sdf.format(postDate.getTime());
+ } else {
+ if (days > 0) {
+ // Then it is more than 1 day old but less than 30 days old... so show how many days old it is
+ returnString = "Posted " + days + " day" + (days > 1 ? "s" : "") + " ago";
+ } else {
+ if (hours > 0) {
+ // It has been more than 1 hr and less than a day... so display hrs
+ returnString = "Posted " + hours + " hour" + (hours > 1 ? "s" : "") + " ago";
+ } else {
+ if (mins > 0) {
+ // It has been more than 1 min and less than an hour... so display mins
+ returnString = "Posted " + mins + " minute" + (mins > 1 ? "s" : "") + " ago";
+ } else {
+ returnString = "Posted less than a minute ago";
+ }
+ }
+ }
+ }
+
+ return returnString;
+ }
+
+}
View
1  web/src/main/java/com/mysticcoders/mysticpaste/persistence/hibernate/PasteItemDaoImpl.java
@@ -76,7 +76,6 @@ public void markAbuse(PasteItem pasteItem) {
}
public List<PasteItem> getChildren(PasteItem pasteItem) {
- System.out.println("getChildren(PasteItem pasteItem)");
return (List<PasteItem>)getSession()
.getNamedQuery("item.children")
.setParameter("pasteItem", pasteItem)
View
99 web/src/main/java/com/mysticcoders/mysticpaste/utils/StringUtils.java
@@ -0,0 +1,99 @@
+package com.mysticcoders.mysticpaste.utils;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: kinabalu
+ * Date: 1/4/12
+ * Time: 5:29 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class StringUtils {
+
+ public static boolean hasSpamKeywords(String content) {
+ String lowercasedContent = content.toLowerCase();
+
+ for (String badWord : badWords) {
+ if (lowercasedContent.indexOf(badWord) != -1) return true;
+ }
+
+ return false;
+ }
+
+ private static String[] badWords = new String[]{
+ "[/URL]",
+ "[/url]",
+ "adipex",
+ "adultfriendfinder",
+ "adult-dvd",
+ "adult-friend-finder",
+ "adult-personal",
+ "adult personal",
+ "adult-stories",
+ "adult friends",
+ "boob",
+ "casino",
+ "cheap hotel",
+ "cialis",
+ "classified ad",
+ "diazepam",
+ "diazepan",
+ "fiksa.org",
+ "forexcurrency",
+ "free ringtones",
+ "fuck",
+ "gay porn",
+ "geo.ya",
+ "httpgeo",
+ "hot sex",
+ "hydroconone",
+ "incest",
+ "inderal",
+ "insulin",
+ "jewish dating",
+ "keflex",
+ "klonopin",
+ "lamictal",
+ "lasix",
+ "levaquin",
+ "levitra",
+ "lipitor",
+ "male porn",
+ "malenhancement",
+ "masya",
+ "mature porn",
+ "milf",
+ "murphy bed",
+ "nude celebrity",
+ "oxycodone",
+ "paxil",
+ "payday",
+ "phenergan",
+ "phentermine",
+ "poker",
+ "porn link",
+ "porn video",
+ "porno portal",
+ "pornmaster",
+ "premarin",
+ "prozac",
+ "rape",
+ "strattera",
+ "tramadol",
+ "tussionex",
+ "valium",
+ "viagra",
+ "vicodin",
+ "web gratis",
+ "without prescription",
+ "xanax",
+ "xxx ",
+ " xxx",
+ "xxxvideo",
+ "youradult",
+ "zelnorm",
+ "zenegra",
+ "megaupload.com",
+ "members.lycos.co.uk",
+ "lix.in"
+ };
+}
View
4 web/src/main/java/com/mysticcoders/mysticpaste/web/components/highlighter/HighlighterPanel.html
@@ -1,10 +1,6 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
- <script language="javascript" type="text/javascript">
- SyntaxHighlighter.all();
- </script>
-
<pre wicket:id="code" class="java"></pre>
</wicket:panel>
View
40 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/history/HistoryPage.java
@@ -29,8 +29,6 @@
@SpringBean
PasteService pasteService;
- SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
-
DataView historyDataView;
protected String getTitle() {
@@ -54,7 +52,7 @@ protected void populateItem(Item<PasteItem> item) {
item.add(new Label("lineCount", "(" + contentLines.length + " Line" +
(contentLines.length > 1 ? "s" : "") + ")"));
- item.add(new Label("posted", getElapsedTimeSincePost(pasteItem)));
+ item.add(new Label("posted", PasteItem.getElapsedTimeSincePost(pasteItem)));
item.add(new HighlighterPanel("content",
new PropertyModel<String>(pasteItem, "previewContent"), pasteItem.getType()));
@@ -87,40 +85,4 @@ public boolean isVisible() {
});
}
- private String getElapsedTimeSincePost(PasteItem pasteItem) {
- String returnString;
-
- Calendar today = Calendar.getInstance();
- Calendar postDate = Calendar.getInstance();
- postDate.setTime(pasteItem.getTimestamp());
-
- long time = today.getTimeInMillis() - postDate.getTimeInMillis();
- long mins = time / 1000 / 60;
- long hours = mins / 60;
- long days = hours / 24;
-
- if (days > 30) {
- // If it is more than 30 days old... just show the post date
- returnString = "Posted " + sdf.format(postDate);
- } else {
- if (days > 0) {
- // Then it is more than 1 day old but less than 30 days old... so show how many days old it is
- returnString = "Posted " + days + " day" + (days > 1 ? "s" : "") + " ago";
- } else {
- if (hours > 0) {
- // It has been more than 1 hr and less than a day... so display hrs
- returnString = "Posted " + hours + " hour" + (hours > 1 ? "s" : "") + " ago";
- } else {
- if (mins > 0) {
- // It has been more than 1 min and less than an hour... so display mins
- returnString = "Posted " + mins + " minute" + (mins > 1 ? "s" : "") + " ago";
- } else {
- returnString = "Posted less than a minute ago";
- }
- }
- }
- }
-
- return returnString;
- }
}
View
98 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/paste/PasteItemPage.java
@@ -5,6 +5,7 @@
import com.mysticcoders.mysticpaste.model.PasteItem;
import com.mysticcoders.mysticpaste.services.InvalidClientException;
import com.mysticcoders.mysticpaste.services.PasteService;
+import com.mysticcoders.mysticpaste.utils.StringUtils;
import com.mysticcoders.mysticpaste.web.components.DefaultFocusBehavior;
import com.mysticcoders.mysticpaste.web.components.highlighter.HighlighterPanel;
import com.mysticcoders.mysticpaste.web.pages.BasePage;
@@ -20,6 +21,8 @@
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.apache.wicket.util.file.Files;
import org.apache.wicket.util.file.Folder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.io.File;
@@ -34,6 +37,8 @@
@SpringBean
PasteService pasteService;
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
public PasteItemPage() {
super(PasteItemPage.class);
@@ -101,7 +106,7 @@ private void onPaste(boolean isPrivate) {
return;
}
- if (getSpamEmail() != null || hasSpamKeywords(pasteItem.getContent())) {
+ if (getSpamEmail() != null || StringUtils.hasSpamKeywords(pasteItem.getContent())) {
error("Spam Spam Spam Spam");
return;
}
@@ -110,6 +115,8 @@ private void onPaste(boolean isPrivate) {
pasteItem.setType(getLanguageType() != null ? getLanguageType().getLanguage() : "text");
pasteItem.setClientIp(getClientIpAddress());
+ logger.info("New "+pasteItem.getContent()+" line "+(isPrivate ? "private":"public")+" paste created with IP:"+getClientIpAddress()+" language set at:"+pasteItem.getType());
+
try {
pasteService.createItem("web", pasteItem);
PageParameters params = new PageParameters();
@@ -128,16 +135,6 @@ private void onPaste(boolean isPrivate) {
}
}
- public boolean hasSpamKeywords(String content) {
- String lowercasedContent = content.toLowerCase();
-
- for (String badWord : badWords) {
- if (lowercasedContent.indexOf(badWord) != -1) return true;
- }
-
- return false;
- }
-
/*
private FileUploadField fileUploadField;
@@ -215,82 +212,7 @@ private Folder getUploadFolder() {
return ((MysticPasteApplication) Application.get()).getUploadFolder();
}
- private String[] badWords = new String[]{
- "[/URL]",
- "[/url]",
- "adipex",
- "adultfriendfinder",
- "adult-dvd",
- "adult-friend-finder",
- "adult-personal",
- "adult personal",
- "adult-stories",
- "adult friends",
- "boob",
- "casino",
- "cheap hotel",
- "cialis",
- "classified ad",
- "diazepam",
- "diazepan",
- "fiksa.org",
- "forexcurrency",
- "free ringtones",
- "fuck",
- "gay porn",
- "geo.ya",
- "httpgeo",
- "hot sex",
- "hydroconone",
- "incest",
- "inderal",
- "insulin",
- "jewish dating",
- "keflex",
- "klonopin",
- "lamictal",
- "lasix",
- "levaquin",
- "levitra",
- "lipitor",
- "male porn",
- "malenhancement",
- "masya",
- "mature porn",
- "milf",
- "murphy bed",
- "nude celebrity",
- "oxycodone",
- "paxil",
- "payday",
- "phenergan",
- "phentermine",
- "poker",
- "porn link",
- "porn video",
- "porno portal",
- "pornmaster",
- "premarin",
- "prozac",
- "rape",
- "strattera",
- "tramadol",
- "tussionex",
- "valium",
- "viagra",
- "vicodin",
- "web gratis",
- "without prescription",
- "xanax",
- "xxx ",
- " xxx",
- "xxxvideo",
- "youradult",
- "zelnorm",
- "zenegra",
- "megaupload.com",
- "members.lycos.co.uk",
- "lix.in"
- };
+
+
}
}
View
21 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/PasteAsTextResource.java
@@ -4,6 +4,8 @@
import com.mysticcoders.mysticpaste.services.InvalidClientException;
import com.mysticcoders.mysticpaste.services.PasteService;
import org.apache.wicket.injection.Injector;
+import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.request.http.WebResponse;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.AbstractResource;
import org.apache.wicket.request.resource.ContentDisposition;
@@ -12,12 +14,16 @@
import org.apache.wicket.request.resource.IResource;
import org.apache.wicket.request.resource.ResourceReference;
import org.apache.wicket.util.string.StringValue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Locale;
public class PasteAsTextResource extends ResourceReference {
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
@SpringBean
private static PasteService pasteService;
@@ -55,7 +61,6 @@ protected ResourceResponse newResourceResponse(Attributes attributes) {
if (resourceResponse.dataNeedsToBeWritten(attributes)) {
PageParameters params = attributes.getParameters();
-
resourceResponse.setContentDisposition(getContentDisposition());
if (getFileName(params) != null) {
@@ -81,8 +86,18 @@ public void writeData(Attributes attributes) {
} catch(NumberFormatException e) {
pasteItem = pasteService.findPrivateItem("web", params.get("0").toString());
}
-
- attributes.getResponse().write(pasteItem.getContent().getBytes());
+
+ logger.info("Paste ID["+pasteItem.getId()+"] requested text / download");
+ if(pasteItem.isPrivate()) {
+ //X-Robots-Tag: noindex
+ ((WebResponse)attributes.getResponse()).addHeader("X-Robots-Tag", "noindex");
+ }
+ if(!pasteItem.isAbuseFlag()) {
+ attributes.getResponse().write(pasteItem.getContent().getBytes());
+ } else {
+ logger.info("Abuse Paste accessed id["+pasteItem.getId()+"]");
+ attributes.getResponse().write("Marked for abuse.".getBytes());
+ }
} catch (InvalidClientException e) {
}
View
4 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/ViewPastePage.html
@@ -38,7 +38,7 @@
<li><a wicket:id="rawLink">Raw</a></li>
<li><a wicket:id="downloadLink">Download</a></li>
<li><a wicket:id="markAbuseLink"><span wicket:id="markAbuseLabel">[markAbuseLabel]</span></a></li>
- <li><a href="ViewPastePage.html#replytopaste"><img src="assets/images/action_refresh.gif" border="0" /> Reply to Paste</a></li>
+ <li><a href="#replytopaste"><img src="assets/images/action_refresh.gif" border="0" /> Reply to Paste</a></li>
</ul>
</div>
<div class="block_content">
@@ -85,6 +85,8 @@
<textarea wicket:id="content" id="rawPaste" wrap="off"
style="height: 250px; width: 100%; background-color: #eeeeee; border: 1px solid #555;"></textarea>
+ <span style="display: none; visibility: hidden;"><input wicket:id="email" /></span>
+
<p>&nbsp;</p>
<p class="right" align="right">
View
80 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/ViewPastePage.java
@@ -9,43 +9,33 @@
import com.mysticcoders.mysticpaste.model.PasteItem;
import com.mysticcoders.mysticpaste.services.InvalidClientException;
import com.mysticcoders.mysticpaste.services.PasteService;
+import com.mysticcoders.mysticpaste.utils.StringUtils;
import com.mysticcoders.mysticpaste.web.components.highlighter.HighlighterPanel;
import com.mysticcoders.mysticpaste.web.pages.BasePage;
-import com.mysticcoders.mysticpaste.web.pages.HelpPage;
import com.mysticcoders.mysticpaste.web.pages.error.PasteNotFound;
import com.mysticcoders.mysticpaste.web.pages.error.PasteSpam;
-import com.mysticcoders.mysticpaste.web.pages.history.HistoryPage;
-import org.apache.wicket.Application;
import org.apache.wicket.RestartResponseException;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.SimpleAttributeModifier;
-import org.apache.wicket.devutils.stateless.StatelessComponent;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.markup.html.form.TextArea;
-import org.apache.wicket.markup.html.link.*;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.link.AbstractLink;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.ExternalLink;
+import org.apache.wicket.markup.html.link.StatelessLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.request.IRequestHandler;
-import org.apache.wicket.request.IRequestParameters;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler;
-import org.apache.wicket.request.http.WebResponse;
import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.apache.wicket.request.resource.ResourceReference;
-import org.apache.wicket.request.resource.SharedResourceReference;
import org.apache.wicket.spring.injection.annot.SpringBean;
-import org.apache.wicket.util.string.Strings;
+
import java.util.ArrayList;
import java.util.List;
-import java.util.Locale;
//@StatelessComponent
public abstract class ViewPastePage extends BasePage {
@@ -61,6 +51,12 @@ protected String getTitle() {
return "#" + params.get("0") + " - Mystic Paste";
}
+ final IModel<PasteItem> pasteModel;
+
+ protected PasteItem getPasteItem() {
+ return pasteModel.getObject();
+ }
+
protected abstract boolean isPublic();
public ViewPastePage(final PageParameters params) {
@@ -96,7 +92,7 @@ public ViewPastePage(final PageParameters params) {
sb.append(number).append(",");
}
- if(sb.length()>0)
+ if (sb.length() > 0)
highlightLines = sb.substring(0, sb.length() - 1);
}
@@ -107,13 +103,16 @@ public ViewPastePage(final PageParameters params) {
throw new RestartResponseException(ViewPrivatePage.class, pp);
}
- final IModel<PasteItem> pasteModel = getPasteModel(params.get("0").toString());
+ pasteModel = getPasteModel(params.get("0").toString());
if (pasteModel.getObject() == null || (pasteModel.getObject().isPrivate() && params.get("0").isNull())) {
throw new RestartResponseException(PasteNotFound.class);
}
if (pasteModel.getObject().isAbuseFlag()) {
throw new RestartResponseException(PasteSpam.class);
}
+ if (pasteModel.getObject().getContent() == null) {
+ pasteModel.getObject().setContent("");
+ }
this.setDefaultModel(new CompoundPropertyModel(pasteModel));
add(new Label("type"));
@@ -134,21 +133,19 @@ public boolean isVisible() {
Object[] diffOutput = PasteItem.diffPastes(parentPaste.getContent(), pasteModel.getObject().getContent());
- List<Integer> changedLines= (List<Integer>)diffOutput[0]; // TODO horrible horrible hackish thing, where do you get these things
- String diffText = (String)diffOutput[1];
+ List<Integer> changedLines = (List<Integer>) diffOutput[0]; // TODO horrible horrible hackish thing, where do you get these things
+ String diffText = (String) diffOutput[1];
diffView.add(new HighlighterPanel("highlightedContent",
- new Model<String>(diffText),
- parentPaste.getType(),
- false,
- highlightLines,
- changedLines));
+ new Model<String>(diffText),
+ parentPaste.getType(),
+ false,
+ highlightLines,
+ changedLines));
}
add(diffView);
-
-
/*
final AbstractReadOnlyModel<List<PasteItem>> childPastes = new AbstractReadOnlyModel<List<PasteItem>>() {
public List<PasteItem> getObject() {
@@ -182,13 +179,13 @@ protected void populateItem(ListItem<PasteItem> item) {
item.add(viewPaste);
- item.add(new Label("posted", "TODO"));// HistoryPage.getElapsedTimeSincePost(pasteItem))); // TODO refactor this into it's own class
+ item.add(new Label("posted", PasteItem.getElapsedTimeSincePost(pasteItem)));
}
});
String language = pasteModel.getObject().getType();
add(new HighlighterPanel("highlightedContent",
- new PropertyModel(pasteModel, "content"),
+ new PropertyModel<String>(pasteModel, "content"),
language, false,
highlightLines));
@@ -222,24 +219,35 @@ protected void onSubmit() {
add(replyForm);
replyForm.add(new TextArea<String>("content"));
+ replyForm.add(new TextField<String>("email", new PropertyModel<String>(ViewPastePage.this, "spamEmail")));
+
+
}
private String replyPaste;
+ private String spamEmail;
+
+ public String getSpamEmail() {
+ return spamEmail;
+ }
+
+ public void setSpamEmail(String spamEmail) {
+ this.spamEmail = spamEmail;
+ }
+
private void onPaste(IModel<PasteItem> pasteModel) {
PasteItem pI = pasteModel.getObject();
-/*
- if (pasteItem.getContent() == null || pasteItem.getContent().equals("")) {
+ if (pI.getContent() == null || pI.getContent().equals("")) {
error("Paste content is required!");
return;
}
- if (getSpamEmail() != null || hasSpamKeywords(pasteItem.getContent())) {
+ if (getSpamEmail() != null || StringUtils.hasSpamKeywords(pI.getContent())) {
error("Spam Spam Spam Spam");
return;
}
-*/
PasteItem pasteItem = new PasteItem();
pasteItem.setContent(pI.getContent());
pasteItem.setPrivate(pI.isPrivate());
@@ -269,7 +277,7 @@ private void onPaste(IModel<PasteItem> pasteModel) {
private AbstractLink createRawLink(final String id, final PageParameters params) {
- return new ExternalLink(id, "/view/"+params.get("0")+"/text");
+ return new ExternalLink(id, "/view/" + params.get("0") + "/text");
/*
ResourceReference ref = Application.get().getResourceReferenceRegistry().getResourceReference(PasteAsTextResource.class, "pasteAsTextResource", Locale.ENGLISH, null, null, false, false);
return new ResourceLink<Void>(id, ref, params) {
@@ -282,7 +290,7 @@ protected boolean getStatelessHint() {
}
private AbstractLink createDownloadLink(String id, PageParameters params) {
- return new ExternalLink(id, "/view/"+params.get("0")+"/download");
+ return new ExternalLink(id, "/view/" + params.get("0") + "/download");
/*
ResourceReference ref = Application.get().getResourceReferenceRegistry().getResourceReference(DownloadPasteAsTextResource.class, "downloadPasteAsTextResource", Locale.ENGLISH, null, null, false, false);
return new ResourceLink<Void>(id, ref, params) {
View
3  web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/ViewPrivatePage.html
@@ -1,4 +1,7 @@
<html xmlns:wicket="http://wicket.apache.org">
+<wicket:head>
+ <meta NAME="ROBOTS" CONTENT="noindex" />
+</wicket:head>
<wicket:extend>
</wicket:extend>
</html>
View
8 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/ViewPrivatePage.java
@@ -5,8 +5,12 @@
import com.mysticcoders.mysticpaste.services.PasteService;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.request.Request;
+import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* View Paste.
@@ -18,9 +22,13 @@
@SpringBean
PasteService pasteService;
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
public ViewPrivatePage(PageParameters params) {
super(params);
+
+ logger.info("Client ["+ getClientIpAddress() +"] viewing paste with ID["+getPasteItem().getId()+"]");
}
protected IModel<PasteItem> getPasteModel(String id) {
View
7 web/src/main/java/com/mysticcoders/mysticpaste/web/pages/view/ViewPublicPage.java
@@ -12,8 +12,11 @@
import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.*;
+import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* View Paste.
@@ -27,8 +30,12 @@
@SpringBean
PasteService pasteService;
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
public ViewPublicPage(PageParameters params) {
super(params);
+
+ logger.info("Client ["+ getClientIpAddress() +"] viewing paste with ID["+getPasteItem().getId()+"]");
}
protected IModel<PasteItem> getPasteModel(String id) {
View
4 web/src/main/resources/log4j.properties
@@ -10,8 +10,8 @@ log4j.logger.org.apache.wicket.version=INFO
log4j.logger.org.apache.wicket.RequestCycle=INFO
#log4j.logger.org.apache.wicket.util.resource=DEBUG
-log4j.logger.org.apache.commons.httpclient=DEBUG
-log4j.logger.org.jets3t=DEBUG
+log4j.logger.org.apache.commons.httpclient=INFO
+log4j.logger.org.jets3t=INFO
#log4j.logger.org.hibernate=DEBUG
#log4j.logger.org.springframework=DEBUG
View
2  web/src/main/webapp/assets/css/jquery.wysiwyg.css
@@ -4,7 +4,7 @@ div.wysiwyg * { margin: 0; padding: 0; outline: none; }
div.wysiwyg ul.panel { border-bottom: 1px solid #cccccc; background: #fafafa; float: left; width: 99.1%; padding: 5px; margin: 0; -webkit-border-top-left-radius: 3px; -webkit-border-top-right-radius: 3px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; }
div.wysiwyg ul.panel li { list-style-type: none; float: left; padding: 0; margin: 2px 2px 2px 0; background: none; height: 19px; overflow: hidden; }
div.wysiwyg ul.panel li.separator { height: 18px; margin: 3px 4px 0; border-left: 1px solid #cccccc; }
-div.wysiwyg ul.panel li a { text-indent: -5000px; opacity: 0.85; filter:alpha(opacity=85); display: block; width: 16px; height: 16px; background: url("'../images/jquery.wysiwyg.gif'") no-repeat -64px -80px; border: 0; cursor: pointer; padding: 0; margin: 1px; border: 1px solid #fafafa; }
+div.wysiwyg ul.panel li a { text-indent: -5000px; opacity: 0.85; filter:alpha(opacity=85); display: block; width: 16px; height: 16px; background: url('../images/jquery.wysiwyg.gif') no-repeat -64px -80px; border: 0; cursor: pointer; padding: 0; margin: 1px; border: 1px solid #fafafa; }
div.wysiwyg ul.panel li a:hover, div.wysiwyg ul.panel li a.active { opacity: 1.00; filter:alpha(opacity=100); }
div.wysiwyg ul.panel li a.active { border: 1px solid #ddd; background-color: #fff; padding: 0; }
View
4 web/src/main/webapp/assets/css/style.css
@@ -670,11 +670,11 @@ a:hover {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
- background: url("'../images/sdd.jpg'") center right no-repeat;
+ background: url('../images/sdd.jpg') center right no-repeat;
}
.block form .cmf-skinned-select:hover {
- background: url("'../images/sdd_.jpg'") center right no-repeat;
+ background: url('../images/sdd_.jpg') center right no-repeat;
}
.block form div.cmf-skinned-text {
View
14 web/src/main/webapp/assets/fonts/titillium/stylesheet.css
@@ -18,42 +18,42 @@
@font-face {
font-family: 'TitilliumRegular';
src: url("'TitilliumText1.eot'");
- src: local('Titillium Regular'), local('Titillium-Bold'), url("'TitilliumText1.ttf'") format('truetype');
+ src: local('Titillium Regular'), local('Titillium-Bold'), url("TitilliumText1.ttf") format('truetype');
}
@font-face {
font-family: 'Titillium250';
src: url("'TitilliumText250wt.eot'");
- src: local('Titillium 250 wt'), local('Titillium-250wt'), url("'TitilliumText250wt.ttf'") format('truetype');
+ src: local('Titillium 250 wt'), local('Titillium-250wt'), url("TitilliumText250wt.ttf") format('truetype');
}
@font-face {
font-family: 'Titillium400';
src: url("'TitilliumText400wt.eot'");
- src: local('Titillium 400 wt'), local('Titillium-400wt'), url("'TitilliumText400wt.ttf'") format('truetype');
+ src: local('Titillium 400 wt'), local('Titillium-400wt'), url("TitilliumText400wt.ttf") format('truetype');
}
@font-face {
font-family: 'Titillium600';
src: url("'TitilliumText600wt.eot'");
- src: local('Titillium 600 wt'), local('Titillium-600wt'), url("'TitilliumText600wt.ttf'") format('truetype');
+ src: local('Titillium 600 wt'), local('Titillium-600wt'), url("TitilliumText600wt.ttf") format('truetype');
}
@font-face {
font-family: 'Titillium800';
src: url("'TitilliumText800wt.eot'");
- src: local('Titillium 800 wt'), local('Titillium-800wt'), url("'TitilliumText800wt.ttf'") format('truetype');
+ src: local('Titillium 800 wt'), local('Titillium-800wt'), url("TitilliumText800wt.ttf") format('truetype');
}
@font-face {
font-family: 'Titillium999';
src: url("'TitilliumText999wt.eot'");
- src: local('Titillium 999 wt'), local('Titillium-999wt'), url("'TitilliumText999wt.ttf'") format('truetype');
+ src: local('Titillium 999 wt'), local('Titillium-999wt'), url("TitilliumText999wt.ttf") format('truetype');
}
@font-face {
font-family: 'TitilliumTitle';
src: url("'Titillium_title03.eot'");
- src: local('TitilliumTitle01 Thin'), local('TitilliumTitle01-Thin'), url("'Titillium_title03.ttf'") format('truetype');
+ src: local('TitilliumTitle01 Thin'), local('TitilliumTitle01-Thin'), url("Titillium_title03.ttf") format('truetype');
}
View
6 web/src/main/webapp/assets/js/facebox.js
@@ -79,8 +79,8 @@
settings: {
opacity : 0,
overlay : true,
- loadingImage : 'images/loading.gif',
- closeImage : 'images/closelabel.gif',
+ loadingImage : '/assets/images/loading.gif',
+ closeImage : '/assets/images/closelabel.gif',
imageTypes : [ 'png', 'jpg', 'jpeg', 'gif' ],
faceboxHtml : '\
<div id="facebox" style="display:none;"> \
@@ -97,7 +97,7 @@
</div> \
<div class="footer"> \
<a href="#" class="close"> \
- <img src="images/closelabel.gif" title="close" class="close_image" /> \
+ <img src="/assets/images/closelabel.gif" title="close" class="close_image" /> \
</a> \
</div> \
</td> \
Please sign in to comment.
Something went wrong with that request. Please try again.