Skip to content
This repository was archived by the owner on Apr 7, 2024. It is now read-only.
This repository was archived by the owner on Apr 7, 2024. It is now read-only.

Adding possibility to consume events #2

@7h3Rabbit

Description

@7h3Rabbit

We want people to be able to modify the use after their own liking.
There for we will want to support the following events on the IStaticWebService.
They will be called in the order specified below.

  1. BeforeGeneratePage
    First thing happening when GeneratePage is called.
    StaticWebGeneratePageEventArg is populated with following info: ContentLink, CultureInfo.
    Resources can also be populated IF GeneratePage method is called from ScheduledJob and pages generated before had resources depending on them.
    This event can be canceled by setting CancelAction to true.

  2. BeforeGetPageContent
    Called before HTTP Request is triggered.
    StaticWebGeneratePageEventArg is populated with following info: ContentLink, CultureInfo and PageUrl.
    This event can be canceled by setting CancelAction to true.
    It can be used for example if you want to populate Content in a different way then using the default WebClient request to PageUrl.

  3. AfterGetPageContent
    Called after HTTP Request was triggered and we get our result.
    StaticWebGeneratePageEventArg is populated with following info: ContentLink, CultureInfo, PageUrl and Content. Event can be used to adjust or populate Content.
    This event can't be canceled.

  4. BeforeTryToFixLinkUrls
    Called before fixing EpiServer permanent links (As they will point to a 404 if not fixed on a static website).
    StaticWebGeneratePageEventArg is populated with following info: ContentLink, CultureInfo, PageUrl and Content.
    This event can be canceled by setting CancelAction to true.
    It can be used to prohibit fixing EpiServer permanent links if you still want them or if it is some sort of error in it.

  5. BeforeEnsurePageResources
    Called before retrieving the resources this page is dependent on.
    StaticWebGeneratePageEventArg is populated with following info: ContentLink, CultureInfo, PageUrl and Content.
    This event can be canceled by setting CancelAction to true.
    It can be used to retrieve resources in a different way then using the default WebClient behavior.

  6. AfterEnsurePageResources
    Called after retrieving the resources this page is dependent on.
    StaticWebGeneratePageEventArg is populated with following info: ContentLink, CultureInfo, PageUrl, Content and Resources.
    This event can't be canceled.

  7. BeforeGeneratePageWrite
    Called before page is written to disk.
    StaticWebGeneratePageEventArg is populated with following info: ContentLink, CultureInfo, PageUrl, Content, Resources and FilePath.
    This event can be canceled by setting CancelAction to true.

  8. AfterGeneratePageWrite
    Called after page was written to disk.
    StaticWebGeneratePageEventArg is populated with following info: ContentLink, CultureInfo, PageUrl, Content, Resources and FilePath.
    This event can't be canceled.

StaticWebGeneratePageEventArg
The StaticWebGeneratePageEventArg have the following properties:

  • ContentLink: ContentReference
    Content reference for the latest published version of the specified page.
  • CultureInfo: CultureInfo
    Language we are currently generating the page for.
  • PageUrl: string
    Absolute url for the page in question.
  • Resources: Dictionary<string, string>
    A dictionary of identified and ensured resources.
    First string in KeyValuePair is orginal resource name found.
    Seconds string in KeyValuePair the new name used when writing resource to disk (If this value is null, no changes was required to save resource).
  • FilePath: string
    This is the filepath (including filename) where the file will be written.
  • Content: string
    Html content for the page.
  • CancelAction : boolean
    For events that can be canceled, you can set this to true to tell StaticWebEpiServerPlugin to not do anything in this step.
    It is a good practice to set a cancel message when setting this to true.
  • CancelReason : string
    Tell others why the event was canceled. It is a good practice to indicate both for debugging but also if you have multiple consumers of this event.
  • Items: IDictionary
    Dictionary that allow consumers of the event to share data between each other.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions