-
Notifications
You must be signed in to change notification settings - Fork 0
Adding possibility to consume events #2
Description
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.
-
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 settingCancelAction
totrue
. -
BeforeGetPageContent
Called before HTTP Request is triggered.
StaticWebGeneratePageEventArg is populated with following info:ContentLink
,CultureInfo
andPageUrl
.
This event can be canceled by settingCancelAction
totrue
.
It can be used for example if you want to populateContent
in a different way then using the default WebClient request toPageUrl
. -
AfterGetPageContent
Called after HTTP Request was triggered and we get our result.
StaticWebGeneratePageEventArg is populated with following info:ContentLink
,CultureInfo
,PageUrl
andContent
. Event can be used to adjust or populateContent
.
This event can't be canceled. -
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
andContent
.
This event can be canceled by settingCancelAction
totrue
.
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. -
BeforeEnsurePageResources
Called before retrieving the resources this page is dependent on.
StaticWebGeneratePageEventArg is populated with following info:ContentLink
,CultureInfo
,PageUrl
andContent
.
This event can be canceled by settingCancelAction
totrue
.
It can be used to retrieve resources in a different way then using the default WebClient behavior. -
AfterEnsurePageResources
Called after retrieving the resources this page is dependent on.
StaticWebGeneratePageEventArg is populated with following info:ContentLink
,CultureInfo
,PageUrl
,Content
andResources
.
This event can't be canceled. -
BeforeGeneratePageWrite
Called before page is written to disk.
StaticWebGeneratePageEventArg is populated with following info:ContentLink
,CultureInfo
,PageUrl
,Content
,Resources
andFilePath
.
This event can be canceled by settingCancelAction
totrue
. -
AfterGeneratePageWrite
Called after page was written to disk.
StaticWebGeneratePageEventArg is populated with following info:ContentLink
,CultureInfo
,PageUrl
,Content
,Resources
andFilePath
.
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.