auser-poolparty 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/CHANGELOG +8 -0
  2. data/README.txt +10 -10
  3. data/Rakefile +30 -21
  4. data/{web/static/site/images → assets}/clouds.png +0 -0
  5. data/bin/instance +39 -34
  6. data/bin/pool +44 -29
  7. data/bin/poolnotify +34 -0
  8. data/config/haproxy.conf +1 -1
  9. data/config/heartbeat_authkeys.conf +1 -1
  10. data/config/monit/haproxy.monit.conf +2 -1
  11. data/config/nginx.conf +1 -1
  12. data/config/reconfigure_instances_script.sh +28 -9
  13. data/config/sample-config.yml +1 -1
  14. data/lib/core/string.rb +3 -0
  15. data/lib/modules/ec2_wrapper.rb +47 -22
  16. data/lib/modules/file_writer.rb +38 -0
  17. data/lib/modules/sprinkle_overrides.rb +32 -0
  18. data/lib/modules/vlad_override.rb +5 -4
  19. data/lib/poolparty.rb +14 -10
  20. data/lib/poolparty/application.rb +33 -19
  21. data/lib/poolparty/master.rb +227 -105
  22. data/lib/poolparty/optioner.rb +8 -4
  23. data/lib/poolparty/plugin.rb +34 -4
  24. data/lib/poolparty/provider/packages/haproxy.rb +0 -15
  25. data/lib/poolparty/provider/packages/heartbeat.rb +1 -1
  26. data/lib/poolparty/provider/packages/ruby.rb +6 -6
  27. data/lib/poolparty/provider/packages/s3fuse.rb +9 -2
  28. data/lib/poolparty/provider/provider.rb +65 -25
  29. data/lib/poolparty/remote_instance.rb +95 -74
  30. data/lib/poolparty/remoter.rb +48 -37
  31. data/lib/poolparty/remoting.rb +41 -17
  32. data/lib/poolparty/scheduler.rb +4 -4
  33. data/lib/poolparty/tasks.rb +1 -1
  34. data/lib/poolparty/tasks/package.rake +53 -0
  35. data/lib/poolparty/tasks/plugins.rake +1 -1
  36. data/poolparty.gemspec +50 -58
  37. data/spec/application_spec.rb +28 -0
  38. data/spec/core_spec.rb +9 -0
  39. data/spec/ec2_wrapper_spec.rb +87 -0
  40. data/spec/file_writer_spec.rb +73 -0
  41. data/spec/files/describe_response +37 -0
  42. data/spec/files/multi_describe_response +69 -0
  43. data/spec/files/remote_desc_response +37 -0
  44. data/spec/helpers/ec2_mock.rb +3 -0
  45. data/spec/master_spec.rb +302 -78
  46. data/spec/monitors/cpu_monitor_spec.rb +2 -1
  47. data/spec/monitors/memory_spec.rb +1 -0
  48. data/spec/monitors/misc_monitor_spec.rb +1 -0
  49. data/spec/monitors/web_spec.rb +1 -0
  50. data/spec/optioner_spec.rb +12 -0
  51. data/spec/plugin_manager_spec.rb +10 -10
  52. data/spec/plugin_spec.rb +6 -3
  53. data/spec/pool_binary_spec.rb +3 -0
  54. data/spec/poolparty_spec.rb +12 -7
  55. data/spec/provider_spec.rb +1 -0
  56. data/spec/remote_instance_spec.rb +18 -18
  57. data/spec/remoter_spec.rb +4 -2
  58. data/spec/remoting_spec.rb +10 -2
  59. data/spec/scheduler_spec.rb +0 -6
  60. data/spec/spec_helper.rb +13 -0
  61. metadata +83 -52
  62. data/Manifest +0 -115
  63. data/lib/poolparty/tmp.rb +0 -46
  64. data/misc/basics_tutorial.txt +0 -142
  65. data/web/static/conf/nginx.conf +0 -22
  66. data/web/static/site/images/balloon.png +0 -0
  67. data/web/static/site/images/cb.png +0 -0
  68. data/web/static/site/images/railsconf_preso_img.png +0 -0
  69. data/web/static/site/index.html +0 -71
  70. data/web/static/site/javascripts/application.js +0 -3
  71. data/web/static/site/javascripts/corner.js +0 -178
  72. data/web/static/site/javascripts/jquery-1.2.6.pack.js +0 -11
  73. data/web/static/site/misc.html +0 -42
  74. data/web/static/site/storage/pool_party_presentation.pdf +0 -0
  75. data/web/static/site/stylesheets/application.css +0 -100
  76. data/web/static/site/stylesheets/reset.css +0 -17
  77. data/web/static/src/layouts/application.haml +0 -25
  78. data/web/static/src/pages/index.haml +0 -25
  79. data/web/static/src/pages/misc.haml +0 -5
  80. data/web/static/src/stylesheets/application.sass +0 -100
