codeigniter_vender 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +11 -8
- data/VERSION +1 -1
- data/codeigniter_vender.gemspec +11 -10
- data/lib/generators/ci/auth/auth_generator.rb +24 -0
- data/lib/generators/ci/{ci_auth → auth}/templates/auth.php +9 -8
- data/lib/generators/ci/auth/templates/auth_model.php +56 -0
- data/lib/generators/ci/base.rb +18 -0
- data/lib/generators/ci/install/install_generator.rb +5 -6
- data/lib/generators/ci/layout/layout_generator.rb +19 -0
- data/lib/generators/ci/{ci_layout/templates/application_layout.php.erb → layout/templates/application_layout.php} +1 -1
- metadata +12 -11
- data/lib/generators/ci/ci_auth/ci_auth_generator.rb +0 -11
- data/lib/generators/ci/ci_auth/templates/auth_model.php +0 -52
- data/lib/generators/ci/ci_layout/ci_layout_generator.rb +0 -24
- /data/lib/generators/ci/{ci_auth → auth}/USAGE +0 -0
- /data/lib/generators/ci/{ci_auth → auth}/templates/login_form.php +0 -0
- /data/lib/generators/ci/{ci_layout → layout}/USAGE +0 -0
data/README.md
CHANGED
@@ -4,16 +4,14 @@ This is for ruby fans who also love php. I love [CodeIgniter](http://codeigniter
|
|
4
4
|
|
5
5
|
It is a set of php-code generators.
|
6
6
|
|
7
|
-
The current CodeIgniter version is 2.0
|
7
|
+
The current official CodeIgniter version is 2.0.
|
8
8
|
|
9
|
-
|
9
|
+
#### What is CodeIgniter?
|
10
10
|
|
11
|
-
in
|
12
|
-
|
11
|
+
CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. If you're a developer who lives in the real world of shared hosting accounts and clients with deadlines, and if you're tired of ponderously large and thoroughly undocumented frameworks.
|
12
|
+
|
13
|
+
CodeIgniter 是一个小巧但功能强大的 PHP 框架,作为一个简单而“优雅”的工具包,它可以为 PHP 程序员建立功能完善的 Web 应用程序。如果你是一个使用共享主机,并且为客户所要求的期限而烦恼的开发人员,如果你已经厌倦了那些傻大笨粗的框架。
|
13
14
|
|
14
|
-
ruby script/generate ci_controller blog hot old
|
15
|
-
|
16
|
-
The above commands will generate php code into public directory
|
17
15
|
|
18
16
|
### How to start?
|
19
17
|
|
@@ -42,7 +40,12 @@ This will generate a controller named Page and two pages (about_us.php and help)
|
|
42
40
|
|
43
41
|
Enjoy it!
|
44
42
|
|
43
|
+
### Resources
|
45
44
|
|
45
|
+
+ [CodeIgniter official site](http://codeigniter.com/)
|
46
|
+
+ [CodeIgniter user guide](http://codeigniter.com/user_guide/)
|
47
|
+
+ [CodeIgniter中国站](http://codeigniter.org.cn/)
|
48
|
+
+ [XAMPP](http://www.apachefriends.org/zh_cn/xampp.html)
|
46
49
|
|
47
50
|
### TODO List
|
48
51
|
|
@@ -50,4 +53,4 @@ Enjoy it!
|
|
50
53
|
+ test!!!
|
51
54
|
|
52
55
|
|
53
|
-
Copyright (c) 2010 [qichunren], released under the MIT license
|
56
|
+
Copyright (c) 2010 - 2011 [qichunren], released under the MIT license
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/codeigniter_vender.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{codeigniter_vender}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["qichunren"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-21}
|
13
13
|
s.description = %q{CodeigniterVender is a Ruby gem for php coder who love CodeIgniter.This is for rubyist who also love php.}
|
14
14
|
s.email = %q{whyruby@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -32,14 +32,12 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/codeigniter/commands/help.rb",
|
33
33
|
"lib/codeigniter/tasks/ci.rake",
|
34
34
|
"lib/codeigniter_vender.rb",
|
35
|
-
"lib/generators/ci/
|
36
|
-
"lib/generators/ci/
|
37
|
-
"lib/generators/ci/
|
38
|
-
"lib/generators/ci/
|
39
|
-
"lib/generators/ci/
|
40
|
-
"lib/generators/ci/
|
41
|
-
"lib/generators/ci/ci_layout/ci_layout_generator.rb",
|
42
|
-
"lib/generators/ci/ci_layout/templates/application_layout.php.erb",
|
35
|
+
"lib/generators/ci/auth/USAGE",
|
36
|
+
"lib/generators/ci/auth/auth_generator.rb",
|
37
|
+
"lib/generators/ci/auth/templates/auth.php",
|
38
|
+
"lib/generators/ci/auth/templates/auth_model.php",
|
39
|
+
"lib/generators/ci/auth/templates/login_form.php",
|
40
|
+
"lib/generators/ci/base.rb",
|
43
41
|
"lib/generators/ci/controller/USAGE",
|
44
42
|
"lib/generators/ci/controller/controller_generator.rb",
|
45
43
|
"lib/generators/ci/controller/templates/controller.php",
|
@@ -366,6 +364,9 @@ Gem::Specification.new do |s|
|
|
366
364
|
"lib/generators/ci/install/templates/CodeIgniterLibs/CodeIgniter_2.0.0/user_guide/userguide.css",
|
367
365
|
"lib/generators/ci/install/templates/README",
|
368
366
|
"lib/generators/ci/install/templates/config/database.php",
|
367
|
+
"lib/generators/ci/layout/USAGE",
|
368
|
+
"lib/generators/ci/layout/layout_generator.rb",
|
369
|
+
"lib/generators/ci/layout/templates/application_layout.php",
|
369
370
|
"lib/generators/ci/model/USAGE",
|
370
371
|
"lib/generators/ci/model/model_generator.rb",
|
371
372
|
"lib/generators/ci/model/templates/model.php",
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "generators/ci/base"
|
3
|
+
|
4
|
+
module Ci
|
5
|
+
module Generators
|
6
|
+
class AuthGenerator < Base
|
7
|
+
|
8
|
+
desc "This generator generate User lgoin auth code."
|
9
|
+
|
10
|
+
def create_auth_controller
|
11
|
+
template "auth.php", "#{ci_root}/application/controllers/auth.php"
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_auth_model
|
15
|
+
template "auth_model.php", "#{ci_root}/application/models/auth_model.php"
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_auth_view
|
19
|
+
template "login_form.php", "#{ci_root}/application/views/login_form.php"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -1,17 +1,18 @@
|
|
1
|
-
<?php
|
2
|
-
|
1
|
+
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
2
|
+
|
3
|
+
class Auth extends CI_Controller{
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
function __construct(){
|
6
|
+
parent::__construct();
|
7
|
+
// Write your own initialize code
|
8
|
+
}
|
7
9
|
|
8
10
|
function index($message=null){
|
9
11
|
$data = array(
|
10
12
|
'message' => $message
|
11
13
|
);
|
12
14
|
|
13
|
-
$this->load->view('
|
14
|
-
$this->load->view('admin/auth/login_form', $data);
|
15
|
+
$this->load->view('auth/login_form', $data);
|
15
16
|
}
|
16
17
|
|
17
18
|
function login(){
|
@@ -20,7 +21,7 @@ class Auth extends Controller{
|
|
20
21
|
if($login_result !== TRUE)
|
21
22
|
$this->index($login_result);
|
22
23
|
else
|
23
|
-
redirect('
|
24
|
+
redirect('users/dashboard');
|
24
25
|
}
|
25
26
|
|
26
27
|
function logout(){
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
2
|
+
|
3
|
+
class Auth_model extends CI_Model{
|
4
|
+
|
5
|
+
function __construct(){
|
6
|
+
parent::__construct();
|
7
|
+
// Write your own initialize code
|
8
|
+
}
|
9
|
+
|
10
|
+
function doLogin(){
|
11
|
+
$data = array(
|
12
|
+
'username LIKE' => $this->input->post('user'),
|
13
|
+
'pass' => md5($this->input->post('pass'))
|
14
|
+
);
|
15
|
+
|
16
|
+
//check db for valid user/pass pair
|
17
|
+
$row = $this->db->get_where('users', $data)->first_row();
|
18
|
+
|
19
|
+
if($row->id == NULL)
|
20
|
+
return "Invalid username or password.";
|
21
|
+
|
22
|
+
if($row->active != 'on')
|
23
|
+
return "Your account has been suspended. Please <a href='/contact'><u>contact us</u></a> for more info.";
|
24
|
+
|
25
|
+
//set session variables
|
26
|
+
$this->session->set_userdata('user', $row->username);
|
27
|
+
$this->session->set_userdata('displayname', $row->displayname);
|
28
|
+
$this->session->set_userdata('admin', $row->admin);
|
29
|
+
|
30
|
+
//update last login time
|
31
|
+
$this->db->update('users',
|
32
|
+
array('lastlogon'=>date('YmdHis')),
|
33
|
+
array('username LIKE'=>$row->username)
|
34
|
+
);
|
35
|
+
|
36
|
+
return TRUE;
|
37
|
+
}
|
38
|
+
|
39
|
+
function doLogout(){
|
40
|
+
$this->session->sess_destroy();
|
41
|
+
}
|
42
|
+
|
43
|
+
function loggedIn(){
|
44
|
+
$user = $this->session->userdata('user');
|
45
|
+
if($user == null || $user == '')
|
46
|
+
return FALSE;
|
47
|
+
|
48
|
+
define('USER', $user);
|
49
|
+
define('DISPLAYNAME', $this->session->userdata('displayname'));
|
50
|
+
|
51
|
+
return TRUE;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
/* End of file auth_model.php */
|
56
|
+
/* Location: ./application/models/auth_model.php */
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Ci
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
class Base < ::Rails::Generators::Base
|
5
|
+
|
6
|
+
def self.source_root
|
7
|
+
@_ci_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), generator_name, 'templates'))
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def ci_root
|
13
|
+
@ci_root ||= YAML.load_file("config/codeigniter.yml")["path"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -1,13 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "generators/ci/base"
|
3
|
+
|
1
4
|
module Ci
|
2
5
|
module Generators
|
3
|
-
class InstallGenerator <
|
6
|
+
class InstallGenerator < Base
|
4
7
|
|
5
8
|
class_option :version, :type => :string, :aliases => :v, :default => "2.0.0", :desc => "set CodeIgniter version."
|
6
|
-
# class_option :subdir, :type => :string, :aliases => :s, :default => "", :desc => "install CodeIgniter prject into public subdir."
|
7
|
-
|
8
|
-
def self.source_root
|
9
|
-
File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
10
|
-
end
|
9
|
+
# class_option :subdir, :type => :string, :aliases => :s, :default => "", :desc => "install CodeIgniter prject into public subdir."
|
11
10
|
|
12
11
|
desc "This generator generate CodeIgniter project into public/ directory. This is your first step."
|
13
12
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "generators/ci/base"
|
3
|
+
|
4
|
+
module Ci
|
5
|
+
module Generators
|
6
|
+
|
7
|
+
class LayoutGenerator < Base
|
8
|
+
|
9
|
+
class_option :jquery, :type => :boolean, :default => true, :desc => "User jQuery js."
|
10
|
+
argument :layout_name, :type => :string, :default => "application"
|
11
|
+
|
12
|
+
def create_layout
|
13
|
+
template "application_layout.php", "#{ci_root}/application/views/layouts/#{layout_name.underscore}.php"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<div id="header"></div>
|
13
13
|
<div id="content"></div>
|
14
14
|
<div id="footer"></div>
|
15
|
-
<% if
|
15
|
+
<% if options.jquery? -%>
|
16
16
|
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
|
17
17
|
<% end -%>
|
18
18
|
</body>
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 5
|
9
|
+
version: 0.0.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- qichunren
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-21 00:00:00 +08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -43,14 +43,12 @@ files:
|
|
43
43
|
- lib/codeigniter/commands/help.rb
|
44
44
|
- lib/codeigniter/tasks/ci.rake
|
45
45
|
- lib/codeigniter_vender.rb
|
46
|
-
- lib/generators/ci/
|
47
|
-
- lib/generators/ci/
|
48
|
-
- lib/generators/ci/
|
49
|
-
- lib/generators/ci/
|
50
|
-
- lib/generators/ci/
|
51
|
-
- lib/generators/ci/
|
52
|
-
- lib/generators/ci/ci_layout/ci_layout_generator.rb
|
53
|
-
- lib/generators/ci/ci_layout/templates/application_layout.php.erb
|
46
|
+
- lib/generators/ci/auth/USAGE
|
47
|
+
- lib/generators/ci/auth/auth_generator.rb
|
48
|
+
- lib/generators/ci/auth/templates/auth.php
|
49
|
+
- lib/generators/ci/auth/templates/auth_model.php
|
50
|
+
- lib/generators/ci/auth/templates/login_form.php
|
51
|
+
- lib/generators/ci/base.rb
|
54
52
|
- lib/generators/ci/controller/USAGE
|
55
53
|
- lib/generators/ci/controller/controller_generator.rb
|
56
54
|
- lib/generators/ci/controller/templates/controller.php
|
@@ -377,6 +375,9 @@ files:
|
|
377
375
|
- lib/generators/ci/install/templates/CodeIgniterLibs/CodeIgniter_2.0.0/user_guide/userguide.css
|
378
376
|
- lib/generators/ci/install/templates/README
|
379
377
|
- lib/generators/ci/install/templates/config/database.php
|
378
|
+
- lib/generators/ci/layout/USAGE
|
379
|
+
- lib/generators/ci/layout/layout_generator.rb
|
380
|
+
- lib/generators/ci/layout/templates/application_layout.php
|
380
381
|
- lib/generators/ci/model/USAGE
|
381
382
|
- lib/generators/ci/model/model_generator.rb
|
382
383
|
- lib/generators/ci/model/templates/model.php
|
@@ -1,11 +0,0 @@
|
|
1
|
-
class CiAuthGenerator < Rails::Generator::Base
|
2
|
-
|
3
|
-
def manifest
|
4
|
-
record do |m|
|
5
|
-
m.file "auth.php", "public/system/application/controllers/admin/auth.php"
|
6
|
-
m.file "auth_model.php", "public/system/application/models/auth_model.php"
|
7
|
-
m.file "login_form.php", "public/system/application/views/login_form.php"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
class Auth_model extends Model{
|
3
|
-
|
4
|
-
function __contstruct(){
|
5
|
-
parent::Model();
|
6
|
-
//session_start();
|
7
|
-
}
|
8
|
-
|
9
|
-
function doLogin(){
|
10
|
-
$data = array(
|
11
|
-
'username LIKE' => $this->input->post('user'),
|
12
|
-
'pass' => md5($this->input->post('pass'))
|
13
|
-
);
|
14
|
-
|
15
|
-
//check db for valid user/pass pair
|
16
|
-
$row = $this->db->get_where('users', $data)->first_row();
|
17
|
-
|
18
|
-
if($row->id == NULL)
|
19
|
-
return "Invalid username or password.";
|
20
|
-
|
21
|
-
if($row->active != 'on')
|
22
|
-
return "Your account has been suspended. Please <a href='/contact'><u>contact us</u></a> for more info.";
|
23
|
-
|
24
|
-
//set session variables
|
25
|
-
$this->session->set_userdata('user', $row->username);
|
26
|
-
$this->session->set_userdata('displayname', $row->displayname);
|
27
|
-
$this->session->set_userdata('admin', $row->admin);
|
28
|
-
|
29
|
-
//update last login time
|
30
|
-
$this->db->update('users',
|
31
|
-
array('lastlogon'=>date('YmdHis')),
|
32
|
-
array('username LIKE'=>$row->username)
|
33
|
-
);
|
34
|
-
|
35
|
-
return TRUE;
|
36
|
-
}
|
37
|
-
|
38
|
-
function doLogout(){
|
39
|
-
$this->session->sess_destroy();
|
40
|
-
}
|
41
|
-
|
42
|
-
function loggedIn(){
|
43
|
-
$user = $this->session->userdata('user');
|
44
|
-
if($user == null || $user == '')
|
45
|
-
return FALSE;
|
46
|
-
|
47
|
-
define('USER', $user);
|
48
|
-
define('DISPLAYNAME', $this->session->userdata('displayname'));
|
49
|
-
|
50
|
-
return TRUE;
|
51
|
-
}
|
52
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
class CiLayoutGenerator < Rails::Generator::Base
|
2
|
-
|
3
|
-
default_options :use_jquery => false
|
4
|
-
|
5
|
-
def manifest
|
6
|
-
record do |m|
|
7
|
-
m.directory "public/system/application/views/layouts"
|
8
|
-
m.template "application_layout.php.erb", "public/system/application/views/layouts/application_layout.php", :assigns => { :use_jquery => options[:use_jquery] }
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
protected
|
13
|
-
|
14
|
-
def banner
|
15
|
-
"Usage: #{$0} ci_layout [options]"
|
16
|
-
end
|
17
|
-
|
18
|
-
def add_options!(opt)
|
19
|
-
opt.separator ''
|
20
|
-
opt.separator 'Options:'
|
21
|
-
opt.on("--use-jquery", "Use google jquery api") { |v| options[:use_jquery] = true }
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
File without changes
|
File without changes
|
File without changes
|