Changeset 975
- Timestamp:
- 08/20/08 17:18:34 (3 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ActionStreams/plugins/ActionStreams/doc/recipe-guide.txt
r903 r975 1 1 # Action Streams Recipe Developer Guide # 2 2 3 The Action Streams plugin collects authors' actions performed in remote services. Plugin developers can add support to Action Streams for new web services, often with no Perl code required at all. 3 The Action Streams plugin collects authors' actions performed in remote 4 services. Plugin developers can add support to Action Streams for new web 5 services, often with no Perl code required at all. 4 6 5 7 ## Making a plugin with the registry ## 6 8 7 In Movable Type 4, plugins are defined using a file called `config.yaml` instead of Perl code. When Movable Type loads the plugin, the settings the plugin defines in `config.yaml` are integrated into what's called *the registry*. The registry is a tree of settings that informs Movable Type what settings, pages, and objects are available. 8 9 To define your plugin, make a new directory in the `plugins` directory. Inside it, create a file called `config.yaml`, and enter all the basic plugin settings. For example: 9 In Movable Type 4, plugins are defined using a file called `config.yaml` 10 instead of Perl code. When Movable Type loads the plugin, the settings the 11 plugin defines in `config.yaml` are integrated into what's called *the 12 registry*. The registry is a tree of settings that informs Movable Type what 13 settings, pages, and objects are available. 14 15 To define your plugin, make a new directory in the `plugins` directory. Inside 16 it, create a file called `config.yaml`, and enter all the basic plugin 17 settings. For example: 10 18 11 19 id: ExampleService … … 18 26 plugin_link: http://www.example.com/plugins/example-service/ 19 27 20 These settings define a plugin called "Example Service" with all the specified settings. Consult the Movable Type developer documentation for further help on creating plugins. 28 These settings define a plugin called "Example Service" with all the specified 29 settings. Consult the Movable Type developer documentation for further help on 30 creating plugins. 21 31 22 32 ## Defining a profile service ## 23 33 24 Every action and stream belongs to a **service**, so unless you're adding a stream for a service that already exists in Action Streams, you need to define one of those first. Usually a service is a web site at which an author has an account. Authors can use the Action Streams plugin to make a sidebar list of their accounts on all the services for which they enter their accounts. 25 26 Profile services are defined in the `profile_services` section of the registry. Because Movable Type merges your `config.yaml` into the registry, you specify additional services by adding your own `profile_services` section to your plugin's `config.yaml`. For example: 34 Every action and stream belongs to a **service**, so unless you're adding a 35 stream for a service that already exists in Action Streams, you need to define 36 one of those first. Usually a service is a web site at which an author has an 37 account. Authors can use the Action Streams plugin to make a sidebar list of 38 their accounts on all the services for which they enter their accounts. 39 40 Profile services are defined in the `profile_services` section of the 41 registry. Because Movable Type merges your `config.yaml` into the registry, 42 you specify additional services by adding your own `profile_services` section 43 to your plugin's `config.yaml`. For example: 27 44 28 45 profile_services: … … 39 56 icon: example.png 40 57 41 This defines two services. Each service has its own key by which it's known in the registry. These services' keys are `example` and `complex`. The data you can set for a service are: 58 This defines two services. Each service has its own key by which it's known in 59 the registry. These services' keys are `example` and `complex`. The data you 60 can set for a service are: 42 61 43 62 ### `name` (required) ### 44 63 45 The human-readable name of the service. This name is used for display and for ordering the list of services. 64 The human-readable name of the service. This name is used for display and for 65 ordering the list of services. 46 66 47 67 ### `url` (required) ### 48 68 49 The URL to a user's profile on the service. This is the URL used in the author's list of services. 50 51 The string `{{ident}}` will be replaced by the author's identifier for this service. Only one identifier per service is currently supported. 69 The URL to a user's profile on the service. This is the URL used in the 70 author's list of services. 71 72 The string `{{ident}}` will be replaced by the author's identifier for this 73 service. Only one identifier per service is currently supported. 52 74 53 75 ### `ident_label` ### 54 76 55 A label to describe what the author's identifier on the service is. If not given, the label `Username` is used. For example, if the user identifier on the service is a number, you might specify `User ID` here to indicate the author should enter a number. For the AIM service, the label is `Screen name`. 77 A label to describe what the author's identifier on the service is. If not 78 given, the label `Username` is used. For example, if the user identifier on 79 the service is a number, you might specify `User ID` here to indicate the 80 author should enter a number. For the AIM service, the label is `Screen name`. 56 81 57 82 ### `ident_example` ### 58 83 59 A label to show what the identifiers for the service generally look like. For example, if the user identifier is a number, you might specify `12345`. For the Flickr service, the example identifier is `36381329@N00`. 84 A label to show what the identifiers for the service generally look like. For 85 example, if the user identifier is a number, you might specify `12345`. For 86 the Flickr service, the example identifier is `36381329@N00`. 60 87 61 88 ### `ident_suffix` ### 62 89 63 A label to show after the field in which the identifier is entered. Typically this is used to further suggest that the one's subdomain on a service is one's identifier. For example, the Vox service's suffix is `.vox.com`. 90 A label to show after the field in which the identifier is entered. Typically 91 this is used to further suggest that the one's subdomain on a service is one's 92 identifier. For example, the Vox service's suffix is `.vox.com`. 64 93 65 94 ### `service_type` ### 66 95 67 The kind of web service this profile is about. Authors can list their accounts for a certain type of services using the `type` attribute of the `OtherProfiles` tag. Any value is allowed here, but the established service types are: 96 The kind of web service this profile is about. Authors can list their accounts 97 for a certain type of services using the `type` attribute of the 98 `OtherProfiles` tag. Any value is allowed here, but the established service 99 types are: 68 100 69 101 * `contact` (AIM, Yahoo! Messenger, etc) … … 77 109 ### `icon` ### 78 110 79 The location of the service's icon. This can be a complete URL to the image. If not a URL, `icon` should be a path to the image relative to your plugin's `mt-static` directory. For example, if you install your `example.png` at `mt-static/plugins/ExampleService/example.png`, your `icon` setting should be `example.png`. 111 The location of the service's icon. This can be a complete URL to the image. 112 If not a URL, `icon` should be a path to the image relative to your plugin's 113 `mt-static` directory. For example, if you install your `example.png` at 114 `mt-static/plugins/ExampleService/example.png`, your `icon` setting should be 115 `example.png`. 80 116 81 117 ## Defining stream recipes for a service ## 82 118 83 Once a service is defined in `profile_services`, you can make recipes for collecting its action streams. These recipes go in the `action_streams` section of the registry. For example: 119 Once a service is defined in `profile_services`, you can make recipes for 120 collecting its action streams. These recipes go in the `action_streams` 121 section of the registry. For example: 84 122 85 123 action_streams: … … 96 134 thumbnail: media:thumbnail/child::text() 97 135 98 Each service has its own section, labelled with the same key as in the `profile_services` section. Inside that, you can define one or more recipes for how to collect actions. As you can see, recipes have three parts: 136 Each service has its own section, labelled with the same key as in the 137 `profile_services` section. Inside that, you can define one or more recipes 138 for how to collect actions. As you can see, recipes have three parts: 99 139 100 140 * **URLs** that indicate where to find action content. 101 * **Collectors** that specify how to turn the resource at the stream's URL into action data. Action data is primarily a title, a link, and a unique identifier for each action, but you can specify additional data fields in your recipe. 102 * **Forms** that describe how to turn the action data back into HTML. Authors can display however they like with template code, but in the application and by default, actions in this stream will display as you specify in the recipe. 141 * **Collectors** that specify how to turn the resource at the stream's URL 142 into action data. Action data is primarily a title, a link, and a unique 143 identifier for each action, but you can specify additional data fields in 144 your recipe. 145 * **Forms** that describe how to turn the action data back into HTML. Authors 146 can display however they like with template code, but in the application and 147 by default, actions in this stream will display as you specify in the 148 recipe. 103 149 104 150 Together, these parts define the recipe. … … 106 152 ### Picking a stream ID ### 107 153 108 The word you use as the registry key when defining a stream is its ID. While you can use any term here, if the stream you're defining is analogous to a stream available from another service, use the same ID as the other service's stream does. 109 110 Template authors can list similar actions across services by using the `stream` attribute on the `ActionStreams` tag in absence of the `service` attribute. The value template authors will use with `stream` will be this ID, so in order for your (say) photos stream to be included when a user lists all posted photos across all services, use `photos` for your stream ID. 154 The word you use as the registry key when defining a stream is its ID. While 155 you can use any term here, if the stream you're defining is analogous to a 156 stream available from another service, use the same ID as the other service's 157 stream does. 158 159 Template authors can list similar actions across services by using the 160 `stream` attribute on the `ActionStreams` tag in absence of the `service` 161 attribute. The value template authors will use with `stream` will be this ID, 162 so in order for your (say) photos stream to be included when a user lists all 163 posted photos across all services, use `photos` for your stream ID. 111 164 112 165 Some of the standard stream IDs used in the standard provided streams are: 113 166 114 * `links`, web pages or resources that have been bookmarked (as in del.icio.us, Digg, Magnolia) 115 * `photos`, photos posted by the author (as in Flickr, Picasa on the Web, Smugmug) 116 * `favorites`, assets and objects of others' that the author saved as a favorite (as in Vox, Twitter, YouTube) 167 * `links`, web pages or resources that have been bookmarked (as in 168 del.icio.us, Digg, Magnolia) 169 * `photos`, photos posted by the author (as in Flickr, Picasa on the Web, 170 Smugmug) 171 * `favorites`, assets and objects of others' that the author saved as a 172 favorite (as in Vox, Twitter, YouTube) 117 173 * `achievements`, awards won by the author (as in Steam or Kongregate) 118 174 * `videos`, videos posted by the author (as in Viddler, Vimeo, YouTube) … … 120 176 ### Picking the stream resource ### 121 177 122 Typically, modern web services will provide a web feed or XML resource for their members that rolls up their recent activity on the site. Sometimes a service only provides an HTML page, but Action Streams can work with them too. This is the resource you will specify as your stream's `url`. 123 124 The URL for the resource needs to include the user's identifier in the URL. In some extreme cases, you may even have to change what identifier your profile service uses in order to get the stream resource. Normally the same user name or ID is in the URL, though. 178 Typically, modern web services will provide a web feed or XML resource for 179 their members that rolls up their recent activity on the site. Sometimes a 180 service only provides an HTML page, but Action Streams can work with them too. 181 This is the resource you will specify as your stream's `url`. 182 183 The URL for the resource needs to include the user's identifier in the URL. In 184 some extreme cases, you may even have to change what identifier your profile 185 service uses in order to get the stream resource. Normally the same user name 186 or ID is in the URL, though. 125 187 126 188 ### Three schools of collection ### 127 189 128 Most services don't yet publish their members' actions as such, so even if you can collect from a nice standard web feed, the feed content will need some massaging. There are three main kinds of collectors at your disposal: XML feeds, HTML scrapers, and custom collectors. 190 Most services don't yet publish their members' actions as such, so even if you 191 can collect from a nice standard web feed, the feed content will need some 192 massaging. There are three main kinds of collectors at your disposal: XML 193 feeds, HTML scrapers, and custom collectors. 129 194 130 195 #### XML feeds #### 131 196 132 It's easy to collect data from XML feeds. Action Streams accepts recipes using XPath syntax. For example, you might collect data from del.icio.us' RSS feeds with an `xpath` recipe: 197 It's easy to collect data from XML feeds. Action Streams accepts recipes using 198 XPath syntax. For example, you might collect data from del.icio.us' RSS feeds 199 with an `xpath` recipe: 133 200 134 201 delicious: … … 146 213 url: link/child::text() 147 214 148 This specifies that each item in the feed is an XPath `//item`, meaning an `item` tag anywhere in the document. Within each `item`, you can find values for the `created_on`, `title`, and `url` fields using the given XPath selectors. The `identifier: url` statement indicates to use the `url` value as the action's unique identifier. 149 150 As many services provide as standard web feeds, it's actually even easier to collect from those. Instead of `xpath`, specify your recipe as `rss` or `atom`, with any additional or special fields as additional XPath selectors: 215 This specifies that each item in the feed is an XPath `//item`, meaning an 216 `item` tag anywhere in the document. Within each `item`, you can find values 217 for the `created_on`, `title`, and `url` fields using the given XPath 218 selectors. The `identifier: url` statement indicates to use the `url` value as 219 the action's unique identifier. 220 221 As many services provide as standard web feeds, it's actually even easier to 222 collect from those. Instead of `xpath`, specify your recipe as `rss` or 223 `atom`, with any additional or special fields as additional XPath selectors: 151 224 152 225 delicious: … … 160 233 created_on: dc:date/child::text() 161 234 162 If there are no special fields to collect, you can also specify the recipe as simply `1`, as in this recipe for Jaiku: 235 If there are no special fields to collect, you can also specify the recipe as 236 simply `1`, as in this recipe for Jaiku: 163 237 164 238 jaiku: … … 170 244 atom: 1 171 245 172 The values of each entry's ID field (`guid` in RSS and `id` in Atom) are then used for actions' identifiers. 246 The values of each entry's ID field (`guid` in RSS and `id` in Atom) are then 247 used for actions' identifiers. 173 248 174 249 #### HTML pages #### 175 250 176 When feeds aren't available, HTML will do. Action Streams reads HTML pages using Web::Scraper, an HTML scraping library inspired by the Ruby scrapi library. For example, the Iwtst plugin reads your iwanttoseethat.com profile page with this definition: 251 When feeds aren't available, HTML will do. Action Streams reads HTML pages 252 using Web::Scraper, an HTML scraping library inspired by the Ruby scrapi 253 library. For example, the Iwtst plugin reads your iwanttoseethat.com profile 254 page with this definition: 177 255 178 256 iwtst: … … 193 271 - TEXT 194 272 195 Instead of XPath, here we can use CSS selector syntax. (For more complex constructions, you can use XPath selectors as well.) This recipe says each action is a `div` with class `seethat_yes` inside a `seethat` `div`. The action's `url` field is then the value of the `href` attribute of the `a` tag inside, while the `title` field is the text linked inside that `a` tag. 273 Instead of XPath, here we can use CSS selector syntax. (For more complex 274 constructions, you can use XPath selectors as well.) This recipe says each 275 action is a `div` with class `seethat_yes` inside a `seethat` `div`. The 276 action's `url` field is then the value of the `href` attribute of the `a` tag 277 inside, while the `title` field is the text linked inside that `a` tag. 196 278 197 279 #### Custom collectors #### 198 280 199 If you aren't pulling web data, or you can't quite articulate as a set of selectors, you can implement your own action collector as a Perl class. You then tell what class implements your stream: 281 If you aren't pulling web data, or you can't quite articulate as a set of 282 selectors, you can implement your own action collector as a Perl class. You 283 then tell what class implements your stream: 200 284 201 285 complex: … … 206 290 class: Example::Event::ComplexPosts 207 291 208 Your class then subclasses the plugin's `ActionStreams::Event` class, and implements your particular content-finding behavior. As the XML and HTML recipes are really the default behavior of an `ActionStreams::Event` object, the above techniques are easily accessible from your class too. See some of the `ActionStreams::Event` subclasses included with the Action Streams plugin for examples. 292 Your class then subclasses the plugin's `ActionStreams::Event` class, and 293 implements your particular content-finding behavior. As the XML and HTML 294 recipes are really the default behavior of an `ActionStreams::Event` object, 295 the above techniques are easily accessible from your class too. See some of 296 the `ActionStreams::Event` subclasses included with the Action Streams plugin 297 for examples. 209 298 210 299 ### Formatting actions for display ### 211 300 212 While bloggers can customize how actions are published to the blog however they wish with the provided template tags, the recipe defines how actions are displayed when using the `mt:StreamAction` tag and when displayed in the application. This display is governed by the `html_form` and `html_params` options, as in the del.icio.us recipe: 301 While bloggers can customize how actions are published to the blog however 302 they wish with the provided template tags, the recipe defines how actions are 303 displayed when using the `mt:StreamAction` tag and when displayed in the 304 application. This display is governed by the `html_form` and `html_params` 305 options, as in the del.icio.us recipe: 213 306 214 307 delicious: … … 222 315 # ... 223 316 224 The `html_form` setting is a pattern in maketext format, making it easy to . Each replacement token is numbered. The first replacement token, `[_1]`, is always the name of the MT user whose action is being displayed. The next tokens represent the fields you specify in (in this case, `url` and `title`). 225 226 Note that the result of formatting an action is, in fact, HTML. This markup will be returned verbatim when used with the `mt:StreamAction` tag. For display in the Movable Type application, the HTML is removed; del.icio.us links are the text "*Author name* saved the link *title*" without the hyperlink, for example. 317 The `html_form` setting is a pattern in maketext format, making it easy to . 318 Each replacement token is numbered. The first replacement token, `[_1]`, is 319 always the name of the MT user whose action is being displayed. The next 320 tokens represent the fields you specify in (in this case, `url` and `title`). 321 322 Note that the result of formatting an action is, in fact, HTML. This markup 323 will be returned verbatim when used with the `mt:StreamAction` tag. For 324 display in the Movable Type application, the HTML is removed; del.icio.us 325 links are the text "*Author name* saved the link *title*" without the 326 hyperlink, for example. 227 327 228 328 ### Cleaning up after your stream ### 229 329 230 Some streams may not leave in the correct displayable format. For example, the regular Twitter tweet feeds include the authors' usernames with the tweets. The Twitter stream needs to remove to correctly collect only the tweet text. How can it remove the usernames from the collected actions? 231 232 Movable Type provides a system for defining *callbacks*, or code hooks that are run at certain points of a process. The Action Streams plugin provides several callbacks at various stages of stream event collection. You will have to use Perl code to write these callbacks, but as you're doing very small things, the code is usually simple. 233 234 For example, the Twitter stream uses the `pre_build_action_streams_event` callback to modify the actions after they're collected by the normal feed collector, but before they are saved. The callback is defined in the registry thus: 330 Some streams may not leave in the correct displayable format. For example, the 331 regular Twitter tweet feeds include the authors' usernames with the tweets. 332 The Twitter stream needs to remove to correctly collect only the tweet text. 333 How can it remove the usernames from the collected actions? 334 335 Movable Type provides a system for defining *callbacks*, or code hooks that 336 are run at certain points of a process. The Action Streams plugin provides 337 several callbacks at various stages of stream event collection. You will have 338 to use Perl code to write these callbacks, but as you're doing very small 339 things, the code is usually simple. 340 341 For example, the Twitter stream uses the `pre_build_action_streams_event` 342 callback to modify the actions after they're collected by the normal feed 343 collector, but before they are saved. The callback is defined in the registry 344 thus: 235 345 236 346 callbacks: … … 252 362 } 253 363 254 The Action Streams callbacks available to you are documented later. See the Movable Type developer documentation for more about defining callbacks. 364 The Action Streams callbacks available to you are documented later. See the 365 Movable Type developer documentation for more about defining callbacks. 255 366 256 367 ## Stream recipe option reference ## 257 368 258 Recipes describe how to collect and display users' actions on profile services. They are found in the `action_streams` section of the registry, in sections named the same as the related service in the `profile_services` section. 369 Recipes describe how to collect and display users' actions on profile 370 services. They are found in the `action_streams` section of the registry, in 371 sections named the same as the related service in the `profile_services` 372 section. 259 373 260 374 The options you can set for action streams are: … … 262 376 ### `name` (required) ### 263 377 264 The name of the action stream. This is displayed to authors when they enter their profile service identifier, where they are given the option of collecting the stream. 378 The name of the action stream. This is displayed to authors when they enter 379 their profile service identifier, where they are given the option of 380 collecting the stream. 265 381 266 382 ### `description` (required) ### 267 383 268 The description of the action stream. This is displayed to authors with the stream's name when they enter profile identifiers. 384 The description of the action stream. This is displayed to authors with the 385 stream's name when they enter profile identifiers. 269 386 270 387 ### `fields` ### … … 272 389 The list of additional fields supported by actions of this stream. 273 390 274 Every stream already has a set of standard fields. You need only specify additional fields beyond these. The standard fields are: 391 Every stream already has a set of standard fields. You need only specify 392 additional fields beyond these. The standard fields are: 275 393 276 394 #### `title` #### … … 284 402 #### `thumbnail` #### 285 403 286 The web address (URL) of a thumbnail image of the page/asset/resource the action is about. 404 The web address (URL) of a thumbnail image of the page/asset/resource the 405 action is about. 287 406 288 407 #### `identifier` #### … … 292 411 #### `created_on` #### 293 412 294 When the action was taken. This is *not* necessarily when the page/asset/resource the action is about was created; when a link is saved or a video is favorited, for example. 413 When the action was taken. This is *not* necessarily when the 414 page/asset/resource the action is about was created; when a link is saved or a 415 video is favorited, for example. 295 416 296 417 #### `modified_on` #### 297 418 298 When the action was last altered. Many actions occur only once and will never change, but some may (such as if the author changes the rating or tags for a saved link). Action Streams will update this timestamp automatically when the action object is changed. 419 When the action was last altered. Many actions occur only once and will never 420 change, but some may (such as if the author changes the rating or tags for a 421 saved link). Action Streams will update this timestamp automatically when the 422 action object is changed. 299 423 300 424 ### `html_form` ### 301 425 302 The formatting string for formatting an action for display. Numbered replacement tokens are replaced with the author's name and the values of the fields named in `html_params`. 426 The formatting string for formatting an action for display. Numbered 427 replacement tokens are replaced with the author's name and the values of the 428 fields named in `html_params`. 303 429 304 430 ### `html_params` ### 305 431 306 The list of additional fields to replace into `html_form` when displaying an action. 432 The list of additional fields to replace into `html_form` when displaying an 433 action. 307 434 308 435 ### `url` ### 309 436 310 The URL from which to collect action data. The token `{{ident}}` will be replaced with the author's identifier on that service. 437 The URL from which to collect action data. The token `{{ident}}` will be 438 replaced with the author's identifier on that service. 311 439 312 440 ### `identifier` ### 313 441 314 The name of the field to use as the unique identifier. Multiple fields can be specified by separating their names with commas (for example: `title,created_on`). 315 316 If not given, the collection recipe should collect an `identifier` field from the action source. If an `identifier` field is not collected, each action will be considered unique, regardless of the content of the other fields. 442 The name of the field to use as the unique identifier. Multiple fields can be 443 specified by separating their names with commas (for example: 444 `title,created_on`). 445 446 If not given, the collection recipe should collect an `identifier` field from 447 the action source. If an `identifier` field is not collected, each action will 448 be considered unique, regardless of the content of the other fields. 317 449 318 450 ### `xpath` ### 319 451 320 The XPath recipe with which to collect action data. The recipe options for an XPath recipe are: 452 The XPath recipe with which to collect action data. The recipe options for an 453 XPath recipe are: 321 454 322 455 #### `foreach` (required) #### 323 456 324 The XPath selector that selects the nodes of the resource document that represent actions. All the `get` selectors are then applied to each node to find the action data. 457 The XPath selector that selects the nodes of the resource document that 458 represent actions. All the `get` selectors are then applied to each node to 459 find the action data. 325 460 326 461 #### `get` (required) #### 327 462 328 A set of XPath selectors, keyed on the names of the action fields they describe. To find the value of each field, the indicated selector is applied to each node as determined by the `foreach` selector. 463 A set of XPath selectors, keyed on the names of the action fields they 464 describe. To find the value of each field, the indicated selector is applied 465 to each node as determined by the `foreach` selector. 329 466 330 467 ### `rss` ### 331 468 332 The RSS recipe with which to collect action data. RSS recipes collect data from the standard RSS entry content. If child options are specified, each is used as an XPath selector (as in an `xpath` recipe's `get` option) to collect a field from the RSS `item` nodes. 469 The RSS recipe with which to collect action data. RSS recipes collect data 470 from the standard RSS entry content. If child options are specified, each is 471 used as an XPath selector (as in an `xpath` recipe's `get` option) to collect 472 a field from the RSS `item` nodes. 333 473 334 474 ### `atom` ### 335 475 336 The Atom recipe with which to collect action data. Atom recipes collect data from the standard Atom feed content. If child options are specified, each is used as an XPath selector (as in an `xpath` recipe's `get` option) to collect a field from the Atom `entry` nodes. 476 The Atom recipe with which to collect action data. Atom recipes collect data 477 from the standard Atom feed content. If child options are specified, each is 478 used as an XPath selector (as in an `xpath` recipe's `get` option) to collect 479 a field from the Atom `entry` nodes. 337 480 338 481 ### `scraper` ### 339 482 340 The Web::Scraper recipe with which to collect action data. The options for a Web::Scraper recipe are: 483 The Web::Scraper recipe with which to collect action data. The options for a 484 Web::Scraper recipe are: 341 485 342 486 #### `foreach` (required) #### 343 487 344 The CSS or XPath selector that selects the nodes of the resource document that represent the actions. All the `get` selectors are then applied to each node to find the action data. 488 The CSS or XPath selector that selects the nodes of the resource document that 489 represent the actions. All the `get` selectors are then applied to each node 490 to find the action data. 345 491 346 492 #### `get` (required) #### 347 493 348 A set of Web::Scraper selectors, keyed on the names of the action fields they describe. Each selector is applied to each action node, as determined by the `foreach` selector, to find the action data. 494 A set of Web::Scraper selectors, keyed on the names of the action fields they 495 describe. Each selector is applied to each action node, as determined by the 496 `foreach` selector, to find the action data. 349 497 350 498 Each Web::Scraper selector is a two-element list: 351 499 352 500 * The CSS or XPath selector to use to find a child node. 353 * `@`*`attribute`* or `TEXT` to select an attribute value or the text content of the node. 501 * `@`*`attribute`* or `TEXT` to select an attribute value or the text content 502 of the node. 354 503 355 504 ### `class` ### 356 505 357 The name of the Perl package to use to represent actions in this stream. The Perl package should be a subclass of `ActionStreams::Event`. See the `ActionStreams::Event` perldoc for information on defining an action stream in Perl code. 506 The name of the Perl package to use to represent actions in this stream. The 507 Perl package should be a subclass of `ActionStreams::Event`. See the 508 `ActionStreams::Event` perldoc for information on defining an action stream in 509 Perl code. 358 510 359 511 ## Stream recipe callback reference ## 360 512 361 Action Streams specifies several callbacks for you to customize the creation of your action streams and the collection of their events. 362 363 Note that Movable Type's standard object callbacks are also available for the `ActionStreams::Event` objects representing actions. 513 Action Streams specifies several callbacks for you to customize the creation 514 of your action streams and the collection of their events. 515 516 Note that Movable Type's standard object callbacks are also available for the 517 `ActionStreams::Event` objects representing actions. 364 518 365 519 ### `pre_add_profile.`*`type`* ### 366 520 367 Fires before an author's new profile is added. `type` is the ID (registry key) of the service being added. The parameters passed to your callback routine are: 521 Fires before an author's new profile is added. `type` is the ID (registry key) 522 of the service being added. The parameters passed to your callback routine 523 are: 368 524 369 525 * `$app`, the current MT::App through which the profile is being added 370 526 * `$user`, the MT::Author whose profile is being added 371 * `$profile`, a hashref containing the information about the profile being added: 527 * `$profile`, a hashref containing the information about the profile being 528 added: 372 529 * `type`, the ID of the profile service 373 530 * `ident`, the user ID on the remote service 374 531 * `label`, a user-facing description of the profile 375 532 * `uri`, the URL of the profile page 376 * `streams`, a hashref with keys that are the stream IDs of the streams the author has selected to collect; all values are set to `1` 533 * `streams`, a hashref with keys that are the stream IDs of the streams the 534 author has selected to collect; all values are set to `1` 377 535 378 536 ### `post_add_profile.`*`type`* ### 379 537 380 Fires after an author's new profile is added. The same parameters are passed to your callback routine as to a `pre_add_profile` routine. 538 Fires after an author's new profile is added. The same parameters are passed 539 to your callback routine as to a `pre_add_profile` routine. 381 540 382 541 ### `pre_remove_profile.`*`type`* ### 383 542 384 Fires before a profile is removed. The parameters passed to your callback routine are: 543 Fires before a profile is removed. The parameters passed to your callback 544 routine are: 385 545 386 546 * `$app`, the current MT::App through which the profile is being removed … … 391 551 ### `post_remove_profile.`*`type`* ### 392 552 393 Fires after a profile is removed. The parameters passed to your callback are the same as to a `pre_remove_profile` callback. 553 Fires after a profile is removed. The parameters passed to your callback are 554 the same as to a `pre_remove_profile` callback. 394 555 395 556 ### `pre_action_streams_task` ### 396 557 397 Fires before the scheduled task to collect stream events is performed. The parameters to your callback routine are: 398 399 * `$mt`, the current MT instance through which the stream events will be collected 558 Fires before the scheduled task to collect stream events is performed. The 559 parameters to your callback routine are: 560 561 * `$mt`, the current MT instance through which the stream events will be 562 collected 400 563 401 564 ### `post_action_streams_task` ### 402 565 403 Fires after the scheduled task to collect stream events is completed. The parameters to your callback are the same as for `pre_action_streams_task`. 566 Fires after the scheduled task to collect stream events is completed. The 567 parameters to your callback are the same as for `pre_action_streams_task`. 404 568 405 569 ### `pre_update_action_streams_profile.`*`type`* ### 406 570 407 Fires before the streams for a particular author's profile are collected. For example, this callback fires once before an author's Twitter streams (both the tweets and favorites streams) are collected. The parameters passed to your callback routine are: 408 409 * `$mt`, the current MT instance through which the stream events will be collected 571 Fires before the streams for a particular author's profile are collected. For 572 example, this callback fires once before an author's Twitter streams (both the 573 tweets and favorites streams) are collected. The parameters passed to your 574 callback routine are: 575 576 * `$mt`, the current MT instance through which the stream events will be 577 collected 410 578 * `$author`, the MT::Author whose streams are being collected 411 * `$profile`, a hashref containing all the information about the profile; this is the same as the `$profile` argument to the `pre_add_profile` callback 579 * `$profile`, a hashref containing all the information about the profile; this 580 is the same as the `$profile` argument to the `pre_add_profile` callback 412 581 413 582 ### `post_update_action_streams_profile.`*`type`* ### 414 583 415 Fires after the streams for a particular author's profile are collected. The parameters passed to your callback routine are the same as to `pre_update_action_streams_profile`. 584 Fires after the streams for a particular author's profile are collected. The 585 parameters passed to your callback routine are the same as to 586 `pre_update_action_streams_profile`. 416 587 417 588 ### `pre_build_action_streams_event.`*`type`* ### 418 589 419 Fires after a stream event is collected, but before it's put into the `ActionStreams::Event` object. The parameters given to your callback routine are: 590 Fires after a stream event is collected, but before it's put into the 591 `ActionStreams::Event` object. The parameters given to your callback routine 592 are: 420 593 421 594 * `$mt`, the current MT instance through which the stream event was collected 422 595 * `$item`, a hashref containing the data collected for this event 423 * `$event`, the `ActionStreams::Event` into which the event data will put; this is either a new empty `ActionStreams::Event`, or the previously version of this event as determined by the value of the stream recipe's identifier field 596 * `$event`, the `ActionStreams::Event` into which the event data will put; 597 this is either a new empty `ActionStreams::Event`, or the previously version 598 of this event as determined by the value of the stream recipe's identifier 599 field 424 600 * `$author`, the MT::Author whose stream is being collected 425 * `$profile`, a hashref containing all the information about the profile; this is the same as the `$profile` argument to the `pre_add_profile` callback 601 * `$profile`, a hashref containing all the information about the profile; this 602 is the same as the `$profile` argument to the `pre_add_profile` callback 426 603 427 604 ### `post_build_action_streams_event.`*`type`* ### 428 605 429 Fires after a stream event is composed, but before it is saved. The parameters passed to your callback routine are the same as to `pre_build_action_streams_event`. 606 Fires after a stream event is composed, but before it is saved. The parameters 607 passed to your callback routine are the same as to 608 `pre_build_action_streams_event`. 609