data/Manifest DELETED
@@ -1,115 +0,0 @@
1
- archives/ruby-1.8.6-p111.tar.gz
2
- bin/instance
3
- bin/pool
4
- CHANGELOG
5
- config/cloud_master_takeover
6
- config/create_proxy_ami.sh
7
- config/haproxy.conf
8
- config/heartbeat.conf
9
- config/heartbeat_authkeys.conf
10
- config/installers/ubuntu_install.sh
11
- config/monit/haproxy.monit.conf
12
- config/monit/nginx.monit.conf
13
- config/monit.conf
14
- config/nginx.conf
15
- config/reconfigure_instances_script.sh
16
- config/sample-config.yml
17
- config/scp_instances_script.sh
18
- lib/core/array.rb
19
- lib/core/exception.rb
20
- lib/core/float.rb
21
- lib/core/hash.rb
22
- lib/core/kernel.rb
23
- lib/core/module.rb
24
- lib/core/object.rb
25
- lib/core/proc.rb
26
- lib/core/string.rb
27
- lib/core/time.rb
28
- lib/modules/callback.rb
29
- lib/modules/ec2_wrapper.rb
30
- lib/modules/safe_instance.rb
31
- lib/modules/vlad_override.rb
32
- lib/poolparty/application.rb
33
- lib/poolparty/init.rb
34
- lib/poolparty/master.rb
35
- lib/poolparty/monitors/cpu.rb
36
- lib/poolparty/monitors/memory.rb
37
- lib/poolparty/monitors/web.rb
38
- lib/poolparty/monitors.rb
39
- lib/poolparty/optioner.rb
40
- lib/poolparty/plugin.rb
41
- lib/poolparty/plugin_manager.rb
42
- lib/poolparty/provider/packages/essential.rb
43
- lib/poolparty/provider/packages/git.rb
44
- lib/poolparty/provider/packages/haproxy.rb
45
- lib/poolparty/provider/packages/heartbeat.rb
46
- lib/poolparty/provider/packages/monit.rb
47
- lib/poolparty/provider/packages/rsync.rb
48
- lib/poolparty/provider/packages/ruby.rb
49
- lib/poolparty/provider/packages/s3fuse.rb
50
- lib/poolparty/provider/provider.rb
51
- lib/poolparty/provider.rb
52
- lib/poolparty/remote_instance.rb
53
- lib/poolparty/remoter.rb
54
- lib/poolparty/remoting.rb
55
- lib/poolparty/scheduler.rb
56
- lib/poolparty/tasks/cloud.rake
57
- lib/poolparty/tasks/development.rake
58
- lib/poolparty/tasks/ec2.rake
59
- lib/poolparty/tasks/instance.rake
60
- lib/poolparty/tasks/plugins.rake
61
- lib/poolparty/tasks/server.rake
62
- lib/poolparty/tasks.rb
63
- lib/poolparty/tmp.rb
64
- lib/poolparty.rb
65
- lib/s3/s3_object_store_folders.rb
66
- Manifest
67
- misc/basics_tutorial.txt
68
- Rakefile
69
- README.txt
70
- spec/application_spec.rb
71
- spec/callback_spec.rb
72
- spec/core_spec.rb
73
- spec/helpers/ec2_mock.rb
74
- spec/kernel_spec.rb
75
- spec/master_spec.rb
76
- spec/monitors/cpu_monitor_spec.rb
77
- spec/monitors/memory_spec.rb
78
- spec/monitors/misc_monitor_spec.rb
79
- spec/monitors/web_spec.rb
80
- spec/optioner_spec.rb
81
- spec/plugin_manager_spec.rb
82
- spec/plugin_spec.rb
83
- spec/pool_binary_spec.rb
84
- spec/poolparty_spec.rb
85
- spec/provider_spec.rb
86
- spec/remote_instance_spec.rb
87
- spec/remoter_spec.rb
88
- spec/remoting_spec.rb
89
- spec/scheduler_spec.rb
90
- spec/spec_helper.rb
91
- spec/string_spec.rb
92
- tmp/node0-pool-party-ha.cf
93
- tmp/node0-pool-party-haresources
94
- tmp/node0-pool-party-hosts
95
- tmp/node1-pool-party-ha.cf
96
- tmp/node1-pool-party-haresources
97
- tmp/node1-pool-party-hosts
98
- tmp/pool-party-haproxy.cfg
99
- web/static/conf/nginx.conf
100
- web/static/site/images/balloon.png
101
- web/static/site/images/cb.png
102
- web/static/site/images/clouds.png
103
- web/static/site/images/railsconf_preso_img.png
104
- web/static/site/index.html
105
- web/static/site/javascripts/application.js
106
- web/static/site/javascripts/corner.js
107
- web/static/site/javascripts/jquery-1.2.6.pack.js
108
- web/static/site/misc.html
109
- web/static/site/storage/pool_party_presentation.pdf
110
- web/static/site/stylesheets/application.css
111
- web/static/site/stylesheets/reset.css
112
- web/static/src/layouts/application.haml
113
- web/static/src/pages/index.haml
114
- web/static/src/pages/misc.haml
115
- web/static/src/stylesheets/application.sass
data/lib/poolparty/tmp.rb DELETED
@@ -1,46 +0,0 @@
1
- $:.unshift(File.dirname(__FILE__))
2
- require "backcall"
3
- require "remoter"
4
- class Test
5
- include PoolParty::Remoter
6
- include Callbacks
7
-
8
- after :initialize, :set_hosts
9
- def rt
10
- @rt ||= Rake::RemoteTask
11
- end
12
-
13
- def set_hosts(c)
14
- rt.host "myslice", :app, :db
15
- end
16
-
17
- def rtask(name, *args, &block)
18
- rt.remote_task(name.to_sym => args, &block)
19
- end
20
-
21
- def scp local, remote
22
- require "tempfile"
23
- rtask(:scp) do
24
- put remote do
25
- open(local).read
26
- end
27
- end.execute
28
- end
29
- before :scp, :set_hosts
30
- def ssh command=nil, &block
31
- block = Proc.new do
32
- run command
33
- end
34
- rtask(:ssh, &block).execute
35
- end
36
- before :ssh, :set_hosts
37
- end
38
-
39
- t = Test.new
40
- t.scp("/Users/auser/Sites/work/citrusbyte/internal/gems/pool-party/pool/CHANGELOG", "ho")
41
- t.ssh("ls -l")
42
- t.ssh <<-EOE
43
- ls -l
44
- mv ho CHANGELOG
45
- cat CHANGELOG
46
- EOE
@@ -1,142 +0,0 @@
1
- PoolParty, a tutorial.
2
-
3
- To get PoolParty up and running on your very own ec2 instances, you have to do a few things in preparation first.
4
-
5
- First, install the gem with:
6
-
7
- sudo gem install auser-poolparty -s http://gems.github.com
8
-
9
- First, head on over to http://aws.amazon.com and sign up for an account. Make sure you make note of the access key and the secret access key on the access identifiers page. Also, scroll down to the bottom of that page and download your x.509 certificate and the private one as well. You only can generate that once, so make sure you download it immediately. Finally, take note of your account id.
10
-
11
- Now, let's get to some PoolParty setup. PoolParty only requires one file, a configuration file. Once you get this setup, PoolParty will do the rest for you, so let's get started editing the config file.
12
-
13
- There is a generator in progress, so if by the time you read this and you have the gem installed, type
14
-
15
- which poolparty
16
-
17
- If you get a response, then the generator has been built and you can skip this section and go right to the next 'using it' section, however, if not or you just want to understand the innerworkings, read on.
18
-
19
- config/config.yml
20
- PoolParty makes the guess that your config is in a file and is in config/config.yml in your base project directory. However, this is not necessary if you do not want a configuration file, since all options can be added at runtime using switches on the command-line. That being said, the easiest way is to write a config file.
21
-
22
- The minimal config file looks like this:
23
-
24
- :access_key: "1XCTNEK1CC5BQXXXXXXX"
25
- :secret_access_key: "Q2qJHP0S2iOKikn9glB+XXXX/XXXXXXXX/XXXXXXX"
26
- :ami: "ami-3057b259"
27
-
28
- That's it. However,a more complete one would look more like this:
29
-
30
- :app_name: "test_app"
31
- :user_id: "1619-6456-1111"
32
- :access_key: "1XCTNEK1CC5BQXXXXXXX"
33
- :secret_access_key: "Q2qJHP0S2iOKikn9glB+XXXX/XXXXXXXX/XXXXXXX"
34
- :ami: "ami-3057b259"
35
- :size: small
36
- :polling_time: "5.minutes"
37
- :minimum_instances: 2
38
- :maximum_instances: 10
39
- :ec2_dir: "/Users/user/.ec2"
40
- :keypair: user
41
- :os: ubuntu
42
- :host_port: 80
43
- :shared_bucket: "pool-party-app-data"
44
- :environment: production
45
- :contract_when:
46
- web > 10
47
- cpu < 0.2
48
- :expand_when:
49
- cpu > 0.45
50
- web < 10
51
-
52
- Most of it should be self-explanatory, but a few points are necessary to describe. ec2_dir and keypair are for your location development machine. If you didn't create a keypair, not to worry, put in anything here. If you did, it's the name of the keypair you added. This is important for working with the instances after you get them up.
53
-
54
- If you put in a bucket in the shared_bucket key, the instances will automount that bucket to the /data drive. If you leave it out or don't include it, then it won't.
55
-
56
- The master instance takes care of monitoring the cloud for you. If the the parameters you set in the contract_when and expand_when are met, then the cloud will respond accordingly. Those are based on monitors that are included in PoolParty.
57
-
58
- The installation of the required software for PoolParty is taken care of by PoolParty. That being said, PoolParty makes no assumptions of what the cloud's responsibilities will be. See 'Using' later on.
59
-
60
- Monitors
61
- The monitors are flexible and extensible. Currently included in PoolParty are monitors that monitor web requests and cpu and memory percentages. Writing a monitor or a plugin are out of the scope of this tutorial, but will be included in future tutorials.
62
-
63
- Configuring
64
- It can be tedious setting up just your development machine. This is why PoolParty makes it super easy for you in just one rake task.
65
-
66
- If you are not familiar with ruby, I suggest you look into it, it's a beautiful language. However, PoolParty is language-agnostic, so not to worry.
67
-
68
- Create a file in your development directory called Rakefile and add this to it.
69
-
70
- require 'rubygems'
71
- require 'poolparty'
72
-
73
- PoolParty.include_tasks
74
-
75
- That's it, pretty simple and a bunch of tasks are available to you directly!
76
- Your development directory should look like this:
77
-
78
- ./
79
- config/
80
- config.yml
81
- Rakefile
82
-
83
- Now, once you have this setup and your config file setup, you can type
84
-
85
- rake dev:setup
86
-
87
- That's it and you should be able to type ec2-describe-images (provided you have installed the ec2-api-tools, available here: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&categoryID=88) at this point and you are set.
88
-
89
- You will find yourself with a .<keypair_name>_pool_keys file in your home directory. Anytime you want to setup a new cloud or simply check on this one, all you have to do is type:
90
-
91
- source ~/.<keypair_name>_pool_keys
92
-
93
- and your'll be ready to switch over to editing the new cloud.
94
-
95
- Using:
96
- When it's easy to maintain a cloud, it's even easier to use.
97
-
98
- There are two binaries included with PoolParty when you install them. Working with the cloud, you can use the binary: pool. Working with the instance, you can use the binary: instance.
99
-
100
- Start your pool by typing:
101
-
102
- pool start
103
-
104
- It may take a minute. PoolParty is starting your cloud and configuring the master at this point. You may be asked to confirm an ssh connection. This only happens the first time so other pool commands won't ask you again.
105
-
106
- To check on your cloud, simply type:
107
-
108
- pool list
109
-
110
- and you will be presented with the list of your cloud and their roles
111
-
112
- If you want to stop the pool, it's as straightforward as:
113
-
114
- pool stop
115
-
116
- There are a other commands you have available to you on the pool site. If you are hosting your master off-site, rather than on EC2, you can type on the master machine:
117
-
118
- pool maintain
119
-
120
- and it will bootup as the master, watching the other instances in the cloud.
121
-
122
- If you want to log into a specific instance, you can do so with the command:
123
-
124
- instance ssh -i num
125
-
126
- The num is the number in the list from: pool list. It defaults to logging into the master if the number is not supplied.
127
-
128
- You have some more options when working with instances. You can
129
-
130
- instance ssh
131
- instance scp src='' dest=''
132
- instance cmd cmd='ls -la'
133
- instance start|stop|install|restart
134
- instance start_maintain
135
-
136
- The last command will force the instance to become the new master.
137
-
138
- Those are the basics of PoolParty.
139
-
140
- You can check it out at http://poolpartyrb.com/.
141
-
142
- If you are interested in active development, check out the source at github at http://github.com/auser/pool-party/tree/master. Active discussion is held here: http://groups.google.com/group/poolpartyrb. Of course, the latest and greatest information will always be released first at http://blog.citrusbyte.com.
@@ -1,22 +0,0 @@
1
- server {
2
-
3
- listen 80;
4
- server_name www.poolpartyrb.com;
5
- rewrite ^/(.*) http://poolpartyrb.com permanent;
6
- }
7
-
8
-
9
- server {
10
-
11
- listen 80;
12
- server_name poolpartyrb.com;
13
-
14
- access_log /apps/poolpartyrb/logs/access.log;
15
- error_log /apps/poolpartyrb/logs/error.log;
16
-
17
- location / {
18
- root /apps/poolpartyrb;
19
- index index.html;
20
- }
21
-
22
- }
Binary file
Binary file
@@ -1,71 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
- <html>
3
- <head>
4
- <title>PoolParty - Cloud EC2 Computing Made Easy</title>
5
- <link href="/stylesheets/reset.css" media="all" rel="stylesheet" type="text/css"/>
6
- <link href="/stylesheets/application.css" media="all" rel="stylesheet" type="text/css"/>
7
- <script type="text/javascript" src="/javascripts/jquery-1.2.6.pack.js"></script>
8
- <script type="text/javascript" src="/javascripts/corner.js"></script>
9
- <script type="text/javascript" src="/javascripts/application.js"></script>
10
- </head>
11
- <body>
12
- <div class='container'>
13
- <div class='balloon'><img alt="Balloon" src="images/balloon.png"/></div>
14
- <div class='header'>
15
- <h1><a href="/">PoolParty</a></h1>
16
- <div class='clouds'><img alt="Clouds" src="images/clouds.png"/></div>
17
- <div class='links'>
18
- <a href="#">api</a>
19
- <a href="http://poolparty.rubyforge.org/">docs</a>
20
- <a href="misc.html">misc</a>
21
- <a href="#">group</a>
22
- </div>
23
- <div class='clear'>
24
- </div>
25
- </div>
26
- <div class='clear'>
27
- </div>
28
- <div class='content'>
29
- <h2>
30
- One Ruby <strong><a href="http://github.com/auser/pool-party/tree/master">Gem</a></strong> = easy EC2 computing cloud.
31
- </h2>
32
- <div class='tout'>
33
- <p class='alt'>
34
- Amazon's Elastic Compute Cloud provides pay-per-use scalability to the masses. However, clouds do not have innate load-balancing ability, and there is no native failover solution.
35
- </p>
36
- <p class='alt'>
37
- PoolParty is an <strong>open source</strong> tool that <strong>automates</strong> deployment, monitoring, and load balancing of EC2 instances. Configure once, and relax by the poolside -- PoolParty will keep your site and its instances afloat.
38
- </p>
39
- </div>
40
- <p>
41
- "I'm convinced, how do I get started?"
42
- <code>
43
- sudo gem install auser-poolparty -s http://gems.github.com
44
- </code>
45
- </p>
46
- <p>
47
- "Okay, are there examples or documentation?"
48
- <span class='alt'>
49
- <a href="http://poolparty.rubyforge.org/">Docs</a>
50
- &
51
- <a href="#">Examples</a>
52
- </span>
53
- </p>
54
- <p>
55
- "How do I extend it?"
56
- <p class='alt'>
57
- More coming soon
58
- <strong>
59
- <a href='http://github.com/auser/pool-party-plugins/tree/master'>
60
- http://github.com/auser/pool-party-plugins/tree/master
61
- </a>
62
- </strong>
63
- </p>
64
- </p>
65
- </div>
66
- <div class='cb'>
67
- <a href="http://www.citrusbyte.com"><img alt="Cb" src="images/cb.png"/></a>
68
- </div>
69
- </div>
70
- </body>
71
- </html>
@@ -1,3 +0,0 @@
1
- $(document).ready(function() {
2
- $(".content").corner();
3
- });
@@ -1,178 +0,0 @@
1
- /*
2
- * jQuery corner plugin
3
- *
4
- * version 1.92 (12/18/2007)
5
- *
6
- * Dual licensed under the MIT and GPL licenses:
7
- * http://www.opensource.org/licenses/mit-license.php
8
- * http://www.gnu.org/licenses/gpl.html
9
- */
10
-
11
- /**
12
- * The corner() method provides a simple way of styling DOM elements.
13
- *
14
- * corner() takes a single string argument: $().corner("effect corners width")
15
- *
16
- * effect: The name of the effect to apply, such as round or bevel.
17
- * If you don't specify an effect, rounding is used.
18
- *
19
- * corners: The corners can be one or more of top, bottom, tr, tl, br, or bl.
20
- * By default, all four corners are adorned.
21
- *
22
- * width: The width specifies the width of the effect; in the case of rounded corners this
23
- * will be the radius of the width.
24
- * Specify this value using the px suffix such as 10px, and yes it must be pixels.
25
- *
26
- * For more details see: http://methvin.com/jquery/jq-corner.html
27
- * For a full demo see: http://malsup.com/jquery/corner/
28
- *
29
- *
30
- * @example $('.adorn').corner();
31
- * @desc Create round, 10px corners
32
- *
33
- * @example $('.adorn').corner("25px");
34
- * @desc Create round, 25px corners
35
- *
36
- * @example $('.adorn').corner("notch bottom");
37
- * @desc Create notched, 10px corners on bottom only
38
- *
39
- * @example $('.adorn').corner("tr dog 25px");
40
- * @desc Create dogeared, 25px corner on the top-right corner only
41
- *
42
- * @example $('.adorn').corner("round 8px").parent().css('padding', '4px').corner("round 10px");
43
- * @desc Create a rounded border effect by styling both the element and its parent
44
- *
45
- * @name corner
46
- * @type jQuery
47
- * @param String options Options which control the corner style
48
- * @cat Plugins/Corner
49
- * @return jQuery
50
- * @author Dave Methvin (dave.methvin@gmail.com)
51
- * @author Mike Alsup (malsup@gmail.com)
52
- */
53
- (function($) {
54
-
55
- $.fn.corner = function(o) {
56
- var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent);
57
- function sz(el, p) { return parseInt($.css(el,p))||0; };
58
- function hex2(s) {
59
- var s = parseInt(s).toString(16);
60
- return ( s.length < 2 ) ? '0'+s : s;
61
- };
62
- function gpc(node) {
63
- for ( ; node && node.nodeName.toLowerCase() != 'html'; node = node.parentNode ) {
64
- var v = $.css(node,'backgroundColor');
65
- if ( v.indexOf('rgb') >= 0 ) {
66
- if ($.browser.safari && v == 'rgba(0, 0, 0, 0)')
67
- continue;
68
- var rgb = v.match(/\d+/g);
69
- return '#'+ hex2(rgb[0]) + hex2(rgb[1]) + hex2(rgb[2]);
70
- }
71
- if ( v && v != 'transparent' )
72
- return v;
73
- }
74
- return '#ffffff';
75
- };
76
- function getW(i) {
77
- switch(fx) {
78
- case 'round': return Math.round(width*(1-Math.cos(Math.asin(i/width))));
79
- case 'cool': return Math.round(width*(1+Math.cos(Math.asin(i/width))));
80
- case 'sharp': return Math.round(width*(1-Math.cos(Math.acos(i/width))));
81
- case 'bite': return Math.round(width*(Math.cos(Math.asin((width-i-1)/width))));
82
- case 'slide': return Math.round(width*(Math.atan2(i,width/i)));
83
- case 'jut': return Math.round(width*(Math.atan2(width,(width-i-1))));
84
- case 'curl': return Math.round(width*(Math.atan(i)));
85
- case 'tear': return Math.round(width*(Math.cos(i)));
86
- case 'wicked': return Math.round(width*(Math.tan(i)));
87
- case 'long': return Math.round(width*(Math.sqrt(i)));
88
- case 'sculpt': return Math.round(width*(Math.log((width-i-1),width)));
89
- case 'dog': return (i&1) ? (i+1) : width;
90
- case 'dog2': return (i&2) ? (i+1) : width;
91
- case 'dog3': return (i&3) ? (i+1) : width;
92
- case 'fray': return (i%2)*width;
93
- case 'notch': return width;
94
- case 'bevel': return i+1;
95
- }
96
- };
97
- o = (o||"").toLowerCase();
98
- var keep = /keep/.test(o); // keep borders?
99
- var cc = ((o.match(/cc:(#[0-9a-f]+)/)||[])[1]); // corner color
100
- var sc = ((o.match(/sc:(#[0-9a-f]+)/)||[])[1]); // strip color
101
- var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10; // corner width
102
- var re = /round|bevel|notch|bite|cool|sharp|slide|jut|curl|tear|fray|wicked|sculpt|long|dog3|dog2|dog/;
103
- var fx = ((o.match(re)||['round'])[0]);
104
- var edges = { T:0, B:1 };
105
- var opts = {
106
- TL: /top|tl/.test(o), TR: /top|tr/.test(o),
107
- BL: /bottom|bl/.test(o), BR: /bottom|br/.test(o)
108
- };
109
- if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
110
- opts = { TL:1, TR:1, BL:1, BR:1 };
111
- var strip = document.createElement('div');
112
- strip.style.overflow = 'hidden';
113
- strip.style.height = '1px';
114
- strip.style.backgroundColor = sc || 'transparent';
115
- strip.style.borderStyle = 'solid';
116
- return this.each(function(index){
117
- var pad = {
118
- T: parseInt($.css(this,'paddingTop'))||0, R: parseInt($.css(this,'paddingRight'))||0,
119
- B: parseInt($.css(this,'paddingBottom'))||0, L: parseInt($.css(this,'paddingLeft'))||0
120
- };
121
-
122
- if ($.browser.msie) this.style.zoom = 1; // force 'hasLayout' in IE
123
- if (!keep) this.style.border = 'none';
124
- strip.style.borderColor = cc || gpc(this.parentNode);
125
- var cssHeight = $.curCSS(this, 'height');
126
-
127
- for (var j in edges) {
128
- var bot = edges[j];
129
- // only add stips if needed
130
- if ((bot && (opts.BL || opts.BR)) || (!bot && (opts.TL || opts.TR))) {
131
- strip.style.borderStyle = 'none '+(opts[j+'R']?'solid':'none')+' none '+(opts[j+'L']?'solid':'none');
132
- var d = document.createElement('div');
133
- $(d).addClass('jquery-corner');
134
- var ds = d.style;
135
-
136
- bot ? this.appendChild(d) : this.insertBefore(d, this.firstChild);
137
-
138
- if (bot && cssHeight != 'auto') {
139
- if ($.css(this,'position') == 'static')
140
- this.style.position = 'relative';
141
- ds.position = 'absolute';
142
- ds.bottom = ds.left = ds.padding = ds.margin = '0';
143
- if ($.browser.msie)
144
- ds.setExpression('width', 'this.parentNode.offsetWidth');
145
- else
146
- ds.width = '100%';
147
- }
148
- else if (!bot && $.browser.msie) {
149
- if ($.css(this,'position') == 'static')
150
- this.style.position = 'relative';
151
- ds.position = 'absolute';
152
- ds.top = ds.left = ds.right = ds.padding = ds.margin = '0';
153
-
154
- // fix ie6 problem when blocked element has a border width
155
- var bw = 0;
156
- if (ie6 || !$.boxModel)
157
- bw = sz(this,'borderLeftWidth') + sz(this,'borderRightWidth');
158
- ie6 ? ds.setExpression('width', 'this.parentNode.offsetWidth - '+bw+'+ "px"') : ds.width = '100%';
159
- }
160
- else {
161
- ds.margin = !bot ? '-'+pad.T+'px -'+pad.R+'px '+(pad.T-width)+'px -'+pad.L+'px' :
162
- (pad.B-width)+'px -'+pad.R+'px -'+pad.B+'px -'+pad.L+'px';
163
- }
164
-
165
- for (var i=0; i < width; i++) {
166
- var w = Math.max(0,getW(i));
167
- var e = strip.cloneNode(false);
168
- e.style.borderWidth = '0 '+(opts[j+'R']?w:0)+'px 0 '+(opts[j+'L']?w:0)+'px';
169
- bot ? d.appendChild(e) : d.insertBefore(e, d.firstChild);
170
- }
171
- }
172
- }
173
- });
174
- };
175
-
176
- $.fn.uncorner = function(o) { return $('.jquery-corner', this).remove(); };
177
-
178
- })(jQuery);