| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Farabi; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
47376
|
use Mojo::Base 'Mojolicious'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
8
|
|
|
4
|
1
|
|
|
1
|
|
660093
|
use Path::Tiny; |
|
|
1
|
|
|
|
|
12149
|
|
|
|
1
|
|
|
|
|
974
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Modern Perl IDE |
|
7
|
|
|
|
|
|
|
our $VERSION = '0.47'; # VERSION |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Application SQLite database and projects are stored in this directory |
|
11
|
|
|
|
|
|
|
has 'home_dir'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Projects are stored in this directory |
|
14
|
|
|
|
|
|
|
has 'projects_dir'; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# The database name and location |
|
17
|
|
|
|
|
|
|
has 'db_name'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub startup { |
|
20
|
1
|
|
|
1
|
1
|
22287
|
my $app = shift; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Change secret passphrase that is used for signed cookies |
|
23
|
1
|
|
|
|
|
38
|
$app->secrets( ['Hulk, Smash!'] ); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Use content from directories under lib/Farabi/files |
|
26
|
1
|
|
|
|
|
39
|
$app->home->parse( path( path(__FILE__)->dirname, 'Farabi' ) ); |
|
27
|
1
|
|
|
|
|
253
|
$app->static->paths->[0] = $app->home->rel_dir('files/public'); |
|
28
|
1
|
|
|
|
|
127
|
$app->renderer->paths->[0] = $app->home->rel_dir('files/templates'); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Define routes |
|
31
|
1
|
|
|
|
|
112
|
my $route = $app->routes; |
|
32
|
1
|
|
|
|
|
22
|
$route->get('/')->to('editor#default'); |
|
33
|
1
|
|
|
|
|
547
|
$route->post("/syntax_check")->to('editor#syntax_check'); |
|
34
|
1
|
|
|
|
|
713
|
$route->post('/pod2html')->to('editor#pod2html'); |
|
35
|
1
|
|
|
|
|
594
|
$route->post("/md2html")->to('editor#md2html'); |
|
36
|
1
|
|
|
|
|
621
|
$route->post("/perl_critic")->to('editor#perl_critic'); |
|
37
|
1
|
|
|
|
|
632
|
$route->post("/perl_tidy")->to('editor#perl_tidy'); |
|
38
|
1
|
|
|
|
|
624
|
$route->post("/perl_strip")->to('editor#perl_strip'); |
|
39
|
1
|
|
|
|
|
615
|
$route->post("/spellunker")->to('editor#spellunker'); |
|
40
|
1
|
|
|
|
|
652
|
$route->post("/code_cutnpaste")->to('editor#code_cutnpaste'); |
|
41
|
1
|
|
|
|
|
692
|
$route->post("/git")->to('editor#git'); |
|
42
|
1
|
|
|
|
|
557
|
$route->post("/open_file")->to('editor#open_file'); |
|
43
|
1
|
|
|
|
|
663
|
$route->post("/save_file")->to('editor#save_file'); |
|
44
|
1
|
|
|
|
|
603
|
$route->post("/find_file")->to('editor#find_file'); |
|
45
|
1
|
|
|
|
|
613
|
$route->post("/find_action")->to('editor#find_action'); |
|
46
|
1
|
|
|
|
|
583
|
$route->post("/run_perl")->to('editor#run_perl'); |
|
47
|
1
|
|
|
|
|
639
|
$route->post("/run_perlbrew_exec")->to('editor#run_perlbrew_exec'); |
|
48
|
1
|
|
|
|
|
662
|
$route->post("/dump_ppi_tree")->to('editor#dump_ppi_tree'); |
|
49
|
1
|
|
|
|
|
565
|
$route->post("/repl_eval")->to('editor#repl_eval'); |
|
50
|
1
|
|
|
|
|
650
|
$route->post("/ping")->to('editor#ping'); |
|
51
|
1
|
|
|
|
|
590
|
$route->post("/ack")->to('editor#ack'); |
|
52
|
1
|
|
|
|
|
576
|
$route->post("/midgen")->to('editor#midgen'); |
|
53
|
1
|
|
|
|
|
580
|
$route->post("/project")->to('editor#project'); |
|
54
|
1
|
|
|
|
|
505
|
$route->post("/cpanm")->to('editor#cpanm'); |
|
55
|
1
|
|
|
|
|
556
|
$route->post("/help")->to('editor#help'); |
|
56
|
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
532
|
eval { $app->_setup_dirs }; |
|
|
1
|
|
|
|
|
8
|
|
|
58
|
1
|
50
|
|
|
|
76
|
if ($@) { |
|
59
|
0
|
|
|
|
|
0
|
die "Failure to create \$HOME/.farabi directory structure, reason: $@"; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# The database name |
|
63
|
1
|
|
|
|
|
21
|
$app->db_name( path( $app->home_dir, 'farabi.db' ) ); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Setup the Farabi database |
|
66
|
1
|
|
|
|
|
50
|
eval { $app->_setup_database }; |
|
|
1
|
|
|
|
|
5
|
|
|
67
|
1
|
50
|
|
|
|
460
|
if ($@) { |
|
68
|
0
|
|
|
|
|
0
|
warn "Database not setup, reason: $@"; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub support_can_be_enabled { |
|
74
|
8
|
|
|
8
|
0
|
53444
|
my $app = shift; |
|
75
|
8
|
|
|
|
|
15
|
my $module = shift; |
|
76
|
|
|
|
|
|
|
|
|
77
|
8
|
|
|
|
|
61
|
my %REQUIRED_VERSION = ( |
|
78
|
|
|
|
|
|
|
'Perl::Critic' => '1.118', |
|
79
|
|
|
|
|
|
|
'Perl::Tidy' => '20121207', |
|
80
|
|
|
|
|
|
|
'Perl::Strip' => '1.1', |
|
81
|
|
|
|
|
|
|
'Spellunker' => '0.0.17', |
|
82
|
|
|
|
|
|
|
'Code::CutNPaste' => '0.04', |
|
83
|
|
|
|
|
|
|
'App::Midgen' => '0.32', |
|
84
|
|
|
|
|
|
|
'Dist::Zilla' => '5.016', |
|
85
|
|
|
|
|
|
|
); |
|
86
|
|
|
|
|
|
|
|
|
87
|
8
|
|
|
|
|
15
|
my $version = $REQUIRED_VERSION{$module}; |
|
88
|
8
|
50
|
|
|
|
26
|
return 0 unless defined $version; |
|
89
|
|
|
|
|
|
|
|
|
90
|
1
|
|
|
1
|
|
1804
|
eval qq{use $module $version;}; |
|
|
1
|
|
|
1
|
|
1686267
|
|
|
|
1
|
|
|
1
|
|
49
|
|
|
|
1
|
|
|
1
|
|
9
|
|
|
|
1
|
|
|
1
|
|
18
|
|
|
|
1
|
|
|
1
|
|
76
|
|
|
|
1
|
|
|
1
|
|
423
|
|
|
|
0
|
|
|
1
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
331
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
339
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
427
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
389
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
1
|
|
|
|
|
8
|
|
|
|
1
|
|
|
|
|
30
|
|
|
|
1
|
|
|
|
|
40
|
|
|
|
8
|
|
|
|
|
646
|
|
|
91
|
8
|
100
|
|
|
|
14670
|
if ($@) { |
|
92
|
5
|
|
|
|
|
155
|
$app->log->warn( |
|
93
|
|
|
|
|
|
|
"$module support is disabled. Please install $module $version or later." |
|
94
|
|
|
|
|
|
|
); |
|
95
|
5
|
|
|
|
|
244
|
return 0; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
else { |
|
98
|
3
|
|
|
|
|
91
|
$app->log->info("$module support is enabled"); |
|
99
|
3
|
|
|
|
|
156
|
return 1; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# |
|
104
|
|
|
|
|
|
|
# Create the following directory structure: |
|
105
|
|
|
|
|
|
|
# .farabi |
|
106
|
|
|
|
|
|
|
# .farabi/projects |
|
107
|
|
|
|
|
|
|
# |
|
108
|
|
|
|
|
|
|
sub _setup_dirs { |
|
109
|
1
|
|
|
1
|
|
4
|
my $app = shift; |
|
110
|
|
|
|
|
|
|
|
|
111
|
1
|
|
|
|
|
2133
|
require File::HomeDir; |
|
112
|
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
8319
|
$app->home_dir( path( File::HomeDir->home, ".farabi" ) ); |
|
114
|
1
|
|
|
|
|
140
|
$app->projects_dir( path( $app->home_dir, "projects" ) ); |
|
115
|
1
|
|
|
|
|
72
|
$app->projects_dir->mkpath; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# Setup the Farabi database |
|
119
|
|
|
|
|
|
|
sub _setup_database { |
|
120
|
1
|
|
|
1
|
|
4
|
my $app = shift; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# Connect and create the Farabi SQLite database if not found |
|
123
|
1
|
|
|
|
|
876
|
require DBIx::Simple; |
|
124
|
1
|
|
|
|
|
51153
|
my $db_name = $app->db_name; |
|
125
|
1
|
|
|
|
|
35
|
my $db = DBIx::Simple->connect("dbi:SQLite:dbname=$db_name"); |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# Create tables if they do not exist |
|
128
|
1
|
|
|
|
|
20440
|
$db->query(<<SQL); |
|
129
|
|
|
|
|
|
|
CREATE TABLE IF NOT EXISTS recent_list ( |
|
130
|
|
|
|
|
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT, |
|
131
|
|
|
|
|
|
|
name TEXT, |
|
132
|
|
|
|
|
|
|
type TEXT, |
|
133
|
|
|
|
|
|
|
last_used TEXT |
|
134
|
|
|
|
|
|
|
) |
|
135
|
|
|
|
|
|
|
SQL |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# Disconnect from database |
|
138
|
1
|
|
|
|
|
510
|
$db->disconnect; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
__END__ |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=pod |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=encoding UTF-8 |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 NAME |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Farabi - Modern Perl IDE |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 VERSION |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
version 0.47 |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# Run on the default port 4040 |
|
160
|
|
|
|
|
|
|
$ farabi |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# Run it on port 5050 |
|
163
|
|
|
|
|
|
|
$ farabi --port 5050 |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
This is a modern web-based Perl IDE that runs inside your favorite browser. |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Please run the following command and then open http://127.0.0.1:4040 in your browser: |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
farabi |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 SECURITY WARNING |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
B<Farabi is an experiment in progress>. It is a web-based user interface with a backend Perl web server. |
|
176
|
|
|
|
|
|
|
Please B<DO NOT> serve it on the Internet unless you jail it in an isolated uber-secure |
|
177
|
|
|
|
|
|
|
environment that has proper CPU and I/O limits and non-root access. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
You have been warned, young padawan :) |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 FEATURES |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=over |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item Open File(s) |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
The dialog provides partial filename search inside the directory where Farabi was started. |
|
188
|
|
|
|
|
|
|
Matched single or multiple file selections can then be opened in one batch. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
B<WARNING:> Please do not start farabi in a folder with too many files like your home directory |
|
191
|
|
|
|
|
|
|
because this feature's performance will eventually suffer. |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=back |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 METHODS |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 support_can_be_enabled |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Returns 1 when a required C<module> with a specific version is found otherwise returns 0. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
It can be used in the future to toggle feature XYZ runtime support |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head1 TECHNOLOGIES USED |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=over |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item * |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
L<Mojolicious|http://mojolicio.us> - A next generation web framework for the Perl programming language |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=item * |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
L<jQuery|http://jquery.com/> - A new kind of JavaScript Library |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item * |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
L<JSHint|http://jshint.com/> - A JavaScript Code Quality Tool |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=item * |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
L<Bootstrap|http://twitter.github.com/bootstrap> - Sleek, intuitive, and powerful front-end framework for faster and easier web development |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item * |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
L<CodeMirror|http://codemirror.net> - In-browser code editing made bearable |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item * |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
L<Perlito|http://perlito.org/> - Runtime for "Perlito" Perl5-in-Javascript |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=back |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
L<EPIC|http://www.epic-ide.org/>, L<Kephra>, L<Padre>, L<TryPerl|http://tryperl.com/> |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 HISTORY |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
The idea started back in March 2012 as a fork of L<Padre>. I wanted to dump L<Wx> for the browser. |
|
240
|
|
|
|
|
|
|
The first version was in 11th April as L<Mojolicious::Plugin::Pedro>. It used the ACE Javascript |
|
241
|
|
|
|
|
|
|
editor and jQuery UI. Then i hibernated for a while to play games :) Later I heard about L<Galileo>. |
|
242
|
|
|
|
|
|
|
It basically used the same idea, mojolicious backend, browser for the frontend. So I stopped |
|
243
|
|
|
|
|
|
|
playing games and rolled my sleeves to focus on Pedro. |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Later I discovered Pedro was not a good name for my project. So I chose Farabi for |
|
246
|
|
|
|
|
|
|
L<Al-Farabi|http://en.wikipedia.org/wiki/Al-Farabi> who was a renowned scientist and philosopher |
|
247
|
|
|
|
|
|
|
of the Islamic Golden Age. He was also a cosmologist, logician,and musician. |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=head1 SUPPORT |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
If you find a bug, please report it in: |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
L<https://github.com/azawawi/farabi/issues> |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
If you find this module useful, please rate it in: |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Farabi> |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 AUTHORS |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
Ahmad M. Zawawi E<lt>ahmad.zawawi@gmail.comE<gt> |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Kevin Dawson E<lt>bowtie@cpan.orgE<gt> |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head1 AUTHOR |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Ahmad M. Zawawi <ahmad.zawawi@gmail.com> |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Ahmad M. Zawawi. |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
276
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=cut |