my-simon 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/.document +5 -0
  2. data/.gitignore.orig +55 -0
  3. data/DOC/Launch Check List.docx +0 -0
  4. data/DOC/Launch Check List.pdf +0 -0
  5. data/Gemfile +14 -0
  6. data/Gemfile.lock +44 -0
  7. data/LICENSE.txt +20 -0
  8. data/README.md +21 -0
  9. data/README.rdoc +19 -0
  10. data/Rakefile +46 -0
  11. data/VERSION +1 -0
  12. data/build/rakefile.rb +12 -0
  13. data/config.rb +24 -0
  14. data/lib/simon.rb +0 -5
  15. data/my-simon.gemspec +141 -0
  16. data/scaffolding/simon/controller.tpl +9 -0
  17. data/scaffolding/simon/model.tpl +10 -0
  18. data/scaffolding/simon/view.tpl +5 -0
  19. data/scaffolding/standards/html_template.html +44 -0
  20. data/scaffolding/standards/html_template.php +44 -0
  21. data/scaffolding/standards/jquery_plugin_template.js +45 -0
  22. data/scaffolding/standards/js_template.js +43 -0
  23. data/simon +282 -0
  24. data/test/helper.rb +18 -0
  25. data/test/test_simon.rb +7 -0
  26. data/www/.htaccess +488 -0
  27. data/www/404.html +32 -0
  28. data/www/crossdomain.xml +25 -0
  29. data/www/favicon.ico +0 -0
  30. data/www/index.php +17 -0
  31. data/www/lib/js/homePage.js +43 -0
  32. data/www/lib/js/jquery/JQbook.js +809 -0
  33. data/www/lib/js/jquery/jquery-1.8.0.min.js +27 -0
  34. data/www/lib/js/jquery/jquery.alphanumeric.js +82 -0
  35. data/www/lib/js/jquery/jquery.cookie.js +96 -0
  36. data/www/lib/js/jquery/jquery.easing.1.3.js +207 -0
  37. data/www/lib/js/main.js +117 -0
  38. data/www/lib/js/master.js +6 -0
  39. data/www/lib/js/plugins/handlebars-1.0.rc.1.js +1920 -0
  40. data/www/lib/js/plugins/modernizr-1.7.min.js +2 -0
  41. data/www/lib/js/plugins/swfobject.js +777 -0
  42. data/www/lib/js/plugins_mod/README.txt +3 -0
  43. data/www/lib/php/app.php +53 -0
  44. data/www/lib/php/controller/index.php +10 -0
  45. data/www/lib/php/controller/regex.php +23 -0
  46. data/www/lib/php/model/Book.php +8 -0
  47. data/www/lib/php/model/Model.php +8 -0
  48. data/www/lib/php/plugins/php-activerecord/ActiveRecord.php +44 -0
  49. data/www/lib/php/plugins/php-activerecord/lib/CallBack.php +226 -0
  50. data/www/lib/php/plugins/php-activerecord/lib/Column.php +155 -0
  51. data/www/lib/php/plugins/php-activerecord/lib/Config.php +288 -0
  52. data/www/lib/php/plugins/php-activerecord/lib/Connection.php +456 -0
  53. data/www/lib/php/plugins/php-activerecord/lib/ConnectionManager.php +38 -0
  54. data/www/lib/php/plugins/php-activerecord/lib/DateTime.php +45 -0
  55. data/www/lib/php/plugins/php-activerecord/lib/Exceptions.php +137 -0
  56. data/www/lib/php/plugins/php-activerecord/lib/Expressions.php +183 -0
  57. data/www/lib/php/plugins/php-activerecord/lib/Inflector.php +115 -0
  58. data/www/lib/php/plugins/php-activerecord/lib/Model.php +1673 -0
  59. data/www/lib/php/plugins/php-activerecord/lib/Reflections.php +86 -0
  60. data/www/lib/php/plugins/php-activerecord/lib/Relationship.php +637 -0
  61. data/www/lib/php/plugins/php-activerecord/lib/SQLBuilder.php +396 -0
  62. data/www/lib/php/plugins/php-activerecord/lib/Serialization.php +302 -0
  63. data/www/lib/php/plugins/php-activerecord/lib/Singleton.php +57 -0
  64. data/www/lib/php/plugins/php-activerecord/lib/Table.php +547 -0
  65. data/www/lib/php/plugins/php-activerecord/lib/Utils.php +351 -0
  66. data/www/lib/php/plugins/php-activerecord/lib/Validations.php +833 -0
  67. data/www/lib/php/plugins/php-activerecord/lib/adapters/MysqlAdapter.php +73 -0
  68. data/www/lib/php/plugins/php-activerecord/lib/adapters/OciAdapter.php +121 -0
  69. data/www/lib/php/plugins/php-activerecord/lib/adapters/PgsqlAdapter.php +104 -0
  70. data/www/lib/php/plugins/php-activerecord/lib/adapters/SqliteAdapter.php +81 -0
  71. data/www/lib/php/system/Config.php +174 -0
  72. data/www/lib/php/system/config.routes.php +29 -0
  73. data/www/lib/php/system/router.php +220 -0
  74. data/www/lib/php/template/footer.php +59 -0
  75. data/www/lib/php/template/header.php +74 -0
  76. data/www/lib/php/view/index.php +5 -0
  77. data/www/media/images/facebook_share.jpg +0 -0
  78. data/www/robots.txt +5 -0
  79. data/www/sandbox/readme.txt +3 -0
  80. data/www/sass/javascript.scss +1 -0
  81. data/www/sass/layout.scss +128 -0
  82. data/www/sass/master.scss +4 -0
  83. data/www/sass/reset.scss +47 -0
  84. data/www/sass/typography.scss +24 -0
  85. data/www/styles/javascript.css +1 -0
  86. data/www/styles/layout.css +186 -0
  87. data/www/styles/master.css +4 -0
  88. data/www/styles/reset.css +60 -0
  89. data/www/styles/typography.css +24 -0
  90. metadata +179 -7
