friendly_extensions 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,349 @@
1
+ # -*- encoding : utf-8 -*-
2
+ # Lists of character replacements like ASCII and HTML entities
3
+ module Chars2Remove
4
+
5
+ # List with internation chars and their ASCII replacement
6
+ CHARS = {
7
+ "¡" => "",
8
+ "&" => "",
9
+ "¢" => "",
10
+ "£" => "",
11
+ "¤" => "",
12
+ "¥" => "",
13
+ "¦" => "",
14
+ "§" => "",
15
+ "¨" => "",
16
+ "©" => "(C)",
17
+ "ª" => "",
18
+ "«" => "<",
19
+ "¬" => "-",
20
+ "­" => "-",
21
+ "®" => "(R)",
22
+ "¯" => "",
23
+ "°" => "",
24
+ "±" => "",
25
+ "²" => "",
26
+ "³" => "",
27
+ "´" => "",
28
+ "µ" => "n",
29
+ "¶" => "",
30
+ "·" => "",
31
+ "¸" => "",
32
+ "¹" => "",
33
+ "º" => "",
34
+ "»" => ">",
35
+ "¼" => "",
36
+ "½" => "",
37
+ "¾" => "",
38
+ "¿" => "?",
39
+ "Ä" => "Ae",
40
+ "À" => "A",
41
+ "Á" => "A",
42
+ "Â" => "A",
43
+ "Ã" => "A",
44
+ "Å" => "A",
45
+ "Æ" => "Ae",
46
+ "Ç" => "C",
47
+ "È" => "E",
48
+ "É" => "E",
49
+ "Ê" => "E",
50
+ "Ë" => "E",
51
+ "Ì" => "I",
52
+ "Í" => "I",
53
+ "Î" => "I",
54
+ "Ï" => "I",
55
+ "Ð" => "D",
56
+ "Ñ" => "N",
57
+ "Ö" => "Oe",
58
+ "Ò" => "O",
59
+ "Ó" => "O",
60
+ "Ô" => "O",
61
+ "Õ" => "O",
62
+ "×" => "x",
63
+ "Ø" => "Oe",
64
+ "Ü" => "Ue",
65
+ "Ù" => "U",
66
+ "Ú" => "U",
67
+ "Û" => "U",
68
+ "Ý" => "y",
69
+ "Þ" => "p",
70
+ "ä" => "ae",
71
+ "ö" => "oe",
72
+ "ü" => "ue",
73
+ "ß" => "ss",
74
+ "à" => "a",
75
+ "á" => "a",
76
+ "â" => "a",
77
+ "ã" => "a",
78
+ "å" => "a",
79
+ "æ" => "ae",
80
+ "ç" => "c",
81
+ "è" => "e",
82
+ "é" => "e",
83
+ "ê" => "e",
84
+ "ë" => "e",
85
+ "ì" => "i",
86
+ "í" => "i",
87
+ "î" => "i",
88
+ "ï" => "i",
89
+ "ð" => "o",
90
+ "ñ" => "n",
91
+ "ò" => "o",
92
+ "ó" => "o",
93
+ "ô" => "o",
94
+ "õ" => "o",
95
+ "÷" => "x",
96
+ "ø" => "o",
97
+ "ù" => "u",
98
+ "ú" => "u",
99
+ "û" => "u",
100
+ "ý" => "y",
101
+ "þ" => "y",
102
+ "ÿ" => "y"
103
+ }
104
+
105
+
106
+
107
+ # These charaters mustn't be removed in HTML mode!
108
+ # All HTML Entities
109
+ ENTITIES = {
110
+ 'Â' => {:html => '&Acirc;' , :dec => '&#194;' , :hex => '&#x00C2;' },
111
+ 'â' => {:html => '&acirc;' , :dec => '&#226;' , :hex => '&#x00E2;' },
112
+ '´' => {:html => '&acute;' , :dec => '&#180;' , :hex => '&#x00B4;' },
113
+ 'Æ' => {:html => '&AElig;' , :dec => '&#198;' , :hex => '&#x00C6;' },
114
+ 'æ' => {:html => '&aelig;' , :dec => '&#230;' , :hex => '&#x00E6;' },
115
+ 'À' => {:html => '&Agrave;' , :dec => '&#192;' , :hex => '&#x00C0;' },
116
+ 'à' => {:html => '&agrave;' , :dec => '&#224;' , :hex => '&#x00E0;' },
117
+ 'ℵ' => {:html => '&alefsym;' , :dec => '&#8501;' , :hex => '&#x2135;' },
118
+ 'Α' => {:html => '&Alpha;' , :dec => '&#913;' , :hex => '&#x0391;' },
119
+ 'α' => {:html => '&alpha;' , :dec => '&#945;' , :hex => '&#x03B1;' },
120
+ '∧' => {:html => '&and;' , :dec => '&#8743;' , :hex => '&#x2227;' },
121
+ '∠' => {:html => '&ang;' , :dec => '&#8736;' , :hex => '&#x2220;' },
122
+ 'Å' => {:html => '&Aring;' , :dec => '&#197;' , :hex => '&#x00C5;' },
123
+ 'å' => {:html => '&aring;' , :dec => '&#229;' , :hex => '&#x00E5;' },
124
+ '≈' => {:html => '&asymp;' , :dec => '&#8776;' , :hex => '&#x2248;' },
125
+ 'Ã' => {:html => '&Atilde;' , :dec => '&#195;' , :hex => '&#x00C3;' },
126
+ 'ã' => {:html => '&atilde;' , :dec => '&#227;' , :hex => '&#x00E3;' },
127
+ 'Ä' => {:html => '&Auml;' , :dec => '&#196;' , :hex => '&#x00C4;' },
128
+ 'ä' => {:html => '&auml;' , :dec => '&#228;' , :hex => '&#x00E4;' },
129
+ '„' => {:html => '&bdquo;' , :dec => '&#8222;' , :hex => '&#x201E;' },
130
+ 'Β' => {:html => '&Beta;' , :dec => '&#914;' , :hex => '&#x0392;' },
131
+ 'β' => {:html => '&beta;' , :dec => '&#946;' , :hex => '&#x03B2;' },
132
+ '¦' => {:html => '&brvbar;' , :dec => '&#166;' , :hex => '&#x00A6;' },
133
+ '•' => {:html => '&bull;' , :dec => '&#8226;' , :hex => '&#x2022;' },
134
+ '∩' => {:html => '&cap;' , :dec => '&#8745;' , :hex => '&#x2229;' },
135
+ 'Ç' => {:html => '&Ccedil;' , :dec => '&#199;' , :hex => '&#x00C7;' },
136
+ 'ç' => {:html => '&ccedil;' , :dec => '&#231;' , :hex => '&#x00E7;' },
137
+ '¸' => {:html => '&cedil;' , :dec => '&#184;' , :hex => '&#x00B8;' },
138
+ '¢' => {:html => '&cent;' , :dec => '&#162;' , :hex => '&#x00A2;' },
139
+ 'Χ' => {:html => '&Chi;' , :dec => '&#935;' , :hex => '&#x03A7;' },
140
+ 'χ' => {:html => '&chi;' , :dec => '&#967;' , :hex => '&#x03C7;' },
141
+ 'ˆ' => {:html => '&circ;' , :dec => '&#710;' , :hex => '&#x02C6;' },
142
+ '♣' => {:html => '&clubs;' , :dec => '&#9827;' , :hex => '&#x2663;' },
143
+ '≅' => {:html => '&cong;' , :dec => '&#8773;' , :hex => '&#x2245;' },
144
+ '©' => {:html => '&copy;' , :dec => '&#169;' , :hex => '&#x00A9;' },
145
+ '↵' => {:html => '&crarr;' , :dec => '&#8629;' , :hex => '&#x21B5;' },
146
+ '∪' => {:html => '&cup;' , :dec => '&#8746;' , :hex => '&#x222A;' },
147
+ '¤' => {:html => '&curren;' , :dec => '&#164;' , :hex => '&#x00A4;' },
148
+ '‡' => {:html => '&Dagger;' , :dec => '&#8225;' , :hex => '&#x2021;' },
149
+ '†' => {:html => '&dagger;' , :dec => '&#8224;' , :hex => '&#x2020;' },
150
+ '⇓' => {:html => '&dArr;' , :dec => '&#8659;' , :hex => '&#x21D3;' },
151
+ '↓' => {:html => '&darr;' , :dec => '&#8595;' , :hex => '&#x2193;' },
152
+ '°' => {:html => '&deg;' , :dec => '&#176;' , :hex => '&#x00B0;' },
153
+ 'Δ' => {:html => '&Delta;' , :dec => '&#916;' , :hex => '&#x0394;' },
154
+ 'δ' => {:html => '&delta;' , :dec => '&#948;' , :hex => '&#x03B4;' },
155
+ '♦' => {:html => '&diams;' , :dec => '&v#9830;', :hex => '&#x2666;' },
156
+ '÷' => {:html => '&divide;' , :dec => '&#247;' , :hex => '&#x00F7;' },
157
+ 'É' => {:html => '&Eacute;' , :dec => '&#201;' , :hex => '&#x00C9;' },
158
+ 'é' => {:html => '&eacute;' , :dec => '&#233;' , :hex => '&#x00E9;' },
159
+ 'Ê' => {:html => '&Ecirc;' , :dec => '&#202;' , :hex => '&#x00CA;' },
160
+ 'ê' => {:html => '&ecirc;' , :dec => '&#234;' , :hex => '&#x00EA;' },
161
+ 'È' => {:html => '&Egrave;' , :dec => '&#200;' , :hex => '&#x00C8;' },
162
+ 'è' => {:html => '&egrave;' , :dec => '&#232;' , :hex => '&#x00E8;' },
163
+ '∅' => {:html => '&empty;' , :dec => '&#8709;' , :hex => '&#x2205;' },
164
+ 'Ε' => {:html => '&Epsilon;' , :dec => '&#917;' , :hex => '&#x0395;' },
165
+ 'ε' => {:html => '&epsilon;' , :dec => '&#949;' , :hex => '&#x03B5;' },
166
+ '≡' => {:html => '&equiv;' , :dec => '&#8801;' , :hex => '&#x2261;' },
167
+ 'Η' => {:html => '&Eta;' , :dec => '&#919;' , :hex => '&#x0397;' },
168
+ 'η' => {:html => '&eta;' , :dec => '&#951;' , :hex => '&#x03B7;' },
169
+ 'Ð' => {:html => '&ETH;' , :dec => '&#208;' , :hex => '&#x00D0;' },
170
+ 'ð' => {:html => '&eth;' , :dec => '&#240;' , :hex => '&#x00F0;' },
171
+ 'Ë' => {:html => '&Euml;' , :dec => '&#203;' , :hex => '&#x00CB;' },
172
+ 'ë' => {:html => '&euml;' , :dec => '&#235;' , :hex => '&#x00EB;' },
173
+ '€' => {:html => '&euro;' , :dec => '&#8364;' , :hex => '&#x20AC;' },
174
+ '∃' => {:html => '&exist;' , :dec => '&#8707;' , :hex => '&#x2203;' },
175
+ 'ƒ' => {:html => '&fnof;' , :dec => '&#402;' , :hex => '&#x0192;' },
176
+ '∀' => {:html => '&forall;' , :dec => '&#8704;' , :hex => '&#x2200;' },
177
+ '½' => {:html => '&frac12;' , :dec => '&#189;' , :hex => '&#x00BD;' },
178
+ '¼' => {:html => '&frac14;' , :dec => '&#188;' , :hex => '&#x00BC;' },
179
+ '¾' => {:html => '&frac34;' , :dec => '&#190;' , :hex => '&#x00BE;' },
180
+ 'Γ' => {:html => '&Gamma;' , :dec => '&#915;' , :hex => '&#x0393;' },
181
+ 'γ' => {:html => '&gamma;' , :dec => '&#947;' , :hex => '&#x03B3;' },
182
+ '≥' => {:html => '&ge;' , :dec => '&#8805;' , :hex => '&#x2265;' },
183
+ '⇔' => {:html => '&hArr;' , :dec => '&#8660;' , :hex => '&#x21D4;' },
184
+ '↔' => {:html => '&harr;' , :dec => '&#8596;' , :hex => '&#x2194;' },
185
+ '♥' => {:html => '&hearts;' , :dec => '&#9829;' , :hex => '&#x2665;' },
186
+ '…' => {:html => '&hellip;' , :dec => '&#8230;' , :hex => '&#x2026;' },
187
+ 'Í' => {:html => '&Iacute;' , :dec => '&#205;' , :hex => '&#x00CD;' },
188
+ 'í' => {:html => '&iacute;' , :dec => '&#237;' , :hex => '&#x00ED;' },
189
+ 'Î' => {:html => '&Icirc;' , :dec => '&#206;' , :hex => '&#x00CE;' },
190
+ 'î' => {:html => '&icirc;' , :dec => '&#238;' , :hex => '&#x00EE;' },
191
+ '¡' => {:html => '&iexcl;' , :dec => '&#161;' , :hex => '&#x00A1;' },
192
+ 'Ì' => {:html => '&Igrave;' , :dec => '&#204;' , :hex => '&#x00CC;' },
193
+ 'ì' => {:html => '&igrave;' , :dec => '&#236;' , :hex => '&#x00EC;' },
194
+ 'ℑ' => {:html => '&image;' , :dec => '&#8465;' , :hex => '&#x2111;' },
195
+ '∞' => {:html => '&infin;' , :dec => '&#8734;' , :hex => '&#x221E;' },
196
+ '∫' => {:html => '&int;' , :dec => '&#8747;' , :hex => '&#x222B;' },
197
+ 'Ι' => {:html => '&Iota;' , :dec => '&#921;' , :hex => '&#x0399;' },
198
+ 'ι' => {:html => '&iota;' , :dec => '&#953;' , :hex => '&#x03B9;' },
199
+ '¿' => {:html => '&iquest;' , :dec => '&#191;' , :hex => '&#x00BF;' },
200
+ '∈' => {:html => '&isin;' , :dec => '&#8712;' , :hex => '&#x2208;' },
201
+ 'Ï' => {:html => '&Iuml;' , :dec => '&#207;' , :hex => '&#x00CF;' },
202
+ 'ï' => {:html => '&iuml;' , :dec => '&#239;' , :hex => '&#x00EF;' },
203
+ 'Κ' => {:html => '&Kappa;' , :dec => '&#922;' , :hex => '&#x039A;' },
204
+ 'κ' => {:html => '&kappa;' , :dec => '&#954;' , :hex => '&#x03BA;' },
205
+ 'Λ' => {:html => '&Lambda;' , :dec => '&#923;' , :hex => '&#x039B;' },
206
+ 'λ' => {:html => '&lambda;' , :dec => '&#955;' , :hex => '&#x03BB;' },
207
+ '⟨' => {:html => '&lang;' , :dec => '&#9001;' , :hex => '&#x2329;' },
208
+ '«' => {:html => '&laquo;' , :dec => '&#171;' , :hex => '&#x00AB;' },
209
+ '⇐' => {:html => '&lArr;' , :dec => '&#8656;' , :hex => '&#x21D0;' },
210
+ '←' => {:html => '&larr;' , :dec => '&#8592;' , :hex => '&#x2190;' },
211
+ '⌈' => {:html => '&lceil;' , :dec => '&#8968;' , :hex => '&#x2308;' },
212
+ '“' => {:html => '&ldquo;' , :dec => '&#8220;' , :hex => '&#x201C;' },
213
+ '≤' => {:html => '&le;' , :dec => '&#8804;' , :hex => '&#x2264;' },
214
+ '⌊' => {:html => '&lfloor;' , :dec => '&#8970;' , :hex => '&#x230A;' },
215
+ '∗' => {:html => '&lowast;' , :dec => '&#8727;' , :hex => '&#x2217;' },
216
+ '◊' => {:html => '&loz;' , :dec => '&#9674;' , :hex => '&#x25CA;' },
217
+ '‹' => {:html => '&lsaquo;' , :dec => '&#8249;' , :hex => '&#x2039;' },
218
+ '‘' => {:html => '&lsquo;' , :dec => '&#8216;' , :hex => '&#x2018;' },
219
+ '¯' => {:html => '&macr;' , :dec => '&#175;' , :hex => '&#x00AF;' },
220
+ '—' => {:html => '&mdash;' , :dec => '&#8212;' , :hex => '&#x2014;' },
221
+ 'µ' => {:html => '&micro;' , :dec => '&#181;' , :hex => '&#x00B5;' },
222
+ '·' => {:html => '&middot;' , :dec => '&#183;' , :hex => '&#x00B7;' },
223
+ '−' => {:html => '&minus;' , :dec => '&#8722;' , :hex => '&#x2212;' },
224
+ 'Μ' => {:html => '&Mu;' , :dec => '&#924;' , :hex => '&#x039C;' },
225
+ 'μ' => {:html => '&mu;' , :dec => '&#956;' , :hex => '&#x03BC;' },
226
+ '∇' => {:html => '&nabla;' , :dec => '&#8711;' , :hex => '&#x2207;' },
227
+ '–' => {:html => '&ndash;' , :dec => '&#8211;' , :hex => '&#x2013;' },
228
+ '≠' => {:html => '&ne;' , :dec => '&#8800;' , :hex => '&#x2260;' },
229
+ '∋' => {:html => '&ni;' , :dec => '&#8715;' , :hex => '&#x220B;' },
230
+ '¬' => {:html => '&not;' , :dec => '&#172;' , :hex => '&#x00AC;' },
231
+ '∉' => {:html => '&notin;' , :dec => '&#8713;' , :hex => '&#x2209;' },
232
+ '⊄' => {:html => '&nsub;' , :dec => '&#8836;' , :hex => '&#x2284;' },
233
+ 'Ñ' => {:html => '&Ntilde;' , :dec => '&#209;' , :hex => '&#x00D1;' },
234
+ 'ñ' => {:html => '&ntilde;' , :dec => '&#241;' , :hex => '&#x00F1;' },
235
+ 'Ν' => {:html => '&Nu;' , :dec => '&#925;' , :hex => '&#x039D;' },
236
+ 'ν' => {:html => '&nu;' , :dec => '&#957;' , :hex => '&#x03BD;' },
237
+ 'Ó' => {:html => '&Oacute;' , :dec => '&#211;' , :hex => '&#x00D3;' },
238
+ 'ó' => {:html => '&oacute;' , :dec => '&#243;' , :hex => '&#x00F3;' },
239
+ 'Ô' => {:html => '&Ocirc;' , :dec => '&#212;' , :hex => '&#x00D4;' },
240
+ 'ô' => {:html => '&ocirc;' , :dec => '&#244;' , :hex => '&#x00F4;' },
241
+ 'Œ' => {:html => '&OElig;' , :dec => '&#338;' , :hex => '&#x0152;' },
242
+ 'œ' => {:html => '&oelig;' , :dec => '&#339;' , :hex => '&#x0153;' },
243
+ 'Ò' => {:html => '&Ograve;' , :dec => '&#210;' , :hex => '&#x00D2;' },
244
+ 'ò' => {:html => '&ograve;' , :dec => '&#242;' , :hex => '&#x00F2;' },
245
+ '‾' => {:html => '&oline;' , :dec => '&#8254;' , :hex => '&#x203E;' },
246
+ 'Ω' => {:html => '&Omega;' , :dec => '&#937;' , :hex => '&#x03A9;' },
247
+ 'ω' => {:html => '&omega;' , :dec => '&#969;' , :hex => '&#x03C9;' },
248
+ 'Ο' => {:html => '&Omicron;' , :dec => '&#927;' , :hex => '&#x039F;' },
249
+ 'ο' => {:html => '&omicron;' , :dec => '&#959;' , :hex => '&#x03BF;' },
250
+ '⊕' => {:html => '&oplus;' , :dec => '&#8853;' , :hex => '&#x2295;' },
251
+ '∨' => {:html => '&or;' , :dec => '&#8744;' , :hex => '&#x2228;' },
252
+ 'ª' => {:html => '&ordf;' , :dec => '&#170;' , :hex => '&#x00AA;' },
253
+ 'º' => {:html => '&ordm;' , :dec => '&#186;' , :hex => '&#x00BA;' },
254
+ 'Ø' => {:html => '&Oslash;' , :dec => '&#216;' , :hex => '&#x00D8;' },
255
+ 'ø' => {:html => '&oslash;' , :dec => '&#248;' , :hex => '&#x00F8;' },
256
+ 'Õ' => {:html => '&Otilde;' , :dec => '&#213;' , :hex => '&#x00D5;' },
257
+ 'õ' => {:html => '&otilde;' , :dec => '&#245;' , :hex => '&#x00F5;' },
258
+ '⊗' => {:html => '&otimes;' , :dec => '&#8855;' , :hex => '&#x2297;' },
259
+ 'Ö' => {:html => '&Ouml;' , :dec => '&#214;' , :hex => '&#x00D6;' },
260
+ 'ö' => {:html => '&ouml;' , :dec => '&#246;' , :hex => '&#x00F6;' },
261
+ '¶' => {:html => '&para;' , :dec => '&#182;' , :hex => '&#x00B6;' },
262
+ '∂' => {:html => '&part;' , :dec => '&#8706;' , :hex => '&#x2202;' },
263
+ '‰' => {:html => '&permil;' , :dec => '&#8240;' , :hex => '&#x2030;' },
264
+ '⊥' => {:html => '&perp;' , :dec => '&#8869;' , :hex => '&#x22A5;' },
265
+ 'Φ' => {:html => '&Phi;' , :dec => '&#934;' , :hex => '&#x03A6;' },
266
+ 'φ' => {:html => '&phi;' , :dec => '&#966;' , :hex => '&#x03C6;' },
267
+ 'Π' => {:html => '&Pi;' , :dec => '&#928;' , :hex => '&#x03A0;' },
268
+ 'π' => {:html => '&pi;' , :dec => '&#960;' , :hex => '&#x03C0;' },
269
+ 'ϖ' => {:html => '&piv;' , :dec => '&#982;' , :hex => '&#x03D6;' },
270
+ '±' => {:html => '&plusmn;' , :dec => '&#177;' , :hex => '&#x00B1;' },
271
+ '£' => {:html => '&pound;' , :dec => '&#163;' , :hex => '&#x00A3;' },
272
+ '″' => {:html => '&Prime;' , :dec => '&#8243;' , :hex => '&#x2033;' },
273
+ '′' => {:html => '&prime;' , :dec => '&#8242;' , :hex => '&#x2032;' },
274
+ '∏' => {:html => '&prod;' , :dec => '&#8719;' , :hex => '&#x220F;' },
275
+ '∝' => {:html => '&prop;' , :dec => '&#8733;' , :hex => '&#x221D;' },
276
+ 'Ψ' => {:html => '&Psi;' , :dec => '&#936;' , :hex => '&#x03A8;' },
277
+ 'ψ' => {:html => '&psi;' , :dec => '&#968;' , :hex => '&#x03C8;' },
278
+ '√' => {:html => '&radic;' , :dec => '&#8730;' , :hex => '&#x221A;' },
279
+ '⟩' => {:html => '&rang;' , :dec => '&#9002;' , :hex => '&#x232A;' },
280
+ '»' => {:html => '&raquo;' , :dec => '&#187;' , :hex => '&#x00BB;' },
281
+ '⇒' => {:html => '&rArr;' , :dec => '&#8658;' , :hex => '&#x21D2;' },
282
+ '→' => {:html => '&rarr;' , :dec => '&#8594;' , :hex => '&#x2192;' },
283
+ '⌉' => {:html => '&rceil;' , :dec => '&#8969;' , :hex => '&#x2309;' },
284
+ '”' => {:html => '&rdquo;' , :dec => '&#8221;' , :hex => '&#x201D;' },
285
+ 'ℜ' => {:html => '&real;' , :dec => '&#8476;' , :hex => '&#x211C;' },
286
+ '®' => {:html => '&reg;' , :dec => '&#174;' , :hex => '&#x00AE;' },
287
+ '⌋' => {:html => '&rfloor;' , :dec => '&#8971;' , :hex => '&#x230B;' },
288
+ 'Ρ' => {:html => '&Rho;' , :dec => '&#929;' , :hex => '&#x03A1;' },
289
+ 'ρ' => {:html => '&rho;' , :dec => '&#961;' , :hex => '&#x03C1;' },
290
+ '›' => {:html => '&rsaquo;' , :dec => '&#8250;' , :hex => '&#x203A;' },
291
+ '’' => {:html => '&rsquo;' , :dec => '&#8217;' , :hex => '&#x2019;' },
292
+ '‚' => {:html => '&sbquo;' , :dec => '&#8218;' , :hex => '&#x201A;' },
293
+ 'Š' => {:html => '&Scaron;' , :dec => '&#352;' , :hex => '&#x0160;' },
294
+ 'š' => {:html => '&scaron;' , :dec => '&#353;' , :hex => '&#x0161;' },
295
+ '⋅' => {:html => '&sdot;' , :dec => '&#8901;' , :hex => '&#x22C5;' },
296
+ '§' => {:html => '&sect;' , :dec => '&#167;' , :hex => '&#x00A7;' },
297
+ 'Σ' => {:html => '&Sigma;' , :dec => '&#931;' , :hex => '&#x03A3;' },
298
+ 'σ' => {:html => '&sigma;' , :dec => '&#963;' , :hex => '&#x03C3;' },
299
+ 'ς' => {:html => '&sigmaf;' , :dec => '&#962;' , :hex => '&#x03C2;' },
300
+ '∼' => {:html => '&sim;' , :dec => '&#8764;' , :hex => '&#x223C;' },
301
+ '♠' => {:html => '&spades;' , :dec => '&#9824;' , :hex => '&#x2660;' },
302
+ '⊂' => {:html => '&sub;' , :dec => '&#8834;' , :hex => '&#x2282;' },
303
+ '⊆' => {:html => '&sube;' , :dec => '&#8838;' , :hex => '&#x2286;' },
304
+ '∑' => {:html => '&sum;' , :dec => '&#8721;' , :hex => '&#x2211;' },
305
+ '⊃' => {:html => '&sup;' , :dec => '&#8835;' , :hex => '&#x2283;' },
306
+ '¹' => {:html => '&sup1;' , :dec => '&#185;' , :hex => '&#x00B9;' },
307
+ '²' => {:html => '&sup2;' , :dec => '&#178;' , :hex => '&#x00B2;' },
308
+ '³' => {:html => '&sup3;' , :dec => '&#179;' , :hex => '&#x00B3;' },
309
+ '⊇' => {:html => '&supe;' , :dec => '&#8839;' , :hex => '&#x2287;' },
310
+ 'ß' => {:html => '&szlig;' , :dec => '&#223;' , :hex => '&#x00DF;' },
311
+ 'Τ' => {:html => '&Tau;' , :dec => '&#932;' , :hex => '&#x03A4;' },
312
+ 'τ' => {:html => '&tau;' , :dec => '&#964;' , :hex => '&#x03C4;' },
313
+ '∴' => {:html => '&there4;' , :dec => '&#8756;' , :hex => '&#x2234;' },
314
+ 'Θ' => {:html => '&Theta;' , :dec => '&#920;' , :hex => '&#x0398;' },
315
+ 'θ' => {:html => '&theta;' , :dec => '&#952;' , :hex => '&#x03B8;' },
316
+ 'ϑ' => {:html => '&thetasym;' , :dec => '&#977;' , :hex => '&#x03D1;' },
317
+ 'Þ' => {:html => '&THORN;' , :dec => '&#222;' , :hex => '&#x00DE;' },
318
+ 'þ' => {:html => '&thorn;' , :dec => '&#254;' , :hex => '&#x00FE;' },
319
+ '˜' => {:html => '&tilde;' , :dec => '&#732;' , :hex => '&#x02DC;' },
320
+ '×' => {:html => '&times;' , :dec => '&#215;' , :hex => '&#x00D7;' },
321
+ '™' => {:html => '&trade;' , :dec => '&#8482;' , :hex => '&#x2122;' },
322
+ 'Ú' => {:html => '&Uacute;' , :dec => '&#218;' , :hex => '&#x00DA;' },
323
+ 'ú' => {:html => '&uacute;' , :dec => '&#250;' , :hex => '&#x00FA;' },
324
+ '⇑' => {:html => '&uArr;' , :dec => '&#8657;' , :hex => '&#x21D1;' },
325
+ '↑' => {:html => '&uarr;' , :dec => '&#8593;' , :hex => '&#x2191;' },
326
+ 'Û' => {:html => '&Ucirc;' , :dec => '&#219;' , :hex => '&#x00DB;' },
327
+ 'û' => {:html => '&ucirc;' , :dec => '&#251;' , :hex => '&#x00FB;' },
328
+ 'Ù' => {:html => '&Ugrave;' , :dec => '&#217;' , :hex => '&#x00D9;' },
329
+ 'ù' => {:html => '&ugrave;' , :dec => '&#249;' , :hex => '&#x00F9;' },
330
+ '¨' => {:html => '&uml;' , :dec => '&#168;' , :hex => '&#x00A8;' },
331
+ 'ϒ' => {:html => '&upsih;' , :dec => '&#978;' , :hex => '&#x03D2;' },
332
+ 'Υ' => {:html => '&Upsilon;' , :dec => '&#933;' , :hex => '&#x03A5;' },
333
+ 'υ' => {:html => '&upsilon;' , :dec => '&#965;' , :hex => '&#x03C5;' },
334
+ 'Ü' => {:html => '&Uuml;' , :dec => '&#220;' , :hex => '&#x00DC;' },
335
+ 'ü' => {:html => '&uuml;' , :dec => '&#252;' , :hex => '&#x00FC;' },
336
+ '℘' => {:html => '&weierp;' , :dec => '&#8472;' , :hex => '&#x2118;' },
337
+ 'Ξ' => {:html => '&Xi;' , :dec => '&#926;' , :hex => '&#x039E;' },
338
+ 'ξ' => {:html => '&xi;' , :dec => '&#958;' , :hex => '&#x03BE;' },
339
+ 'Ý' => {:html => '&Yacute;' , :dec => '&#221;' , :hex => '&#x00DD;' },
340
+ 'ý' => {:html => '&yacute;' , :dec => '&#253;' , :hex => '&#x00FD;' },
341
+ '¥' => {:html => '&yen;' , :dec => '&#165;' , :hex => '&#x00A5;' },
342
+ 'Ÿ' => {:html => '&Yuml;' , :dec => '&#376;' , :hex => '&#x0178;' },
343
+ 'ÿ' => {:html => '&yuml;' , :dec => '&#255;' , :hex => '&#x00FF;' },
344
+ 'Ζ' => {:html => '&Zeta;' , :dec => '&#918;' , :hex => '&#x0396;' },
345
+ 'ζ' => {:html => '&zeta;' , :dec => '&#950;' , :hex => '&#x03B6;' }
346
+ }
347
+
348
+
349
+ end
@@ -0,0 +1,198 @@
1
+ # -*- encoding : utf-8 -*-
2
+ # Extend Date, DateTime and Time
3
+ module DateNTime
4
+ Date.class_eval do
5
+
6
+ def self.new_from_params(p)
7
+ return Date.new(p["starts_at(1i)"].to_i, p["starts_at(2i)"].to_i, p["starts_at(3i)"].to_i)
8
+ end
9
+
10
+ def to_short_stamp(options = {})
11
+ return self.strftime('%d%m%y')
12
+ end
13
+
14
+ # Return the current age base on a birthdate which is self
15
+ def age_calc
16
+ now = Time.now.to_date
17
+ now.year - self.year - (self.change(:year=>now.year)>now ? 1 : 0) #rescue 0
18
+ end
19
+
20
+ # return next month
21
+ def next_month
22
+ return self+1.month
23
+ end
24
+
25
+ # return previous month
26
+ def prev_month
27
+ return self-1.month
28
+ end
29
+
30
+ def to_de(options = {})
31
+ self.strftime('%d.%m.%Y')
32
+ end
33
+
34
+ def short_date
35
+ self.strftime('%d.%m.')
36
+ end
37
+
38
+ def to_sql
39
+ self.strftime('%Y-%m-%d')
40
+ end
41
+
42
+ def month_name
43
+ MONTH_TO_VIEW[self.month] rescue self
44
+ end
45
+
46
+ def month_name_full
47
+ "#{MONTH_TO_VIEW[self.month]} #{self.year}"
48
+ end
49
+
50
+ def month_label
51
+ self.strftime('%m/%Y')
52
+ end
53
+
54
+ def to_i
55
+ self.to_s.gsub("-", "").to_i
56
+ end
57
+
58
+ def to_zodiac
59
+ zodiacs = {
60
+ [1, 1, 1, 20] => "Steinbock",
61
+ [1, 21, 2, 19] => "Wassermann",
62
+ [2, 20, 3, 20] => "Fische",
63
+ [3, 21, 4, 20] => "Widder",
64
+ [4, 21, 5, 21] => "Stier",
65
+ [5, 22, 6, 21] => "Zwilling",
66
+ [6, 22, 7, 22] => "Krebs",
67
+ [7, 23, 8, 21] => "Löwe",
68
+ [8, 22, 9, 23] => "Junfrau",
69
+ [9, 24, 10, 23] => "Wage",
70
+ [10, 24, 11, 22] => "Skorpion",
71
+ [11, 23, 12, 22] => "Schütze",
72
+ [12, 23, 12, 31] => "Steinbock"
73
+ }
74
+
75
+ zodiacs.each do |key, value|
76
+ date1 = Date.new(self.year, key[0], key[1])
77
+ date2 = Date.new(self.year, key[2], key[3])
78
+ if self >= date1 and self <= date2
79
+ return value
80
+ end
81
+ end
82
+
83
+ end
84
+
85
+ def self.month_array(start_date, end_date)
86
+ dates_start = Date.new(start_date.year, start_date.month)
87
+ dates_end = Date.new(end_date.year, end_date.month)+1.month
88
+
89
+ dates_array = []
90
+
91
+ current_date = dates_start
92
+ while current_date < dates_end
93
+ sdate = current_date
94
+ edate = current_date+1.month - 1.second
95
+
96
+ dates_array << {:start_date => sdate, :end_date => edate}
97
+
98
+ current_date = current_date +1.month
99
+ end
100
+ return dates_array
101
+ end
102
+
103
+ def months_between(date2 = Time.now.to_date, options={:abs => true})
104
+ date1 = self
105
+ abs = 1
106
+
107
+ if date1.to_date > date2.to_date
108
+ abs = -1 if options[:abs] == false
109
+ recent_date = date1.to_date
110
+ past_date = date2.to_date
111
+ else
112
+ recent_date = date2.to_date
113
+ past_date = date1.to_date
114
+ end
115
+
116
+ return ((recent_date.month - past_date.month) + (12 * (recent_date.year - past_date.year))) * abs
117
+ end
118
+
119
+ # first day of current month
120
+ def first_of_month
121
+ Date.new(self.year, self.month)
122
+ end
123
+
124
+ def self.end_of_month(date = Date.new(Time.now.year, Time.now.month))
125
+ DateTime.end_of_month(date)
126
+ end
127
+
128
+ def self.prev_months(i=12)
129
+ dates = []
130
+
131
+ i.times do |x|
132
+ dates << Date.new(Time.now.year, Time.now.month)-(i-x).months
133
+ end
134
+ return dates
135
+ end
136
+
137
+ def self.this_month
138
+ Date.new(Time.now.year, Time.now.month)
139
+ end
140
+
141
+ def self.next_month
142
+ self.this_month + 1.month
143
+ end
144
+
145
+ end
146
+
147
+ DateTime.class_eval do
148
+
149
+ def self.end_of_month(date = Date.new(Time.now.year, Time.now.month))
150
+ date = Date.new(date.year, date.month)
151
+ (date+1.month)-1.second
152
+ end
153
+
154
+
155
+ # sql-formatted string for datetime
156
+ def to_sql
157
+ self.strftime("%Y-%m-%d %H:%M:%S")
158
+ end
159
+
160
+ def months_between(date2 = Time.now.to_date, options={:abs => true})
161
+ self.to_date.months_between(date2, options)
162
+ end
163
+
164
+ def to_de(options = {})
165
+ if options[:only_time] == true
166
+ return self.strftime('%H:%M')
167
+ else
168
+ return self.strftime('%d.%m.%Y - %H:%M')
169
+ end
170
+ end
171
+
172
+ def self.new_from_params(p)
173
+ return DateTime.new(p["starts_at(1i)"].to_i, p["starts_at(2i)"].to_i, p["starts_at(3i)"].to_i, p["starts_at(4i)"].to_i, p["starts_at(5i)"].to_i)
174
+ end
175
+ end
176
+
177
+ Time.class_eval do
178
+
179
+ def self.end_of_month(date = Date.new(Time.now.year, Time.now.month))
180
+ DateTime.end_of_month(date)
181
+ end
182
+
183
+ # sql-formatted string for datetime
184
+ def to_sql
185
+ self.to_datetime.to_sql
186
+ end
187
+
188
+ def to_de(options = {})
189
+ if options[:only_time] == true
190
+ return self.strftime('%H:%M')
191
+ else
192
+ return self.strftime('%d.%m.%Y - %H:%M')
193
+ end
194
+ end
195
+
196
+
197
+ end
198
+ end
@@ -0,0 +1,10 @@
1
+ module FriendlyExtensions
2
+ class Engine < Rails::Engine
3
+ engine_name "friendly_extensions"
4
+
5
+ initializer "friends.labeled_form_helper" do
6
+ ActionView::Helpers::FormBuilder.send(:include, FriendsLabeledFormHelper)
7
+ end
8
+
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ # -*- encoding : utf-8 -*-
2
+ # All dit janze zeug laden
3
+
4
+ require "friendly_extensions/engine"
5
+
6
+ require "array"
7
+ require "date_n_time"
8
+ require "numbers"
9
+ require "hash"
10
+ require "string_and_more"
11
+ require "boolean"
12
+ require "nil_class"
13
+
14
+ # SmartCurrency jetzt auch hier (26.03.2013, 16:30, Florian Eck)
15
+ require 'smart_currency'
16
+
17
+ ActiveRecord::Base.send(:include, SmartCurrency) if defined?(ActiveRecord)
data/lib/hash.rb ADDED
@@ -0,0 +1,38 @@
1
+ # -*- encoding : utf-8 -*-
2
+ module HashExt
3
+ Hash.class_eval do
4
+
5
+
6
+ # returns an array containing the hash values
7
+ # ordered either by hash key or hash value
8
+ # userful for building select_tag data from hash
9
+ # tested
10
+ def ordered(by = 1)
11
+ if by == :key
12
+ by = 0
13
+ elsif by == :value
14
+ by = 1
15
+ end
16
+ self.to_a.sort_by {|x| x[by].inspect}
17
+ end
18
+
19
+
20
+ # useful function for extracting form data from serveral checkboxes which will return a hash like:
21
+ # {:chk_1, => 0, :chk_2, => 1, :chk_3, => 1, ...}
22
+ # .extract_data would return [:chk_2, :chk_3]
23
+ # using slice = "chk_" would return [2,3]
24
+ def extract_data(slice = nil, trigger = "1")
25
+ data = []
26
+ self.each do |value, status|
27
+ value = value.to_s
28
+ if slice.nil?
29
+ data << value if status == trigger
30
+ else
31
+ data << value.split(slice).last if status == trigger
32
+ end
33
+ end
34
+ return data
35
+ end
36
+
37
+ end
38
+ end
data/lib/nil_class.rb ADDED
@@ -0,0 +1,12 @@
1
+ # -*- encoding : utf-8 -*-
2
+ NilClass.class_eval do
3
+
4
+ def to_euro(label = nil, options = {})
5
+ "unbekannt"
6
+ end
7
+
8
+ def to_de(label = nil, options = {})
9
+ "unbekannt"
10
+ end
11
+
12
+ end