rsocialize 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +52 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +77 -0
- data/LICENSE +22 -0
- data/README.md +118 -0
- data/Rakefile +8 -0
- data/lib/.rvmrc +52 -0
- data/lib/generators/USAGE +5 -0
- data/lib/generators/rsocialize/install_generator.rb +33 -0
- data/lib/generators/rsocialize/switch_css_generator.rb +17 -0
- data/lib/generators/rsocialize/templates/example1.css +112 -0
- data/lib/generators/rsocialize/templates/example2.css +99 -0
- data/lib/generators/rsocialize/templates/example3.css +48 -0
- data/lib/generators/rsocialize/templates/example5.css +15 -0
- data/lib/generators/rsocialize/templates/example6.css +157 -0
- data/lib/generators/rsocialize/templates/images/example6.png +0 -0
- data/lib/generators/rsocialize/templates/jquery.sharrre-1.3.4.min.js +7 -0
- data/lib/generators/rsocialize/templates/rsocialize.css +0 -0
- data/lib/generators/rsocialize/templates/rsocialize_controller.rb +94 -0
- data/lib/generators/rsocialize/uninstall_generator.rb +24 -0
- data/lib/rsocialize/engine.rb +5 -0
- data/lib/rsocialize/version.rb +3 -0
- data/lib/rsocialize.rb +246 -0
- data/rsocialize.gemspec +28 -0
- data/spec/rsocialize_spec.rb +316 -0
- data/spec/spec_helper.rb +8 -0
- metadata +168 -0
@@ -0,0 +1,157 @@
|
|
1
|
+
/**CSS changelog: **/
|
2
|
+
/** modified the following**/
|
3
|
+
/**1) .sharrre .share span{} background: url modified from "/img/example6.png" to "/assets/example6.png" **/
|
4
|
+
#example6{
|
5
|
+
float:left;
|
6
|
+
margin:5px 27% 0 27%;
|
7
|
+
}
|
8
|
+
.sharrre{
|
9
|
+
margin:55px 0 0 50px;
|
10
|
+
float:left;
|
11
|
+
}
|
12
|
+
|
13
|
+
.sharrre .box{
|
14
|
+
float:left;
|
15
|
+
width:80px;
|
16
|
+
height:75px;
|
17
|
+
-webkit-border-radius:7px;
|
18
|
+
-moz-border-radius:7px;
|
19
|
+
border-radius:7px;
|
20
|
+
-webkit-box-shadow:0 1px 0 #C3C3C3, 0 6px 0 #54a2bc, 0px 2px 3px 0px rgba(47, 58, 61, 0.25), inset 0px 1px 0px 0px rgba(255, 255, 255, 1);
|
21
|
+
-moz-box-shadow:0 1px 0 #C3C3C3, 0 6px 0 #54a2bc, 0px 2px 3px 0px rgba(47, 58, 61, 0.25), inset 0px 1px 0px 0px rgba(255, 255, 255, 1);
|
22
|
+
box-shadow:0 1px 0 #C3C3C3, 0 6px 0 #54a2bc, 0px 2px 3px 0px rgba(47, 58, 61, 0.25), inset 0px 2px 0px 0px rgba(255, 255, 255, 1);
|
23
|
+
background: #dee7ea; /* Old browsers */
|
24
|
+
background: -moz-linear-gradient(top, #dee7ea 0%, #e5eef2 20%, #e5eef2 100%); /* FF3.6+ */
|
25
|
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#dee7ea), color-stop(20%,#e5eef2), color-stop(100%,#e5eef2)); /* Chrome,Safari4+ */
|
26
|
+
background: -webkit-linear-gradient(top, #dee7ea 0%,#e5eef2 20%,#e5eef2 100%); /* Chrome10+,Safari5.1+ */
|
27
|
+
background: -o-linear-gradient(top, #dee7ea 0%,#e5eef2 20%,#e5eef2 100%); /* Opera 11.10+ */
|
28
|
+
background: -ms-linear-gradient(top, #dee7ea 0%,#e5eef2 20%,#e5eef2 100%); /* IE10+ */
|
29
|
+
background: linear-gradient(top, #dee7ea 0%,#e5eef2 20%,#e5eef2 100%); /* W3C */
|
30
|
+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#dee7ea', endColorstr='#e5eef2',GradientType=0 ); /* IE6-9 */
|
31
|
+
}
|
32
|
+
|
33
|
+
#facebook .box{
|
34
|
+
-webkit-box-shadow:0 1px 0 #C3C3C3, 0 6px 0 #28437a, 0px 2px 3px 0px rgba(47, 58, 61, 0.25), inset 0px 1px 0px 0px rgba(255, 255, 255, 1);
|
35
|
+
-moz-box-shadow:0 1px 0 #C3C3C3, 0 6px 0 #28437a, 0px 2px 3px 0px rgba(47, 58, 61, 0.25), inset 0px 1px 0px 0px rgba(255, 255, 255, 1);
|
36
|
+
box-shadow:0 1px 0 #C3C3C3, 0 6px 0 #28437a, 0px 2px 3px 0px rgba(47, 58, 61, 0.25), inset 0px 2px 0px 0px rgba(255, 255, 255, 1);
|
37
|
+
}
|
38
|
+
|
39
|
+
#googleplus .box{
|
40
|
+
-webkit-box-shadow:0 1px 0 #C3C3C3, 0 6px 0 #404040, 0px 2px 3px 0px rgba(47, 58, 61, 0.25), inset 0px 1px 0px 0px rgba(255, 255, 255, 1);
|
41
|
+
-moz-box-shadow:0 1px 0 #C3C3C3, 0 6px 0 #404040, 0px 2px 3px 0px rgba(47, 58, 61, 0.25), inset 0px 1px 0px 0px rgba(255, 255, 255, 1);
|
42
|
+
box-shadow:0 1px 0 #C3C3C3, 0 6px 0 #404040, 0px 2px 3px 0px rgba(47, 58, 61, 0.25), inset 0px 2px 0px 0px rgba(255, 255, 255, 1);
|
43
|
+
}
|
44
|
+
|
45
|
+
.sharrre .box:active, #facebook .box:active, #googleplus .box:active{
|
46
|
+
box-shadow:0 0 3px #333333;
|
47
|
+
margin-top:4px;
|
48
|
+
}
|
49
|
+
|
50
|
+
.sharrre .count, .sharrre .share{
|
51
|
+
display:inline-block;
|
52
|
+
width:78px;
|
53
|
+
text-align:center;
|
54
|
+
font-weight:bold;
|
55
|
+
}
|
56
|
+
|
57
|
+
.sharrre .count{
|
58
|
+
font-size:20px;
|
59
|
+
color:#444444;
|
60
|
+
text-shadow: 0px 1px 0px #ffffff;
|
61
|
+
filter: dropshadow(color=#ffffff, offx=0, offy=1);
|
62
|
+
height:40px;
|
63
|
+
line-height:40px;
|
64
|
+
border:1px solid #b9b9b9;
|
65
|
+
border-width:1px 1px 0 1px;
|
66
|
+
-moz-border-radius-topleft:7px;
|
67
|
+
-moz-border-radius-topright:7px;
|
68
|
+
-moz-border-radius-bottomright:0;
|
69
|
+
-moz-border-radius-bottomleft:0;
|
70
|
+
-webkit-border-radius:7px 7px 0 0;
|
71
|
+
border-radius:7px 7px 0 0;
|
72
|
+
position:relative;
|
73
|
+
}
|
74
|
+
|
75
|
+
.sharrre .count:before, .sharrre .count:after {
|
76
|
+
content:'';
|
77
|
+
display:block;
|
78
|
+
position:absolute;
|
79
|
+
left:49%;
|
80
|
+
width:0;
|
81
|
+
height:0;
|
82
|
+
}
|
83
|
+
.sharrre .count:before {
|
84
|
+
border:solid 7px transparent;
|
85
|
+
border-top-color:#b2c6cc;
|
86
|
+
margin-left:-7px;
|
87
|
+
bottom: -14px;
|
88
|
+
}
|
89
|
+
.sharrre .count:after {
|
90
|
+
border:solid 6px transparent;
|
91
|
+
margin-left:-6px;
|
92
|
+
bottom:-12px;
|
93
|
+
border-top-color:#e5eef2;
|
94
|
+
}
|
95
|
+
|
96
|
+
.sharrre .share{
|
97
|
+
height:34px;
|
98
|
+
line-height:34px;
|
99
|
+
color:#ffffff;
|
100
|
+
font-size:13px;
|
101
|
+
text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.35);
|
102
|
+
filter: dropshadow(color=#d1d1d1, offx=0, offy=1);
|
103
|
+
border:1px solid #6fa4b5;
|
104
|
+
border-width:0 1px 1px 1px;
|
105
|
+
-moz-border-radius-topleft:0;
|
106
|
+
-moz-border-radius-topright:0;
|
107
|
+
-moz-border-radius-bottomright:7px;
|
108
|
+
-moz-border-radius-bottomleft:7px;
|
109
|
+
-webkit-border-radius:0 0 7px 7px;
|
110
|
+
border-radius:0 0 7px 7px;
|
111
|
+
background-color:#7ac5df;
|
112
|
+
-webkit-box-shadow:inset 0px 1px 0px 0px rgba(105, 164, 185, 1), inset 0px -1px 2px 0px rgba(255, 255, 255, 0.6), inset 0px 2px 1px 0px rgba(255, 0, 0, 0.15);
|
113
|
+
-moz-box-shadow:inset 0px 1px 0px 0px rgba(105, 164, 185, 1), inset 0px -1px 2px 0px rgba(255, 255, 255, 0.6), inset 0px 2px 1px 0px rgba(255, 0, 0, 0.15);
|
114
|
+
box-shadow:inset 0px 1px 0px 0px rgba(105, 164, 185, 1), inset 0px -1px 2px 0px rgba(255, 255, 255, 0.6), inset 0px 2px 1px 0px rgba(255, 0, 0, 0.15);
|
115
|
+
}
|
116
|
+
|
117
|
+
.sharrre .share span{
|
118
|
+
background:url("/assets/example6.png") no-repeat scroll 0 0 transparent;
|
119
|
+
width:18px;
|
120
|
+
height:10px;
|
121
|
+
display: inline-block;
|
122
|
+
}
|
123
|
+
|
124
|
+
#facebook .share span{
|
125
|
+
background-position:0 -35px;
|
126
|
+
height:12px;
|
127
|
+
}
|
128
|
+
|
129
|
+
#facebook .share{
|
130
|
+
border-color:#35538f;
|
131
|
+
background: #637fbb; /* Old browsers */
|
132
|
+
background: -moz-linear-gradient(top, #637fbb 0%, #49649e 100%); /* FF3.6+ */
|
133
|
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#637fbb), color-stop(100%,#49649e)); /* Chrome,Safari4+ */
|
134
|
+
background: -webkit-linear-gradient(top, #637fbb 0%,#49649e 100%); /* Chrome10+,Safari5.1+ */
|
135
|
+
background: -o-linear-gradient(top, #637fbb 0%,#49649e 100%); /* Opera 11.10+ */
|
136
|
+
background: -ms-linear-gradient(top, #637fbb 0%,#49649e 100%); /* IE10+ */
|
137
|
+
background: linear-gradient(top, #637fbb 0%,#49649e 100%); /* W3C */
|
138
|
+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#637fbb', endColorstr='#49649e',GradientType=0 ); /* IE6-9 */
|
139
|
+
-webkit-box-shadow:inset 0px 1px 0px 0px rgba(74, 95, 138, 1), inset 0px -1px 2px 0px rgba(255, 255, 255, 0.4), inset 0px 2px 1px 0px rgba(255, 0, 0, 0.15);
|
140
|
+
-moz-box-shadow:inset 0px 1px 0px 0px rgba(74, 95, 138, 1), inset 0px -1px 2px 0px rgba(255, 255, 255, 0.4), inset 0px 2px 1px 0px rgba(255, 0, 0, 0.15);
|
141
|
+
box-shadow:inset 0px 1px 0px 0px rgba(74, 95, 138, 1), inset 0px -1px 2px 0px rgba(255, 255, 255, 0.4), inset 0px 2px 1px 0px rgba(255, 0, 0, 0.15);
|
142
|
+
}
|
143
|
+
|
144
|
+
#googleplus .share{
|
145
|
+
border-color:#303030;
|
146
|
+
background: #626263; /* Old browsers */
|
147
|
+
background: -moz-linear-gradient(top, #626263 0%, #424244 100%); /* FF3.6+ */
|
148
|
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#626263), color-stop(100%,#424244)); /* Chrome,Safari4+ */
|
149
|
+
background: -webkit-linear-gradient(top, #626263 0%,#424244 100%); /* Chrome10+,Safari5.1+ */
|
150
|
+
background: -o-linear-gradient(top, #626263 0%,#424244 100%); /* Opera 11.10+ */
|
151
|
+
background: -ms-linear-gradient(top, #626263 0%,#424244 100%); /* IE10+ */
|
152
|
+
background: linear-gradient(top, #626263 0%,#424244 100%); /* W3C */
|
153
|
+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#626263', endColorstr='#424244',GradientType=0 ); /* IE6-9 */
|
154
|
+
-webkit-box-shadow:inset 0px 1px 0px 0px rgba(74, 95, 138, 1), inset 0px -1px 2px 0px rgba(255, 255, 255, 0.4), inset 0px 2px 1px 0px rgba(255, 0, 0, 0.15);
|
155
|
+
-moz-box-shadow:inset 0px 1px 0px 0px rgba(74, 95, 138, 1), inset 0px -1px 2px 0px rgba(255, 255, 255, 0.4), inset 0px 2px 1px 0px rgba(255, 0, 0, 0.15);
|
156
|
+
box-shadow:inset 0px 1px 0px 0px rgba(74, 95, 138, 1), inset 0px -1px 2px 0px rgba(255, 255, 255, 0.4), inset 0px 2px 1px 0px rgba(255, 0, 0, 0.15);
|
157
|
+
}
|
Binary file
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*
|
2
|
+
* Sharrre.com - Make your sharing widget!
|
3
|
+
* Version: beta 1.3.4
|
4
|
+
* Author: Julien Hany
|
5
|
+
* License: MIT http://en.wikipedia.org/wiki/MIT_License or GPLv2 http://en.wikipedia.org/wiki/GNU_General_Public_License
|
6
|
+
*/
|
7
|
+
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(6($,g,h,i){l j=\'1Y\',23={3i:\'1Y\',L:{O:C,E:C,z:C,I:C,p:C,K:C,N:C,B:C},2a:0,18:\'\',12:\'\',3:h.3h.1a,x:h.12,1p:\'1Y.3d\',y:{},1q:0,1w:w,3c:w,3b:w,2o:C,1X:6(){},38:6(){},1P:6(){},26:6(){},8:{O:{3:\'\',15:C,1j:\'37\',13:\'35-4Y\',2p:\'\'},E:{3:\'\',15:C,R:\'1L\',11:\'4V\',H:\'\',1A:\'C\',2c:\'C\',2d:\'\',1B:\'\',13:\'4R\'},z:{3:\'\',15:C,y:\'33\',2m:\'\',16:\'\',1I:\'\',13:\'35\'},I:{3:\'\',15:C,Q:\'4K\'},p:{3:\'\',15:C,1j:\'37\'},K:{3:\'\',15:C,11:\'1\'},N:{3:\'\',15:C,22:\'\'},B:{3:\'\',1s:\'\',1C:\'\',11:\'33\'}}},1n={O:"",E:"1D://4J.E.o/4x?q=4u%2X,%4j,%4i,%4h,%4f,%4e,46,%45,%44%42%41%40%2X=%27{3}%27&1y=?",z:"S://3W.3P.z.o/1/3D/y.2G?3={3}&1y=?",I:"S://3l.I.o/2.0/5a.59?54={3}&Q=1c&1y=?",p:\'S://52.p.o/4Q/2G/4B/m?3={3}&1y=?\',K:"",N:"S://1o.N.o/4z/y/L?4r=4o&3={3}&1y=?",B:""},2A={O:6(b){l c=b.4.8.O;$(b.r).X(\'.8\').Z(\'<n G="U 4d"><n G="g-25" m-1j="\'+c.1j+\'" m-1a="\'+(c.3!==\'\'?c.3:b.4.3)+\'" m-2p="\'+c.2p+\'"></n></n>\');g.3Z={13:b.4.8.O.13};l d=0;9(A 2x===\'F\'&&d==0){d=1;(6(){l a=h.1g(\'P\');a.Q=\'x/1c\';a.1r=w;a.17=\'//3w.2w.o/Y/25.Y\';l s=h.1d(\'P\')[0];s.1e.1f(a,s)})()}J{2x.25.3X()}},E:6(c){l e=c.4.8.E;$(c.r).X(\'.8\').Z(\'<n G="U E"><n 2T="1V-47"></n><n G="1V-1L" m-1a="\'+(e.3!==\'\'?e.3:c.4.3)+\'" m-1A="\'+e.1A+\'" m-11="\'+e.11+\'" m-H="\'+e.H+\'" m-3u-2c="\'+e.2c+\'" m-R="\'+e.R+\'" m-2d="\'+e.2d+\'" m-1B="\'+e.1B+\'" m-16="\'+e.16+\'"></n></n>\');l f=0;9(A 1i===\'F\'&&f==0){f=1;(6(d,s,a){l b,2s=d.1d(s)[0];9(d.3x(a)){1v}b=d.1g(s);b.2T=a;b.17=\'//4c.E.4n/\'+e.13+\'/4t.Y#4C=1\';2s.1e.1f(b,2s)}(h,\'P\',\'E-5g\'))}J{1i.3n.3p()}},z:6(b){l c=b.4.8.z;$(b.r).X(\'.8\').Z(\'<n G="U z"><a 1a="1D://z.o/L" G="z-L-U" m-3="\'+(c.3!==\'\'?c.3:b.4.3)+\'" m-y="\'+c.y+\'" m-x="\'+b.4.x+\'" m-16="\'+c.16+\'" m-2m="\'+c.2m+\'" m-1I="\'+c.1I+\'" m-13="\'+c.13+\'">3q</a></n>\');l d=0;9(A 2j===\'F\'&&d==0){d=1;(6(){l a=h.1g(\'P\');a.Q=\'x/1c\';a.1r=w;a.17=\'//1M.z.o/1N.Y\';l s=h.1d(\'P\')[0];s.1e.1f(a,s)})()}J{$.3C({3:\'//1M.z.o/1N.Y\',3E:\'P\',3F:w})}},I:6(a){l b=a.4.8.I;$(a.r).X(\'.8\').Z(\'<n G="U I"><a G="3H \'+b.Q+\'" 3L="3U 3V" 1a="S://I.o/2y?3=\'+V((b.3!==\'\'?b.3:a.4.3))+\'"></a></n>\');l c=0;9(A 43===\'F\'&&c==0){c=1;(6(){l s=h.1g(\'2z\'),24=h.1d(\'2z\')[0];s.Q=\'x/1c\';s.1r=w;s.17=\'//1N.I.o/8.Y\';24.1e.1f(s,24)})()}},p:6(a){9(a.4.8.p.1j==\'4g\'){l b=\'H:2r;\',2e=\'D:2B;H:2r;1B-1j:4y;1t-D:2B;\',2l=\'D:2C;1t-D:2C;2k-50:1H;\'}J{l b=\'H:53;\',2e=\'2g:58;2f:0 1H;D:1u;H:5c;1t-D:1u;\',2l=\'2g:5d;D:1u;1t-D:1u;\'}l c=a.1w(a.4.y.p);9(A c==="F"){c=0}$(a.r).X(\'.8\').Z(\'<n G="U p"><n 1T="\'+b+\'1B:5i 5j,5k,5l-5n;5t:3k;1S:#3m;2D:3o-2E;2g:2F;D:1u;1t-D:3r;2k:0;2f:0;x-3s:0;3t-2b:3v;">\'+\'<n 1T="\'+2e+\'2H-1S:#2I;2k-3y:3z;3A:3B;x-2b:2J;1O:2K 2L #3G;1O-2M:1H;">\'+c+\'</n>\'+\'<n 1T="\'+2l+\'2D:2E;2f:0;x-2b:2J;x-3I:2F;H:2r;2H-1S:#3J;1O:2K 2L #3K;1O-2M:1H;1S:#2I;">\'+\'<2N 17="S://1o.p.o/3M/2N/p.3N.3O" D="10" H="10" 3Q="3R" /> 3S</n></n></n>\');$(a.r).X(\'.p\').3T(\'1P\',6(){a.2O(\'p\')})},K:6(b){l c=b.4.8.K;$(b.r).X(\'.8\').Z(\'<n G="U K"><2P:28 11="\'+c.11+\'" 3h="\'+(c.3!==\'\'?c.3:b.4.3)+\'"></2P:28></n>\');l d=0;9(A 1E===\'F\'&&d==0){d=1;(6(){l a=h.1g(\'P\');a.Q=\'x/1c\';a.1r=w;a.17=\'//1M.K.o/1/1N.Y\';l s=h.1d(\'P\')[0];s.1e.1f(a,s)})();s=g.3Y(6(){9(A 1E!==\'F\'){1E.2Q();21(s)}},20)}J{1E.2Q()}},N:6(b){l c=b.4.8.N;$(b.r).X(\'.8\').Z(\'<n G="U N"><P Q="1Z/L" m-3="\'+(c.3!==\'\'?c.3:b.4.3)+\'" m-22="\'+c.22+\'"></P></n>\');l d=0;9(A g.2R===\'F\'&&d==0){d=1;(6(){l a=h.1g(\'P\');a.Q=\'x/1c\';a.1r=w;a.17=\'//1M.N.o/1Z.Y\';l s=h.1d(\'P\')[0];s.1e.1f(a,s)})()}J{g.2R.1W()}},B:6(b){l c=b.4.8.B;$(b.r).X(\'.8\').Z(\'<n G="U B"><a 1a="S://B.o/1K/2u/U/?3=\'+(c.3!==\'\'?c.3:b.4.3)+\'&1s=\'+c.1s+\'&1C=\'+c.1C+\'" G="1K-3j-U" y-11="\'+c.11+\'">48 49</a></n>\');(6(){l a=h.1g(\'P\');a.Q=\'x/1c\';a.1r=w;a.17=\'//4a.B.o/Y/4b.Y\';l s=h.1d(\'P\')[0];s.1e.1f(a,s)})()}},2S={O:6(){},E:6(){1V=g.2v(6(){9(A 1i!==\'F\'){1i.2t.2q(\'2U.2u\',6(a){1m.1l([\'1k\',\'E\',\'1L\',a])});1i.2t.2q(\'2U.4k\',6(a){1m.1l([\'1k\',\'E\',\'4l\',a])});1i.2t.2q(\'4m.1A\',6(a){1m.1l([\'1k\',\'E\',\'1A\',a])});21(1V)}},2V)},z:6(){2W=g.2v(6(){9(A 2j!==\'F\'){2j.4p.4q(\'1J\',6(a){9(a){1m.1l([\'1k\',\'z\',\'1J\'])}});21(2W)}},2V)},I:6(){},p:6(){},K:6(){},N:6(){6 4s(){1m.1l([\'1k\',\'N\',\'L\'])}},B:6(){}},2Y={O:6(a){g.19("1D://4v.2w.o/L?4w="+a.8.O.13+"&3="+V((a.8.O.3!==\'\'?a.8.O.3:a.3)),"","1b=0, 1G=0, H=2Z, D=20")},E:6(a){g.19("S://1o.E.o/30/30.3d?u="+V((a.8.E.3!==\'\'?a.8.E.3:a.3))+"&t="+a.x+"","","1b=0, 1G=0, H=2Z, D=20")},z:6(a){g.19("1D://z.o/4A/1J?x="+V(a.x)+"&3="+V((a.8.z.3!==\'\'?a.8.z.3:a.3))+(a.8.z.16!==\'\'?\'&16=\'+a.8.z.16:\'\'),"","1b=0, 1G=0, H=31, D=32")},I:6(a){g.19("S://I.o/4D/4E/2y?3="+V((a.8.I.3!==\'\'?a.8.I.3:a.3))+"&12="+a.x+"&1I=w&1T=w","","1b=0, 1G=0, H=31, D=32")},p:6(a){g.19(\'S://1o.p.o/4F?v=5&4G&4H=4I&3=\'+V((a.8.p.3!==\'\'?a.8.p.3:a.3))+\'&12=\'+a.x,\'p\',\'1b=1F,H=1h,D=1h\')},K:6(a){g.19(\'S://1o.K.o/28/?3=\'+V((a.8.p.3!==\'\'?a.8.p.3:a.3)),\'K\',\'1b=1F,H=1h,D=1h\')},N:6(a){g.19(\'1D://1o.N.o/4L/L?3=\'+V((a.8.p.3!==\'\'?a.8.p.3:a.3))+\'&4M=&4N=w\',\'N\',\'1b=1F,H=1h,D=1h\')},B:6(a){g.19(\'S://B.o/1K/2u/U/?3=\'+V((a.8.B.3!==\'\'?a.8.B.3:a.3))+\'&1s=\'+V(a.8.B.1s)+\'&1C=\'+a.8.B.1C,\'B\',\'1b=1F,H=4O,D=4P\')}};6 T(a,b){7.r=a;7.4=$.4S(w,{},23,b);7.4.L=b.L;7.4T=23;7.4U=j;7.1W()};T.W.1W=6(){l c=7;9(7.4.1p!==\'\'){1n.O=7.4.1p+\'?3={3}&Q=O\';1n.K=7.4.1p+\'?3={3}&Q=K\';1n.B=7.4.1p+\'?3={3}&Q=B\'}$(7.r).4W(7.4.3i);9(A $(7.r).m(\'12\')!==\'F\'){7.4.12=$(7.r).4X(\'m-12\')}9(A $(7.r).m(\'3\')!==\'F\'){7.4.3=$(7.r).m(\'3\')}9(A $(7.r).m(\'x\')!==\'F\'){7.4.x=$(7.r).m(\'x\')}$.1z(7.4.L,6(a,b){9(b===w){c.4.2a++}});9(c.4.3b===w){$.1z(7.4.L,6(a,b){9(b===w){4Z{c.34(a)}51(e){}}})}J 9(c.4.18!==\'\'){7.4.26(7,7.4)}J{7.2n()}$(7.r).1X(6(){9($(7).X(\'.8\').36===0&&c.4.3c===w){c.2n()}c.4.1X(c,c.4)},6(){c.4.38(c,c.4)});$(7.r).1P(6(){c.4.1P(c,c.4);1v C})};T.W.2n=6(){l c=7;$(7.r).Z(\'<n G="8"></n>\');$.1z(c.4.L,6(a,b){9(b==w){2A[a](c);9(c.4.2o===w){2S[a]()}}})};T.W.34=6(c){l d=7,y=0,3=1n[c].1x(\'{3}\',V(7.4.3));9(7.4.8[c].15===w&&7.4.8[c].3!==\'\'){3=1n[c].1x(\'{3}\',7.4.8[c].3)}9(3!=\'\'&&d.4.1p!==\'\'){$.55(3,6(a){9(A a.y!=="F"){l b=a.y+\'\';b=b.1x(\'\\56\\57\',\'\');y+=1Q(b,10)}J 9(a.m&&a.m.36>0&&A a.m[0].39!=="F"){y+=1Q(a.m[0].39,10)}J 9(A a.3a!=="F"){y+=1Q(a.3a,10)}J 9(A a[0]!=="F"){y+=1Q(a[0].5b,10)}J 9(A a[0]!=="F"){}d.4.y[c]=y;d.4.1q+=y;d.2i();d.1R()}).5e(6(){d.4.y[c]=0;d.1R()})}J{d.2i();d.4.y[c]=0;d.1R()}};T.W.1R=6(){l a=0;5f(e 1Z 7.4.y){a++}9(a===7.4.2a){7.4.26(7,7.4)}};T.W.2i=6(){l a=7.4.1q,18=7.4.18;9(7.4.1w===w){a=7.1w(a)}9(18!==\'\'){18=18.1x(\'{1q}\',a);$(7.r).1U(18)}J{$(7.r).1U(\'<n G="5h"><a G="y" 1a="#">\'+a+\'</a>\'+(7.4.12!==\'\'?\'<a G="L" 1a="#">\'+7.4.12+\'</a>\':\'\')+\'</n>\')}};T.W.1w=6(a){9(a>=3e){a=(a/3e).3f(2)+"M"}J 9(a>=3g){a=(a/3g).3f(1)+"k"}1v a};T.W.2O=6(a){2Y[a](7.4);9(7.4.2o===w){l b={O:{14:\'5m\',R:\'+1\'},E:{14:\'E\',R:\'1L\'},z:{14:\'z\',R:\'1J\'},I:{14:\'I\',R:\'29\'},p:{14:\'p\',R:\'29\'},K:{14:\'K\',R:\'29\'},N:{14:\'N\',R:\'L\'},B:{14:\'B\',R:\'1K\'}};1m.1l([\'1k\',b[a].14,b[a].R])}};T.W.5o=6(){l a=$(7.r).1U();$(7.r).1U(a.1x(7.4.1q,7.4.1q+1))};T.W.5p=6(a,b){9(a!==\'\'){7.4.3=a}9(b!==\'\'){7.4.x=b}};$.5q[j]=6(b){l c=5r;9(b===i||A b===\'5s\'){1v 7.1z(6(){9(!$.m(7,\'2h\'+j)){$.m(7,\'2h\'+j,5u T(7,b))}})}J 9(A b===\'5v\'&&b[0]!==\'5w\'&&b!==\'1W\'){1v 7.1z(6(){l a=$.m(7,\'2h\'+j);9(a 5x T&&A a[b]===\'6\'){a[b].5y(a,5z.W.5A.5B(c,1))}})}}})(5C,5D,5E);',62,351,'|||url|options||function|this|buttons|if||||||||||||var|data|div|com|delicious||element|||||true|text|count|twitter|typeof|pinterest|false|height|facebook|undefined|class|width|digg|else|stumbleupon|share||linkedin|googlePlus|script|type|action|http|Plugin|button|encodeURIComponent|prototype|find|js|append||layout|title|lang|site|urlCount|via|src|template|open|href|toolbar|javascript|getElementsByTagName|parentNode|insertBefore|createElement|550|FB|size|_trackSocial|push|_gaq|urlJson|www|urlCurl|total|async|media|line|20px|return|shorterTotal|replace|callback|each|send|font|description|https|STMBLPN|no|status|3px|related|tweet|pin|like|platform|widgets|border|click|parseInt|rendererPerso|color|style|html|fb|init|hover|sharrre|in|500|clearInterval|counter|defaults|s1|plusone|render||badge|add|shareTotal|align|faces|colorscheme|cssCount|padding|float|plugin_|renderer|twttr|margin|cssShare|hashtags|loadButtons|enableTracking|annotation|subscribe|50px|fjs|Event|create|setInterval|google|gapi|submit|SCRIPT|loadButton|35px|18px|display|block|none|json|background|fff|center|1px|solid|radius|img|openPopup|su|processWidgets|IN|tracking|id|edge|1000|tw|20url|popup|900|sharer|650|360|horizontal|getSocialJson|en|length|medium|hide|total_count|shares|enableCounter|enableHover|php|1e6|toFixed|1e3|location|className|it|pointer|services|666666|XFBML|inline|parse|Tweet|normal|indent|vertical|show|baseline|apis|getElementById|bottom|5px|overflow|hidden|ajax|urls|dataType|cache|ccc|DiggThisButton|decoration|7EACEE|40679C|rel|static|small|gif|api|alt|Delicious|Add|on|nofollow|external|cdn|go|setTimeout|___gcfg|20WHERE|20link_stat|20FROM|__DBW|20click_count|20comments_fbid|commentsbox_count|root|Pin|It|assets|pinit|connect|googleplus|20total_count|20comment_count|tall|20like_count|20share_count|20normalized_url|remove|unlike|message|net|jsonp|events|bind|format|LinkedInShare|all|SELECT|plus|hl|fql|15px|countserv|intent|urlinfo|xfbml|tools|diggthis|save|noui|jump|close|graph|DiggCompact|cws|token|isFramed|700|300|v2|en_US|extend|_defaults|_name|button_count|addClass|attr|US|try|top|catch|feeds|93px|links|getJSON|u00c2|u00a0|right|getInfo|story|total_posts|26px|left|error|for|jssdk|box|12px|Arial|Helvetica|sans|Google|serif|simulateClick|update|fn|arguments|object|cursor|new|string|_|instanceof|apply|Array|slice|call|jQuery|window|document'.split('|'),0,{}))
|
File without changes
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'curb'
|
6
|
+
require 'active_support' #for json decode/encode
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'rsocialize'
|
9
|
+
|
10
|
+
class RsocializeController < ApplicationController
|
11
|
+
|
12
|
+
def sharrre
|
13
|
+
$_GET = Hash.new
|
14
|
+
#$_GET['url'] = 'http://sharrre.com/' ##In PHP, the predefined $_GET variable is used to collect values in a form with method="get".
|
15
|
+
$_GET['url'] = params[:url]
|
16
|
+
$_GET['type'] = params[:type]
|
17
|
+
#source: http://www.rubyinside.com/nethttp-cheat-sheet-2940.html
|
18
|
+
uri = URI.parse($_GET['url'])
|
19
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
20
|
+
|
21
|
+
@json = {'url'=>'','count'=>0}
|
22
|
+
@json['url'] = $_GET['url'];
|
23
|
+
@url = CGI::escape($_GET['url']);
|
24
|
+
@type = CGI::escape($_GET['type']);
|
25
|
+
#Get HTTP response code
|
26
|
+
response = Net::HTTP.get_response(uri)
|
27
|
+
if(response.code=="200") ##need to make this FILTER_VALIDATE_URL equivalent in ruby
|
28
|
+
if (@type == 'googlePlus')
|
29
|
+
@content = parse("https://plusone.google.com/u/0/_/+1/fastbutton?url="+"#{@url}"+"&count=true");
|
30
|
+
doc = Nokogiri::HTML(open("https://plusone.google.com/u/0/_/+1/fastbutton?url="+"#{@url}"+"&count=true"))
|
31
|
+
doc.xpath("//div[@id='aggregateCount']").each do |node|
|
32
|
+
@json['count'] = node.content #only one item returned, so it'd be great to not have to iterate
|
33
|
+
end
|
34
|
+
elsif (@type == 'stumbleupon')
|
35
|
+
@content = parse("http://www.stumbleupon.com/services/1.01/badge.getinfo?url=#{@url}");
|
36
|
+
@result = ActiveSupport::JSON.decode(@content.body_str) #json_decode takes a JSON encoded string and converts it into a PHP variable.
|
37
|
+
@json['count'] = @result['result']['views']
|
38
|
+
@json['count'] = 0 if @json['count'].nil?
|
39
|
+
elsif (@type == 'pinterest')
|
40
|
+
@content = parse("http://api.pinterest.com/v1/urls/count.json?callback=&url=#{@url}");
|
41
|
+
@result = ActiveSupport::JSON.decode(@content.body_str.gsub(/[()]/,""))
|
42
|
+
@json['count'] = @result['count']
|
43
|
+
@json['count'] = 0 if (@json['count'].nil?||@json['count']=="-")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
#@json => {"url"=>"http://www.google.com/", "count"=>"1.5M"}
|
47
|
+
#@return_json = ActiveSupport::JSON.encode(@json)
|
48
|
+
#=> "{\"url\":\"http://www.google.com/\",\"count\":\"1.5M\"}"
|
49
|
+
# respond_to do |format|
|
50
|
+
# format.json { render json: @return_json }
|
51
|
+
# end
|
52
|
+
render :json=>@json
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse(encUrl)
|
56
|
+
#curb method docs for curl::Easy: http://curb.rubyforge.org/classes/Curl/Easy.html#M000038
|
57
|
+
@options = Hash.new
|
58
|
+
|
59
|
+
#curl_setopt() constants in php: http://www.php.net/manual/en/function.curl-setopt.php for translation in ruby below
|
60
|
+
@options = {
|
61
|
+
:CURLOPT_RETURNTRANSFER => true, #// return web page #TRUE to return the transfer as a string of the return value of php curl_exec() instead of outputting it out directly.
|
62
|
+
:CURLOPT_HEADER => false, #// don't return headers #TRUE to include the header in the output.
|
63
|
+
:CURLOPT_FOLLOWLOCATION => true, #// follow redirects
|
64
|
+
:CURLOPT_ENCODING => "", #// handle all encodings
|
65
|
+
:CURLOPT_USERAGENT => 'sharrre', #// who am i
|
66
|
+
:CURLOPT_AUTOREFERER => true, #// set referer on redirect
|
67
|
+
:CURLOPT_CONNECTTIMEOUT => 5, #// timeout on connect
|
68
|
+
:CURLOPT_TIMEOUT => 10, #// timeout on response
|
69
|
+
:CURLOPT_MAXREDIRS => 3, #// stop after 10 redirects
|
70
|
+
:CURLOPT_SSL_VERIFYHOST => false,
|
71
|
+
:CURLOPT_SSL_VERIFYPEER => false,
|
72
|
+
}
|
73
|
+
|
74
|
+
@options[:CURLOPT_URL] = encUrl
|
75
|
+
@content= Curl::Easy.http_get(@options[:CURLOPT_URL]) do |curl|
|
76
|
+
#curl.returntransfer = ?????
|
77
|
+
curl.head = @options[:CURLOPT_HEADER] #??? #not sure if it's headers
|
78
|
+
curl.follow_location = @options[:CURLOPT_FOLLOWLOCATION]
|
79
|
+
curl.encoding = @options[:CURLOPT_ENCODING]
|
80
|
+
curl.useragent = @options[:CURLOPT_USERAGENT]
|
81
|
+
curl.autoreferer = @options[:CURLOPT_AUTOREFERER]
|
82
|
+
curl.connect_timeout = @options[:CURLOPT_CONNECTTIMEOUT]
|
83
|
+
curl.timeout = @options[:CURLOPT_TIMEOUT]
|
84
|
+
curl.max_redirects = @options[:CURLOPT_MAXREDIRS]
|
85
|
+
curl.ssl_verify_host = @options[:CURLOPT_SSL_VERIFYHOST]
|
86
|
+
curl.ssl_verify_peer = @options[:CURLOPT_SSL_VERIFYPEER]
|
87
|
+
end
|
88
|
+
|
89
|
+
#NOTE: may need to add error handling for curl
|
90
|
+
|
91
|
+
return @content;
|
92
|
+
end
|
93
|
+
|
94
|
+
end #Rsocialize
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
module Rsocialize
|
3
|
+
class UninstallGenerator < Rails::Generators::Base
|
4
|
+
#rails g rsocialize:uninstall
|
5
|
+
def self.source_root
|
6
|
+
@_rsocialize_root ||= File.expand_path("../templates", __FILE__)
|
7
|
+
end
|
8
|
+
def destroy_layout
|
9
|
+
remove_file 'app/assets/stylesheets/example1css.txt'
|
10
|
+
remove_file 'app/assets/stylesheets/example2css.txt'
|
11
|
+
remove_file 'app/assets/stylesheets/example3css.txt'
|
12
|
+
remove_file 'app/assets/stylesheets/example5css.txt'
|
13
|
+
remove_file 'app/assets/stylesheets/example6css.txt'
|
14
|
+
remove_file 'app/assets/stylesheets/rsocialize.css'
|
15
|
+
remove_file %Q{app/assets/javascripts/#{Rsocialize::JQUERY_SHARRRE_FILE}}
|
16
|
+
remove_file 'app/lib/rsocialize_controller.rb'
|
17
|
+
remove_file 'app/assets/images'
|
18
|
+
end
|
19
|
+
def unmodify_routes
|
20
|
+
line = %Q{match '/sharrre' => 'Rsocialize#sharrre'}
|
21
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(line)})/mi,''
|
22
|
+
end
|
23
|
+
end #class UninstallGenerator
|
24
|
+
end
|
data/lib/rsocialize.rb
ADDED
@@ -0,0 +1,246 @@
|
|
1
|
+
require "rsocialize/version"
|
2
|
+
require "action_view"
|
3
|
+
module Rsocialize
|
4
|
+
require 'rsocialize/engine' if defined?(Rails)
|
5
|
+
JQUERY_SHARRRE_FILE = "jquery.sharrre-1.3.4.min.js"
|
6
|
+
EXAMPLE1_JS_OPTIONS = {
|
7
|
+
:twitter=>{:share=>{:twitter=>true},:enableHover=>false, :enableTracking=>true, :buttons=>{:twitter=>{:via=>'_JulienH'}},:click=>%Q[function(api, options){
|
8
|
+
api.simulateClick();
|
9
|
+
api.openPopup('twitter');} ]
|
10
|
+
},
|
11
|
+
:facebook=>{:share=>{:facebook=>true}, :enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
|
12
|
+
api.simulateClick();
|
13
|
+
api.openPopup('facebook');}
|
14
|
+
]
|
15
|
+
},
|
16
|
+
:googlePlus=>{:share=>{:googlePlus=>true},:enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
|
17
|
+
api.simulateClick();
|
18
|
+
api.openPopup('googlePlus');} ]
|
19
|
+
}
|
20
|
+
}
|
21
|
+
EXAMPLE2_JS_OPTIONS = {
|
22
|
+
shareme: {
|
23
|
+
share: {
|
24
|
+
twitter: true,
|
25
|
+
facebook: true,
|
26
|
+
googlePlus: true
|
27
|
+
},
|
28
|
+
template: %Q{<div class="box"><div class="left">Share</div><div class="middle"><a href="#" class="facebook">f</a><a href="#" class="twitter">t</a><a href="#" class="googleplus">+1</a></div><div class="right">{total}</div></div>},
|
29
|
+
enableHover: false,
|
30
|
+
enableTracking: true,
|
31
|
+
render: %Q[function(api, options){
|
32
|
+
$(api.element).on('click', '.twitter', function() {
|
33
|
+
api.openPopup('twitter');
|
34
|
+
});
|
35
|
+
$(api.element).on('click', '.facebook', function() {
|
36
|
+
api.openPopup('facebook');
|
37
|
+
});
|
38
|
+
$(api.element).on('click', '.googleplus', function() {
|
39
|
+
api.openPopup('googlePlus');
|
40
|
+
});
|
41
|
+
}]
|
42
|
+
}
|
43
|
+
}
|
44
|
+
EXAMPLE3_JS_OPTIONS = {
|
45
|
+
shareme: {
|
46
|
+
share: {
|
47
|
+
googlePlus: true,
|
48
|
+
facebook: true,
|
49
|
+
twitter: true,
|
50
|
+
digg: true,
|
51
|
+
delicious: true
|
52
|
+
},
|
53
|
+
enableTracking: true,
|
54
|
+
buttons: {
|
55
|
+
googlePlus: {size: 'tall'},
|
56
|
+
facebook: {layout: 'box_count'},
|
57
|
+
twitter: {count: 'vertical'},
|
58
|
+
digg: {type: 'DiggMedium'},
|
59
|
+
delicious: {size: 'tall'}
|
60
|
+
},
|
61
|
+
hover: %Q[function(api, options){
|
62
|
+
$(api.element).find('.buttons').show();
|
63
|
+
}],
|
64
|
+
hide: %Q[function(api, options){
|
65
|
+
$(api.element).find('.buttons').hide();
|
66
|
+
}]
|
67
|
+
}
|
68
|
+
}
|
69
|
+
EXAMPLE5_JS_OPTIONS = {
|
70
|
+
shareme: {
|
71
|
+
share: {
|
72
|
+
googlePlus: true,
|
73
|
+
facebook: true,
|
74
|
+
twitter: true,
|
75
|
+
digg: true,
|
76
|
+
delicious: true,
|
77
|
+
stumbleupon: true,
|
78
|
+
linkedin: true,
|
79
|
+
pinterest: true
|
80
|
+
},
|
81
|
+
buttons: {
|
82
|
+
googlePlus: {size: 'tall'},
|
83
|
+
facebook: {layout: 'box_count'},
|
84
|
+
twitter: {count: 'vertical'},
|
85
|
+
digg: {type: 'DiggMedium'},
|
86
|
+
delicious: {size: 'tall'},
|
87
|
+
stumbleupon: {layout: '5'},
|
88
|
+
linkedin: {counter: 'top'},
|
89
|
+
pinterest: {media: 'http://sharrre.com/img/example1.png', description: %Q{$('#shareme').data('text'), layout: 'vertical'}}
|
90
|
+
},
|
91
|
+
enableHover: false,
|
92
|
+
enableCounter: false,
|
93
|
+
enableTracking: true
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
EXAMPLE6_JS_OPTIONS ={
|
98
|
+
:twitter=>{:share=>{:twitter=>true},:template=>%Q{<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>Tweet</div></a>}, :enableHover=>false, :enableTracking=>true, :buttons =>{ twitter: {via: '_JulienH'}}, :click=>%Q[function(api, options){
|
99
|
+
api.simulateClick();
|
100
|
+
api.openPopup('twitter');}
|
101
|
+
]
|
102
|
+
},
|
103
|
+
:facebook=> {:share=>{:facebook=>true},:template=>%Q{<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>Like</div></a>}, :enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
|
104
|
+
api.simulateClick();
|
105
|
+
api.openPopup('facebook');}
|
106
|
+
]
|
107
|
+
},
|
108
|
+
:googlePlus=>{:share=>{:googlePlus=>true},:template=>%Q{<a class="box" href="#"><div class="count" href="#">{total}</div><div class="share"><span></span>+1</div></a>}, :enableHover=>false, :enableTracking=>true, :click=>%Q[function(api, options){
|
109
|
+
api.simulateClick();
|
110
|
+
api.openPopup('googlePlus');}
|
111
|
+
]
|
112
|
+
}
|
113
|
+
}
|
114
|
+
def rsocialize_div_tag(div_tag_str="", options={})
|
115
|
+
#options{} :=
|
116
|
+
# url: http://www.example.com/
|
117
|
+
# text: text for tweeting, facebook, etc.
|
118
|
+
options = {:facebook=>{:url=>"http://sharrre.com/", :text=>"Make your sharing widget with Sharrre (jQuery Plugin)", :title=>"Like"},
|
119
|
+
:googleplus=>{:url=>"http://sharrre.com/", :text=>"Make your sharing widget with Sharrre (jQuery Plugin)", :title=>"+1"},
|
120
|
+
:twitter=>{:url=>"http://sharrre.com/", :text=>"Make your sharing widget with Sharrre (jQuery Plugin)", :title=>"Tweet"},
|
121
|
+
:div_template=>"example1", :url=>"http://sharrre.com/", :text=>"Make your sharing widget with Sharrre (jQuery Plugin)", :title=>"share this page"}.merge(options)
|
122
|
+
|
123
|
+
data_url = options[:url]
|
124
|
+
data_text = options[:text]
|
125
|
+
data_title = options[:title]
|
126
|
+
div_str = "".html_safe
|
127
|
+
case options[:div_template]
|
128
|
+
when "example1"
|
129
|
+
div_str = %Q{
|
130
|
+
<div id="example1">
|
131
|
+
<div id="twitter" data-url="#{options[:twitter][:url]}" data-text="#{options[:twitter][:text]}" data-title="#{options[:twitter][:title]}"></div>
|
132
|
+
<div id="facebook" data-url="#{options[:facebook][:url]}" data-text="#{options[:facebook][:text]}" data-title="#{options[:facebook][:title]}"></div>
|
133
|
+
<div id="googleplus" data-url="#{options[:googleplus][:url]}" data-text="#{options[:googleplus][:text]}" data-title="#{options[:googleplus][:title]}"></div>
|
134
|
+
</div>
|
135
|
+
}.html_safe
|
136
|
+
when "example2", "example5"
|
137
|
+
div_str = %Q{
|
138
|
+
<div id="#{options[:div_template]}">
|
139
|
+
<div id="shareme" data-url="#{data_url}" data-text="#{data_text}"></div>
|
140
|
+
</div>
|
141
|
+
}.html_safe
|
142
|
+
when "example3"
|
143
|
+
div_str = %Q{
|
144
|
+
<div id="example3">
|
145
|
+
<div id="shareme" data-url="#{data_url}" data-text="#{data_text}" data-title="#{data_title}"></div>
|
146
|
+
</div>
|
147
|
+
}.html_safe
|
148
|
+
when "example6"
|
149
|
+
div_str = %Q{
|
150
|
+
<div id="example6">
|
151
|
+
<div id="twitter" data-url="#{options[:twitter][:url]}" data-text="#{options[:twitter][:text]}"></div>
|
152
|
+
<div id="facebook" data-url="#{options[:facebook][:url]}" data-text="#{options[:facebook][:text]}"></div>
|
153
|
+
<div id="googleplus" data-url="#{options[:googleplus][:url]}" data-text="#{options[:googleplus][:text]}"></div>
|
154
|
+
</div>
|
155
|
+
}.html_safe
|
156
|
+
else #assume empty or custom
|
157
|
+
if (div_tag_str.empty?) #use template <div>
|
158
|
+
div_str = %Q{
|
159
|
+
<div id="#{options[:div_template]}">
|
160
|
+
<div id="twitter" data-url="#{data_url}" data-text="#{data_text}" data-title="Tweet"></div>
|
161
|
+
<div id="facebook" data-url="#{data_url}" data-text="#{data_text}" data-title="Like"></div>
|
162
|
+
<div id="googleplus" data-url="#{data_url}" data-text="#{data_text}" data-title="+1"></div>
|
163
|
+
</div>
|
164
|
+
}.html_safe
|
165
|
+
else #use your own <div> classes
|
166
|
+
div_str = div_tag_str.html_safe
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
return div_str
|
171
|
+
end
|
172
|
+
def rsocialize_js_tag(options={})
|
173
|
+
case options[:js_template]
|
174
|
+
when "example1"
|
175
|
+
options = EXAMPLE1_JS_OPTIONS
|
176
|
+
when "example2"
|
177
|
+
options = EXAMPLE2_JS_OPTIONS
|
178
|
+
when "example3"
|
179
|
+
options = EXAMPLE3_JS_OPTIONS
|
180
|
+
when "example5"
|
181
|
+
options = EXAMPLE5_JS_OPTIONS
|
182
|
+
when "example6"
|
183
|
+
options = EXAMPLE6_JS_OPTIONS
|
184
|
+
end
|
185
|
+
options=options.merge(options)
|
186
|
+
|
187
|
+
js_str = "<script>\n".html_safe
|
188
|
+
js_str = js_str+rsocialize_build_js(options).html_safe
|
189
|
+
js_str += "</script>".html_safe
|
190
|
+
return js_str
|
191
|
+
end
|
192
|
+
def rsocialize_build_js(options={})
|
193
|
+
@debug_str = ""
|
194
|
+
@js_str = "$(document).ready(function() { "
|
195
|
+
options.each_key do |key|
|
196
|
+
@js_str = @js_str +
|
197
|
+
"$('##{key.to_s.downcase}').sharrre({\n"
|
198
|
+
options[key].each_key do |key2|
|
199
|
+
@js_str = @js_str+%Q{ #{recursive_js_build(options[key],key2, key.to_s)} }
|
200
|
+
@js_str = @js_str+"\n"
|
201
|
+
end
|
202
|
+
@js_str = @js_str+"});\n"
|
203
|
+
end #options.each_key do |key|
|
204
|
+
@js_str = @js_str + "});"
|
205
|
+
return @js_str
|
206
|
+
end
|
207
|
+
def recursive_js_build(options, key, button_val)
|
208
|
+
@retval=%Q{#{key.to_s}: }
|
209
|
+
@retval = @retval+"{" if hash_depth(options[key])>0
|
210
|
+
if options[key].is_a?(Hash)
|
211
|
+
options[key].each_key do |nested_key|
|
212
|
+
@retval = @retval + %Q{ #{recursive_js_build(options[key],nested_key,button_val)} }
|
213
|
+
end
|
214
|
+
else
|
215
|
+
new_key = options[key]
|
216
|
+
if !(options[key]==true||options[key]==false)
|
217
|
+
new_key = %Q{'#{options[key]}'} if (options[key][0,1])!~/[\$f]/
|
218
|
+
#Regexp and mapping to sharrre jQuery options
|
219
|
+
#$ = start of jquery
|
220
|
+
#f = start of function call
|
221
|
+
end
|
222
|
+
@retval = @retval + %Q{#{new_key}}
|
223
|
+
@retval = @retval+"," if options.length>1 && options.keys.last!=key
|
224
|
+
end
|
225
|
+
if hash_depth(options[key])>0 && options.keys.last!=key
|
226
|
+
@retval = @retval + "},\n"
|
227
|
+
elsif hash_depth(options[key])>0
|
228
|
+
@retval = @retval + "}\n"
|
229
|
+
end
|
230
|
+
return @retval
|
231
|
+
end
|
232
|
+
def hash_depth(bhash)
|
233
|
+
#return depth of hash as an integer
|
234
|
+
return 0 if !bhash.is_a?(Hash) #no hash = 0
|
235
|
+
if bhash[bhash.keys.first].is_a?(Hash) #could be nil if hash is only one level deep
|
236
|
+
@depth = hash_depth(bhash[bhash.keys.first])+1
|
237
|
+
else #so return 1
|
238
|
+
return 1
|
239
|
+
end
|
240
|
+
@depth
|
241
|
+
end
|
242
|
+
end #end module Rsocialize
|
243
|
+
|
244
|
+
class ActionView::Base # :nodoc:
|
245
|
+
include Rsocialize
|
246
|
+
end
|
data/rsocialize.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rsocialize/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Bruce Park"]
|
6
|
+
gem.email = ["bruce at binarywebpark.com"]
|
7
|
+
gem.description = %q{Provides a simple way to add social media buttons to your rails application}
|
8
|
+
gem.summary = %q{Provides a simple way to add social media buttons to your rails application. It's a ruby wrapper for the sharrre jQuery plugin.'}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
#gem.files = `git ls-files`.split($\)
|
12
|
+
#gem.files = Dir["{lib}/**/*"] + ["LICENSE", "README.md"]
|
13
|
+
#gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
#gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
gem.name = "rsocialize"
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
gem.version = Rsocialize::VERSION
|
21
|
+
|
22
|
+
gem.add_development_dependency "rspec","~>2.11.0"
|
23
|
+
gem.add_development_dependency "rake","~>0.9.2.2"
|
24
|
+
gem.add_runtime_dependency "curb", "~>0.8.2"
|
25
|
+
gem.add_runtime_dependency "activesupport", "~>3.2.8"
|
26
|
+
gem.add_runtime_dependency "nokogiri", "~>1.5.5"
|
27
|
+
gem.add_runtime_dependency "actionpack", "~>3.2.8"
|
28
|
+
end
|