| 19 | | my $dir = $self->conf->{dir}; |
|---|
| 20 | | unless (-e $dir && -d _) { |
|---|
| 21 | | mkdir $dir, 0755 or $context->error("mkdir $dir: $!"); |
|---|
| 22 | | } |
|---|
| 23 | | |
|---|
| 24 | | my $file = $self->gen_filename($args->{feed}); |
|---|
| 25 | | my $path = File::Spec->catfile($dir, $file); |
|---|
| | 29 | my $file = $self->gen_filename($args->{feed}, $self->conf->{filename} || '%i.js'); |
|---|
| | 30 | my $path = File::Spec->catfile($self->conf->{dir}, $file); |
|---|
| | 76 | |
|---|
| | 77 | __END__ |
|---|
| | 78 | |
|---|
| | 79 | =head1 NAME |
|---|
| | 80 | |
|---|
| | 81 | Plagger::Plugin::Publish::JavaScript - publish links to entries as JavaScript |
|---|
| | 82 | |
|---|
| | 83 | =head1 SYNOPSIS |
|---|
| | 84 | |
|---|
| | 85 | - module: Publish::JavaScript |
|---|
| | 86 | config: |
|---|
| | 87 | dir: /path/to/www/js |
|---|
| | 88 | filename: %t.js |
|---|
| | 89 | |
|---|
| | 90 | =head1 DESCRIPTION |
|---|
| | 91 | |
|---|
| | 92 | This plugin publishes links to feed entries as an HTML embedable |
|---|
| | 93 | JavaScript file. The JS file contains document.write() calls, and can |
|---|
| | 94 | be easily included in any HTML page using: |
|---|
| | 95 | |
|---|
| | 96 | <script src="/path/to/file.js"></script> |
|---|
| | 97 | |
|---|
| | 98 | in any place, like Blog sidebar widgets. |
|---|
| | 99 | |
|---|
| | 100 | The HTML emitted by the JavaScript code has exactly the same structure |
|---|
| | 101 | with Movable Type's standard sidebar module, so you can easily style |
|---|
| | 102 | using CSS. |
|---|
| | 103 | |
|---|
| | 104 | =head1 CONFIG |
|---|
| | 105 | |
|---|
| | 106 | =over 4 |
|---|
| | 107 | |
|---|
| | 108 | =item dir |
|---|
| | 109 | |
|---|
| | 110 | Directory to save JS files in. |
|---|
| | 111 | |
|---|
| | 112 | =item filename |
|---|
| | 113 | |
|---|
| | 114 | Filename to be used to create JS files. It defaults to C<%i.js>, but |
|---|
| | 115 | could be configured using the following formats like strftime: |
|---|
| | 116 | |
|---|
| | 117 | =over 8 |
|---|
| | 118 | |
|---|
| | 119 | =item * %u url |
|---|
| | 120 | |
|---|
| | 121 | =item * %l link |
|---|
| | 122 | |
|---|
| | 123 | =item * %t title |
|---|
| | 124 | |
|---|
| | 125 | =item * %i id |
|---|
| | 126 | |
|---|
| | 127 | =back |
|---|
| | 128 | |
|---|
| | 129 | =back |
|---|
| | 130 | |
|---|
| | 131 | =head1 AUTHOR |
|---|
| | 132 | |
|---|
| | 133 | Tatsuhiko Miyagawa |
|---|
| | 134 | |
|---|
| | 135 | =head1 SEE ALSO |
|---|
| | 136 | |
|---|
| | 137 | L<Plagger>, L<Plagger::Plugin::Publish::MTWidget> |
|---|
| | 138 | |
|---|
| | 139 | =cut |
|---|