Skip to content

Commit

Permalink
버그 수정, 버전 업데이트
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyBrick committed Oct 24, 2019
1 parent 90c9f05 commit e5d59f4
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 23 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'com.jfrog.bintray'

def libName = 'KotlinInside'
def libVersion = '1.0.0'
def libVersion = '1.0.1'
def libDesc = 'Unofficial DCInside API written in Kotlin'

group = 'be.zvz'
Expand Down Expand Up @@ -92,4 +92,4 @@ bintray {
}
}
}
*/
*/
2 changes: 1 addition & 1 deletion src/main/java/be/zvz/kotlininside/value/ApiUrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public final class ApiUrl {
public static final class Article {
public static final String LIST = APP_API + "gall_list_new.php";
public static final String READ = APP_API + "gall_view_new.php";
public static final String WRITE = "http://upload.dcinside.com/_app_write_api.php";
public static final String WRITE = "https://upload.dcinside.com/_app_write_api.php";
public static final String DELETE = APP_API + "gall_del.php";

public static final String UPVOTE = APP_API + "_recommend_up.php";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class ArticleDelete(
.addMultipartParameter("user_id", session.detail!!.userId)
}

val json = KotlinInside.getInstance().httpInterface.upload(ApiUrl.Article.DELETE, option)!!.index(0)
var json = KotlinInside.getInstance().httpInterface.upload(ApiUrl.Article.DELETE, option)!!

if (json.isList)
json = json.index(0)

val result = json.get("result").`as`(Boolean::class.java)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ class ArticleList @JvmOverloads constructor(
relationGall.toMap<String, String>()
else
mutableMapOf<String, String>()
/*relationGall.values().forEach {
val key = it.text()
this[key] = it.get(key).text() //this: LinkedHashMap<String, String>
}*/
},
headText = arrayListOf<HeadText>().apply {
gallInfo.safeGet("head_text").let { headText ->
Expand Down
18 changes: 8 additions & 10 deletions src/main/kotlin/be/zvz/kotlininside/api/article/ArticleVote.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,18 @@ class ArticleVote(
option
)!!

val firstResult = json.safeGet("result")

if (!firstResult.isNull)
return VoteResult(
result = firstResult.`as`(Boolean::class.java),
cause = json.get("cause").text()
)

json = json.index(0)
if (json.isList)
json = json.index(0)

return VoteResult(
result = json.get("result").`as`(Boolean::class.java),
cause = json.get("cause").text(),
member = json.get("member").`as`(Int::class.java)
member = json.safeGet("member").run {
when {
!isNull -> `as`(Int::class.java)
else -> null
}
}
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class ArticleWrite @JvmOverloads constructor(
option.addMultipartFile("upload[$imageCount]", content.file)
imageCount++
}
is StringContent -> option.addMultipartParameter("memo_block[$index]", URLEncoder.encode(StringUtil.toHtml(content.string), "UTF-8"))
is StringContent -> {
option.addMultipartParameter("memo_block[$index]", URLEncoder.encode("<div>" + StringUtil.toHtml(content.string), "UTF-8") + "</div>")
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/be/zvz/kotlininside/utils/StringUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class StringUtil {
'"' -> builder.append("&quot;")
'\n' -> builder.append("<br>")
'\t' -> builder.append("&nbsp; &nbsp; &nbsp;")
else -> if (c.toInt() < 128) {
else -> builder.append(c) /*if (c.toInt() < 128) {
builder.append(c)
} else {
builder.append("&#").append(c.toInt()).append(";")
}
}*/
}

}
return builder.toString()
}
}
}
}
13 changes: 12 additions & 1 deletion src/test/kotlin/be/zvz/kotlininside/KotlinInsideTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ package be.zvz.kotlininside
import be.zvz.kotlininside.api.article.*
import be.zvz.kotlininside.api.type.Article
import be.zvz.kotlininside.api.type.StringContent
import be.zvz.kotlininside.api.type.HeadText
import be.zvz.kotlininside.http.DefaultHttpClient
import be.zvz.kotlininside.session.user.Anonymous
import org.junit.jupiter.api.MethodOrderer
import org.junit.jupiter.api.Order
import org.junit.jupiter.api.TestMethodOrder
import org.junit.jupiter.api.TestInstance
import kotlin.test.Test
import kotlin.test.assertNotNull

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@TestMethodOrder(MethodOrderer.OrderAnnotation::class)
class KotlinInsideTest {
var articleId = 0
Expand Down Expand Up @@ -61,11 +64,19 @@ class KotlinInsideTest {
StringContent(
string = "글은 곧 자동으로 삭제됩니다.\n글의 비밀번호는 1234입니다."
)
)
),
headText = HeadText(
identifier = 0,
name = "일반",
level = 0,
selected = false
)
),
session = KotlinInside.getInstance().session
)

Thread.sleep(5_000)

val writeResult = articleWrite.write()

println(writeResult)
Expand Down

0 comments on commit e5d59f4

Please sign in to comment.