Guest User

Untitled

a guest
Nov 21st, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. class PublicController < ApplicationController
  2. # use the ReferralSource module
  3. include ReferralSource
  4. helper_method :referral_source
  5.  
  6. def blog_post
  7. @sc.blog_post = BlogPost.find params[ :id ]
  8.  
  9. # used by the side rail
  10. @sc.offer = @sc.blog_post.corporate_client.top_performing_offer
  11. @sc.ebook = @sc.blog_post.corporate_client.top_performing_ebook
  12. @sc.email_subscriber = EmailSubscriber.new
  13.  
  14. # get the right source -- i.e. VisitPath or EngagementEngineProgression
  15. source = referral_source
  16.  
  17. # add a visit_point if a VisitPath
  18. if source.visit?
  19. bpv = BlogPostVisit
  20. .create
  21. .property( "blog_post_id", params[ :id ] )
  22. .property( "blog_post_title", @sc.blog_post.latest_version.title )
  23. source.add_visit_node( bpv )
  24. end
  25.  
  26. # add an engagement_engine_action if EngagementEngineProgression
  27. if source.eep?
  28. bpva = BlogPostVisitAction
  29. .create
  30. .property( "blog_post_id", params[ :id ] )
  31. .property( "blog_post_title", @sc.blog_post.latest_version.title )
  32. source.add_visit_node( bpva )
  33. end
  34.  
  35. @sc.source = source.source_type
  36. @sc.source_id = source.source_id
  37. end
  38.  
  39.  
  40. def blog_post_index
  41. @sc.source = source
  42. @sc.blog_posts = BlogPost.approved( params[ :id ] )
  43. end
  44.  
  45.  
  46. def ebook_landing_page
  47.  
  48. @sc.ebook = Ebook.find_by_id params[ :id ]
  49. @sc.prospect_info = ProspectInfo.new
  50.  
  51. source = referral_source
  52.  
  53. if source.visit?
  54. eblpv = EbookLandingPageVisit
  55. .create
  56. .property( 'ebook_title', @sc.ebook.name)
  57. .property( 'ebook_id', @sc.ebook.id )
  58. source.add_visit_node( eblpv )
  59. end
  60.  
  61. if source.eep?
  62. eblpva = EbookLandingPageVisitAction
  63. .create
  64. .property( 'ebook_title', @sc.ebook.name )
  65. .property( 'ebook_id', @sc.ebook.id )
  66. source.add_visit_node( eblvpa )
  67. end
  68.  
  69. @sc.source = source.source_type
  70. @sc.source_id = source.source_id
  71. end
  72.  
  73.  
  74. def ebook_landing_page_submitted
  75. # create the engagement engine progression with the prospect info
  76. eep = EngagementEngineProgression.create( prospect_info: ProspectInfo.create( params[ :prospect_info ] ) )
  77.  
  78. # add the VisitPath if one exists( most likely )
  79. if params[ :source ] == "VisitPath"
  80. visit_path = VisitPath.find_by_id( params[ :source_id ] )
  81. eep.update_attributes( visit_path: visit_path )
  82. end
  83.  
  84. # Add the landing page submitted
  85. eep.add_engagement_engine_action( EbookLandingPageSubmitted.create.property( "ebook_id", params[ :id ] ) )
  86. end
  87.  
  88.  
  89. def get_ebook
  90. # find the appropriate eep
  91. eep = EngagementEngineProgression.find_by_id( params[ :id ] )
  92. # find the appropriate ebook
  93. ebook = Ebook.find( eep.get_action( 'EbookLandingPageSubmitted' ).property( 'ebook_id' ) )
  94. # keep track of the ebook link being clicked
  95. eep.add_engagement_engine_action( EbookLinkClicked.create.property( "ebook_id", ebook.id ) )
  96. # present the ebook for prospect to save
  97. send_file "#{ ebook.pdf_asset_path }", :stream => true, :type => "application/pdf", :disposition => "attachment"
  98. end
  99.  
  100.  
  101. def get_offer
  102. # find the appropriate eep
  103. @sc.eep = EngagementEngineProgression.find_by_id( params[ :id ] )
  104. @sc.pitch_email = eep.get_action( 'SendOfferPitchEmail' )
  105. @sc.offer = Offer.find( pitch_email.id )
  106. @sc.landing_page_blueprint = @sc.offer.landing_page_blueprint
  107. @sc.prospect_form_blueprint = @sc.landing_page_blueprint.prospect_form_blueprint3
  108. end
  109.  
  110.  
  111. def source
  112. params[ :controller ]
  113. end
  114. end
Add Comment
Please, Sign In to add comment