ASP Classic blog framework - BrainOrdure
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

109 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 "/posts/" & Server.URLEncode(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. If Len(slug) = 0 And CLng(postID) > 0 Then
  71. Dim post
  72. On Error Resume Next
  73. Set post = PostsRepository().FindByID(postID)
  74. If Err.Number = 0 Then slug = CStr(post.Slug)
  75. Err.Clear
  76. On Error GoTo 0
  77. End If
  78. ResolvePostSlug = slug
  79. End Function
  80. End Class
  81. ' Singleton instance
  82. Dim CommentsController_Class__Singleton
  83. Function CommentsController()
  84. If IsEmpty(CommentsController_Class__Singleton) Then
  85. Set CommentsController_Class__Singleton = New CommentsController_Class
  86. End If
  87. Set CommentsController = CommentsController_Class__Singleton
  88. End Function
  89. %>

Powered by TurnKey Linux.