Added a data class for the comment types

This commit is contained in:
Erik C. Thauvin 2024-05-24 17:15:15 -07:00
parent 156d85fee1
commit 0480a72c30
Signed by: erik
GPG key ID: 776702A6A2DA330E
100 changed files with 1760 additions and 343 deletions

View file

@ -1 +1 @@
akismet-examples-gradle
akismet-kotlin-examples-gradle

View file

@ -6,8 +6,11 @@
<list size="0" />
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="17" project-jdk-type="JavaSDK" />
<component name="SuppressionsComponent">
<option name="suppComments" value="[]" />
</component>
</project>
</project>

13
examples/gradle/.idea/modules.xml generated Normal file
View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/akismet-examples-gradle.iml" filepath="$PROJECT_DIR$/.idea/modules/akismet-examples-gradle.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/akismet-examples-gradle.main.iml" filepath="$PROJECT_DIR$/.idea/modules/akismet-examples-gradle.main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/akismet-examples-gradle.test.iml" filepath="$PROJECT_DIR$/.idea/modules/akismet-examples-gradle.test.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/gradle.akismet-examples-gradle.iml" filepath="$PROJECT_DIR$/.idea/modules/gradle.akismet-examples-gradle.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/gradle.akismet-examples-gradle.main.iml" filepath="$PROJECT_DIR$/.idea/modules/gradle.akismet-examples-gradle.main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/gradle.akismet-examples-gradle.test.iml" filepath="$PROJECT_DIR$/.idea/modules/gradle.akismet-examples-gradle.test.iml" />
</modules>
</component>
</project>

View file

@ -7,4 +7,4 @@
* in the user manual at https://docs.gradle.org/5.6.2/userguide/multi_project_builds.html
*/
rootProject.name = "akismet-examples"
rootProject.name = "akismet-kotlin-examples-gradle"

View file

@ -3,6 +3,7 @@ package com.example;
import net.thauvin.erik.akismet.Akismet;
import net.thauvin.erik.akismet.AkismetComment;
import net.thauvin.erik.akismet.CommentConfig;
import net.thauvin.erik.akismet.CommentType;
import java.util.Date;
@ -15,7 +16,7 @@ public class AkismetSample {
.isTest(true)
.referrer("https://www.google.com")
.permalink(akismet.getBlog() + "post=1")
.type(AkismetComment.TYPE_COMMENT)
.type(CommentType.COMMENT)
.author("admin")
.authorEmail("test@test.com")
.authorUrl("http://www.CheckOutMyCoolSite.com")

View file

@ -2,6 +2,7 @@ package com.example
import net.thauvin.erik.akismet.Akismet
import net.thauvin.erik.akismet.AkismetComment
import net.thauvin.erik.akismet.CommentType
import java.util.*
import kotlin.system.exitProcess
@ -12,7 +13,7 @@ fun main(args: Array<String>) {
isTest = true
referrer = "https://www.google.com"
permalink = "${akismet.blog}post=1"
type = AkismetComment.TYPE_COMMENT
type = CommentType.COMMENT
author = "admin"
authorEmail = "test@test.com"
authorUrl = "https://www.CheckOutMyCoolSite.com"

View file

@ -7,8 +7,9 @@ import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse
import net.thauvin.erik.akismet.Akismet
import net.thauvin.erik.akismet.AkismetComment
import net.thauvin.erik.akismet.CommentType
import java.io.IOException
import java.util.Date
import java.util.*
@WebServlet(description = "Akismet Servlet", displayName = "Akismet", urlPatterns = ["/comment/*"])
class AkismetServlet : HttpServlet() {
@ -22,7 +23,7 @@ class AkismetServlet : HttpServlet() {
val comment = AkismetComment(request).apply {
permalink = "${akismet.blog}/comment/$id"
type = AkismetComment.TYPE_COMMENT
type = CommentType.COMMENT
author = request.getParameter("name")
authorEmail = request.getParameter("email")
dateGmt = Akismet.dateToGmt(Date())