data/simon ADDED
@@ -0,0 +1,282 @@
1
+ #!/usr/bin/php
2
+ <?php
3
+
4
+
5
+ $command = $argv[1];
6
+ $repo_url = "";
7
+
8
+
9
+
10
+ switch ($command) {
11
+ case 'setup':
12
+
13
+
14
+ $resonse = strtolower(askQuestion("Do you want to setup your project namespace? [y/n]"));
15
+
16
+ if($resonse === "y"){
17
+
18
+ _replace_namespace();
19
+
20
+ }elseif($resonse != "n"){
21
+ e_check("","Invalid Answer: ".$resonse);
22
+ }
23
+
24
+
25
+ $resonse = strtolower(askQuestion("Do you want to setup your local DB? [y/n]"));
26
+
27
+ if($resonse === "y"){
28
+
29
+ _setup_db();
30
+ }elseif($resonse != "n"){
31
+ e_check("","Invalid Answer: ".$resonse);
32
+ }
33
+
34
+ $resonse = strtolower(askQuestion("Do you want to set the Google Analytics tracking id? [y/n]"));
35
+
36
+ if($resonse === "y"){
37
+
38
+ _setup_tracking();
39
+ }elseif($resonse != "n"){
40
+ e_check("","Invalid Answer: ".$resonse);
41
+ }
42
+
43
+ _sucess_msg();
44
+ break;
45
+ case "add" :
46
+
47
+ if($argv[2] === "section"){
48
+
49
+ _add_section();
50
+
51
+ _sucess_msg();
52
+
53
+
54
+ }
55
+
56
+ if($argv[2] === "repo"){
57
+
58
+ _add_repo();
59
+
60
+ _sucess_msg();
61
+
62
+
63
+ }
64
+
65
+
66
+
67
+ break;
68
+ case 'help':
69
+ //TODO
70
+ break;
71
+ default:
72
+ echo "WTF are you trying to do? \n";
73
+ break;
74
+ }
75
+
76
+
77
+ function _setup_boilerplate(){
78
+
79
+ }
80
+
81
+
82
+ function _SearchandReplaceFILE($p_file, $stringsearch, $stringreplace){
83
+ // read the file
84
+ $file = file_get_contents($p_file);
85
+ // replace the data
86
+ $file = str_replace($stringsearch, $stringreplace, $file);
87
+ // write the file
88
+ file_put_contents($p_file, $file);
89
+ }
90
+
91
+ function _SearchandReplaceDIR($dir, $stringsearch, $stringreplace){
92
+ $listDir = array();
93
+ if($handler = opendir($dir)) {
94
+ while (($sub = readdir($handler)) !== FALSE) {
95
+ if ($sub != "." && $sub != ".." && $sub != "Thumb.db") {
96
+ if(is_file($dir."/".$sub)) {
97
+ if(substr_count($sub,'.php') || substr_count($sub,'.js') || substr_count($sub,'.html') || substr_count($sub,'.tpl'))
98
+ {
99
+ $getfilecontents = file_get_contents($dir."/".$sub);
100
+ if(substr_count($getfilecontents,$stringsearch)>0)
101
+ {
102
+ $replacer = str_replace($stringsearch,$stringreplace,$getfilecontents);
103
+ // Let's make sure the file exists and is writable first.
104
+ if (is_writable($dir."/".$sub)) {
105
+ if (!$handle = fopen($dir."/".$sub, 'w')) {
106
+ echo "Cannot open file (".$dir."/".$sub.")\n";
107
+ exit;
108
+ }
109
+ // Write $somecontent to our opened file.
110
+ if (fwrite($handle, $replacer) === FALSE) {
111
+ echo "Cannot write to file (".$dir."/".$sub.")\n";
112
+ exit;
113
+ }
114
+
115
+ fclose($handle);
116
+ } else {
117
+ //echo "The file ".$dir."/".$sub." is not writable \n";
118
+ }
119
+ }
120
+ }
121
+ $listDir[] = $sub;
122
+ }elseif(is_dir($dir."/".$sub)){
123
+ $listDir[$sub] = _SearchandReplaceDIR($dir."/".$sub,$stringsearch,$stringreplace);
124
+ }
125
+ }
126
+ }
127
+ closedir($handler);
128
+ }
129
+ return $listDir;
130
+ }
131
+
132
+ function e_check($p,$msg,$try_again=false){
133
+
134
+ if(isset($p) && strlen($p) != 0){
135
+ echo $p;
136
+ return $p;
137
+ }else if($try_again == 1 ){
138
+ return askQuestion("\n-> Cannot be blank! Try again: ");
139
+ }else{
140
+ echo "Missing parameter: ".$msg."! Try again. \n";
141
+ exit;
142
+ }
143
+ }
144
+
145
+ function askQuestion($p_question){
146
+ echo $p_question.": ";
147
+ system('stty -echo');
148
+ $answer = trim(fgets(STDIN));
149
+ system('stty echo');
150
+ $answer = e_check($answer, "Please enter a value.",true);
151
+ echo "\n";
152
+ return $answer;
153
+ }
154
+
155
+ function _setup_db(){
156
+
157
+ $host = askQuestion("-> What is the DB host?");
158
+ $username = askQuestion("-> What is the DB Username?");
159
+ $password = askQuestion("-> What is the DB password?");
160
+ $dbname = askQuestion("-> What is the DB name?");
161
+
162
+ $file = "./www/lib/php/system/Config.php";
163
+ _SearchandReplaceFILE($file, "%l_host%", $host);
164
+ _SearchandReplaceFILE($file, "%l_user%", $username);
165
+ _SearchandReplaceFILE($file, "%l_pass%", $password);
166
+ _SearchandReplaceFILE($file, "%l_dbname%", $dbname);
167
+
168
+
169
+ }
170
+
171
+ function _replace_namespace(){
172
+ $stringsearch = "CHANGE_ME";
173
+ $stringreplace = askQuestion("-> What do you want as the namespace? (no spaces [aA-zZ]) ");
174
+ $dir = "./";
175
+ _SearchandReplaceDIR($dir,$stringsearch,$stringreplace);
176
+ echo "\n";
177
+ }
178
+
179
+ function _setup_tracking(){
180
+ $tracking_id = askQuestion("-> Google Tracking ID");
181
+ $file = "./www/lib/php/system/Config.php";
182
+ _SearchandReplaceFILE($file, "%google_id%", $tracking_id);
183
+ }
184
+
185
+ function _add_section(){
186
+
187
+ $section_name = askQuestion("-> Name (no spaces [aA-zZ]) ");
188
+ // $section_name = ucfirst($section_name);
189
+
190
+ // controller
191
+ $ctrl_startpoint = "./scaffolding/simon/controller.tpl";
192
+ $ctrl_endpoint = "./www/lib/php/controller/".$section_name.".php";
193
+ exec ("cp ".$ctrl_startpoint." ".$ctrl_endpoint );
194
+ _SearchandReplaceFILE($ctrl_endpoint, "%name%", $section_name);
195
+
196
+ // view
197
+ $ctrl_startpoint = "./scaffolding/simon/view.tpl";
198
+ $ctrl_endpoint = "./www/lib/php/view/".$section_name.".php";
199
+ exec ("cp ".$ctrl_startpoint." ".$ctrl_endpoint );
200
+
201
+ //javascript singleton
202
+ $ctrl_startpoint = "./scaffolding/standards/js_template.js";
203
+ $ctrl_endpoint = "./www/lib/js/".$section_name.".js";
204
+ exec ("cp ".$ctrl_startpoint." ".$ctrl_endpoint );
205
+ _SearchandReplaceFILE($ctrl_endpoint, "CLASS_NAME", $section_name);
206
+ _SearchandReplaceFILE("./www/lib/php/template/footer.php", "<!-- END_DEV: javascript -->", "<script src=\"lib/js/".$section_name.".js\" type=\"text/javascript\" charset=\"utf-8\"></script>\n\t<!-- END_DEV: javascript -->");
207
+ _SearchandReplaceFILE("./www/lib/js/master.js", "*/", "* @depends ".$section_name.".js \n */");
208
+
209
+ // routes
210
+ $routes = "./www/lib/php/system/config.routes.php";
211
+ $current_routedata = file_get_contents($routes, true);
212
+ $current_routedata = str_replace("?>", "", $current_routedata);
213
+ $current_routedata .= "Router::add('/".$section_name."', DIR_CTRL.'/".$section_name.".php');\n ?>";
214
+ file_put_contents($routes, $current_routedata);
215
+
216
+ $resonse = strtolower(askQuestion("Do you want to add a Model? [y/n]"));
217
+
218
+ if($resonse === "y"){
219
+
220
+ // model
221
+ $ctrl_startpoint = "./scaffolding/simon/model.tpl";
222
+ $ctrl_endpoint = "./www/lib/php/model/".$section_name.".php";
223
+ exec ("cp ".$ctrl_startpoint." ".$ctrl_endpoint );
224
+ _SearchandReplaceFILE($ctrl_endpoint, "%name%", $section_name);
225
+
226
+ }
227
+
228
+ }
229
+
230
+ function _add_repo(){
231
+
232
+ $repo_name = askQuestion("-> What do you want to call the repository? (no spaces [aA-zZ])");
233
+ $repo_username = askQuestion("-> Beanstalk Username?");
234
+ $repo_pass = askQuestion("-> Beanstalk Password?");
235
+ $beanstalkapp_account = askQuestion("-> Beanstalk Account name?");
236
+
237
+ $url = "https://".$repo_username.":".$repo_pass."@".$beanstalkapp_account.".beanstalkapp.com/api/repositories.json";
238
+
239
+ $data_array = array('repository' => array());
240
+ $data_array['repository']['name'] = $repo_name;
241
+ $data_array['repository']['type_id'] = "git";
242
+ $data_array['repository']['title'] = $repo_name;
243
+ $data_array['repository']['color_label'] = "label-blue";
244
+ $data = json_encode($data_array);
245
+
246
+ //open connection
247
+ $ch = curl_init();
248
+
249
+ //set the url, number of POST vars, POST data
250
+ $headers = array('Content-type: application/json');
251
+ curl_setopt($ch,CURLOPT_USERAGENT,'evolveit');
252
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
253
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
254
+ curl_setopt($ch,CURLOPT_URL, $url);
255
+ curl_setopt($ch,CURLOPT_POST, count($data_array));
256
+ curl_setopt($ch,CURLOPT_POSTFIELDS, $data);
257
+
258
+ //execute post
259
+ $result = curl_exec($ch);
260
+
261
+ $result = json_decode($result);
262
+
263
+ if(!empty($result->errors)){
264
+ echo $result->errors[0]."\n";
265
+ exit;
266
+ }else{
267
+ $repo_url = $result->git_repository->repository_url;
268
+ echo "-> Repo location: ".$result->git_repository->repository_url;
269
+ }
270
+
271
+ //close connection
272
+ curl_close($ch);
273
+
274
+ }
275
+
276
+ function _sucess_msg(){
277
+
278
+ echo "\n-> Simon: Finished! ( ͡° ͜ʖ ͡°) \n";
279
+
280
+ }
281
+
282
+ ?>
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'simon'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestSimon < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end