line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Riotjs; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mojolicious::Plugin::Riotjs - A Mojolicious plugin for including riot.js .tag files in your project |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
0.04 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
L is a L plugin for including |
14
|
|
|
|
|
|
|
L C<.tag> files in your project. It also |
15
|
|
|
|
|
|
|
makes it very easy to bundle the latest L. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 What is riotjs? |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
From the L: |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
A REACT-LIKE, 2.5KB USER INTERFACE LIBRARY |
22
|
|
|
|
|
|
|
Custom tags - Virtual DOM - Full stack - IE8 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 Dependencies |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Riot is required for this module to work. You can install Riot with |
27
|
|
|
|
|
|
|
L: |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$ sudo apt-get install npm |
30
|
|
|
|
|
|
|
$ npm install riot |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SYNOPSIS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use Mojolicious::Lite; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
get "/" => "index"; |
37
|
|
|
|
|
|
|
app->plugin("riotjs"); |
38
|
|
|
|
|
|
|
app->asset( |
39
|
|
|
|
|
|
|
"app.js" => qw( |
40
|
|
|
|
|
|
|
http://cdnjs.cloudflare.com/ajax/libs/riot/2.0.13/riot.js |
41
|
|
|
|
|
|
|
/js/todo.tag |
42
|
|
|
|
|
|
|
/js/main.js |
43
|
|
|
|
|
|
|
) |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
app->start; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__DATA__ |
48
|
|
|
|
|
|
|
@@ /js/todo.tag |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
{ opts.title } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
{ item.title } |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
this.items = [] |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
add(e) { |
62
|
|
|
|
|
|
|
var input = e.target[0] |
63
|
|
|
|
|
|
|
if (input.value.length) this.items.push({ title: input.value }) |
64
|
|
|
|
|
|
|
input.value = '' |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
@@ /js/main.js |
69
|
|
|
|
|
|
|
riot.mount('todo') |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
@@ index.html.ep |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Riot.js Demo |
76
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
%= asset "app.js" |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
2
|
|
|
2
|
|
1504593
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
91
|
2
|
|
|
2
|
|
346
|
use Cwd (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
622
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$ENV{NODE_PATH} ||= ''; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 METHODS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 node_paths |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
@paths = $self->node_paths($app); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Returns the path to available "node_modules". This is used by L to |
104
|
|
|
|
|
|
|
set the C environment variable. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
The default is to look for "node_modules" in current directy and relative to |
107
|
|
|
|
|
|
|
L. It will also use the current value of |
108
|
|
|
|
|
|
|
C if already set. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub node_paths { |
113
|
1
|
|
|
1
|
1
|
3
|
my ($self, $app) = @_; |
114
|
1
|
|
|
|
|
1
|
my %PATH; |
115
|
|
|
|
|
|
|
|
116
|
1
|
50
|
33
|
|
|
3
|
grep { $_ and -d and !$PATH{$_}++ } split(/:/, $ENV{NODE_PATH}), eval { Cwd::abs_path('node_modules') }, |
|
2
|
|
|
|
|
110
|
|
|
1
|
|
|
|
|
28
|
|
117
|
|
|
|
|
|
|
$app->home->rel_dir('node_modules'); |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 register |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Will register the L with the |
123
|
|
|
|
|
|
|
".tag" file extension. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub register { |
128
|
1
|
|
|
1
|
1
|
34
|
my ($self, $app, $config) = @_; |
129
|
|
|
|
|
|
|
|
130
|
1
|
|
50
|
|
|
5
|
$config->{ext} ||= 'tag'; |
131
|
1
|
|
|
|
|
3
|
$ENV{NODE_PATH} = join ':', $self->node_paths($app); |
132
|
1
|
50
|
|
|
|
3
|
$app->plugin('AssetPack') unless eval { $app->asset }; |
|
1
|
|
|
|
|
14
|
|
133
|
1
|
|
|
|
|
29185
|
$app->asset->preprocessors->add($config->{ext} => 'Mojolicious::Plugin::Riotjs::Preprocessor' => $config); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Copyright (C) 2014, Jan Henning Thorsen |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
141
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 AUTHOR |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Jan Henning Thorsen - C |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |