ASP Classic blog framework - BrainOrdure
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.1KB

  1. <%
  2. ' Auto-generated Controller: Comments
  3. ' Generated on 5/2/2026 9:47:38 PM
  4. ' Generator: generateController.vbs v1.0
  5. '
  6. ' Remember to:
  7. ' 1. Add to app/controllers/autoload_controllers.asp
  8. ' 2. Register in core/lib.ControllerRegistry.asp
  9. ' 3. Add routes in public/Default.asp
  10. Class CommentsController_Class
  11. Private m_useLayout
  12. Private m_title
  13. Private Sub Class_Initialize()
  14. m_useLayout = True
  15. m_title = "Comments"
  16. End Sub
  17. Public Property Get useLayout
  18. useLayout = m_useLayout
  19. End Property
  20. Public Property Let useLayout(v)
  21. m_useLayout = v
  22. End Property
  23. Public Property Get Title
  24. Title = m_title
  25. End Property
  26. Public Property Let Title(v)
  27. m_title = v
  28. End Property
  29. '---------------------------------------------------------------
  30. ' Action: Create
  31. '---------------------------------------------------------------
  32. Public Sub Create()
  33. Dim comment
  34. Set comment = New POBO_Comments
  35. comment.PostID = FormNumberOrZero(Request.Form("PostID"))
  36. comment.AuthorName = Request.Form("AuthorName")
  37. comment.AuthorEmail = Request.Form("AuthorEmail")
  38. comment.Body = Request.Form("Body")
  39. comment.CreatedDate = Now()
  40. comment.IsApproved = 0
  41. CommentsRepository().AddNew comment
  42. Flash().Success = "Comment submitted for approval."
  43. Dim slug : slug = ResolvePostSlug(comment.PostID)
  44. If Len(slug) > 0 Then
  45. Response.Redirect PostPath(slug)
  46. Else
  47. Response.Redirect "/posts"
  48. End If
  49. End Sub
  50. '---------------------------------------------------------------
  51. ' Action: Delete
  52. '---------------------------------------------------------------
  53. Public Sub Delete(ByVal id)
  54. CommentsRepository().Delete id
  55. Flash().Success = "Comment deleted."
  56. Dim returnUrl : returnUrl = Request.ServerVariables("HTTP_REFERER")
  57. If Len(returnUrl) = 0 Then returnUrl = "/posts"
  58. Response.Redirect returnUrl
  59. End Sub
  60. Private Function FormNumberOrZero(ByVal value)
  61. If IsNumeric(value) Then
  62. FormNumberOrZero = CLng(value)
  63. Else
  64. FormNumberOrZero = 0
  65. End If
  66. End Function
  67. Private Function ResolvePostSlug(ByVal postID)
  68. Dim slug : slug = Trim(Request.Form("Slug"))
  69. If Len(slug) = 0 Then slug = Trim(Request.Form("PostSlug"))
  70. slug = NormalizeSlug(slug)
  71. If Len(slug) = 0 And CLng(postID) > 0 Then
  72. Dim post
  73. On Error Resume Next
  74. Set post = PostsRepository().FindByID(postID)
  75. If Err.Number = 0 Then slug = NormalizeSlug(post.Slug)
  76. Err.Clear
  77. On Error GoTo 0
  78. End If
  79. ResolvePostSlug = slug
  80. End Function
  81. End Class
  82. ' Singleton instance
  83. Dim CommentsController_Class__Singleton
  84. Function CommentsController()
  85. If IsEmpty(CommentsController_Class__Singleton) Then
  86. Set CommentsController_Class__Singleton = New CommentsController_Class
  87. End If
  88. Set CommentsController = CommentsController_Class__Singleton
  89. End Function
  90. %>

Powered by TurnKey Linux.