From e600ab67b135cfdc9ff38d7aad76b9f99dc03e96 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Sat, 30 Sep 2017 18:56:33 +0000 Subject: [PATCH 01/40] prototype new site --- app/sites/proto_site.rb | 56 +++++++++ app/views/layouts/proto/_index.rhtml | 1 + public/images/proto/logo2.png | Bin 0 -> 21211 bytes public/stylesheets/proto/custom.css | 172 +++++++++++++++++++++++++++ 4 files changed, 229 insertions(+) create mode 100644 app/sites/proto_site.rb create mode 100644 app/views/layouts/proto/_index.rhtml create mode 100644 public/images/proto/logo2.png create mode 100644 public/stylesheets/proto/custom.css diff --git a/app/sites/proto_site.rb b/app/sites/proto_site.rb new file mode 100644 index 00000000..1b33d5ab --- /dev/null +++ b/app/sites/proto_site.rb @@ -0,0 +1,56 @@ +class ProtoSite < Site + + def site_searches + ['housing', 'Australia'] + end + + def aliases + ['proto.find.coop'] + end + + def dso_filter + nil + end + + def state_filter + nil + end + + def country_filter + nil + end + + def should_show_latest_people + false + end + + def layout + :sprint + end + + def custom_css + name + end + + def use_logo + false + end + + def title + 'Proto Find.coop' + end + + def home + 'http://proto.find.coop:4000' + end + + def menu + [ + { + :name => "Home", + :link => "/", + :id => "manitoba-button-find" + } + ] + end +end diff --git a/app/views/layouts/proto/_index.rhtml b/app/views/layouts/proto/_index.rhtml new file mode 100644 index 00000000..6174c9bf --- /dev/null +++ b/app/views/layouts/proto/_index.rhtml @@ -0,0 +1 @@ +<%= render :partial => "list" %> diff --git a/public/images/proto/logo2.png b/public/images/proto/logo2.png new file mode 100644 index 0000000000000000000000000000000000000000..8af9561c8dbc6eb9d8be777aabf4c4d37179d1c0 GIT binary patch literal 21211 zcmXtAcQjk?|Bs!P7NtaO+M+dU?@^;DN^5Vi_uiYL6<9BnC+>>*1PwxA9p8I~Sn@{hw)gIh`avuNyJWzk5tOo!PP~rEDfQ0zhMp}6s z{*BZ|Q%xCg_rFJBcSRchlY5?TjC}wAa+?1=2>{u-ApD19zUo>kWE=OGX<46sSadf8 z0N4QP%8DNXmzujBe6~hf_}cvK2Z*+fMBIMwW&BP(3_{(s(F?IYx9RC(z1XqX{Rwqw zGVZz0pJFff^i76hiff)Ug(}ILXuvPm*0Uu>TXJ#$T|j}f{89}phV|e;-Zz|@1p^JE z4)O8m#4;_9#v`6C^>Q9qOm&zptg;5k2k@&Djz+NDK9UY-K3hNU50Vy3Ih`S%n~i8~ z9h3)!jLNvep02KTZ;sZ)EPrI%YXc^)-uQnz=nt=Fb_otZ#>`jLU>pPFH?0QT5CUKF zx2XvZa6^048O zkMohsA!Kb=*Q+5oq*+PGs8vHet% z`g@^BQmn{(mL!mCj_suN?V~#nVR`xQFGo zx)wuhcYdCQ%}~f$eEoY4Su_uE`~vEW7$s{s>j`RF7X0-(K!%F3rRkq+8-`1|;2odD2W5P9$dYsn@T zlgbtgAK&TMprVimuB~AIqfcENua{O^AX1NIh^t;b#s ze4hpslE(%2{gio?9TZ#H4l6-tf9{spXrNj|COMoPF0=D>q8)oluZrT&1}&JrTn&DA zd!VTXp&%IYFSvSXSAK;-e$DFT3_hc_ppu2p9J%r?yN&LH-|f~N&mI2J?%eE`v+u$= zysLz|X)R@3^zIOlGEN@c99(OiO& z3?aFcI7b|$M`?5gZ1fP5k3X|T!_R+D&MA||IERLRc{%K^{kZcWwEL3IaE1Il%jEhA zeDN~zp;OS7n8aQVv&KMo@?ufHWJc`j7da`uNkgC%v)Zp)E!@6~A4E2_XNA)43}pkW zCc-^`d7xWm)9atPtfn~Vi-XbMbIbq8)1~7Smg<&BeUV!%noSGZ zqZDNKGQsH|ncw@=eeAzEG|m)O{Sx`kEmQG20P=R!B1lje^Yz-_-du{4fN5;dS93E$ zbLI}nYHvzp5>iNWpnG%9oj=40xV)O#8Vud`3ZEnTUUy)GyHY%R{Vu_C<=L{h=>A{T z21`!ikON)VTBE^{<@H=a1E(g9lY3kCF*MUn0b)^*FP0MmesrQePecU zL=BYjdfvuulyL5NRARhcDpFCJn&m3t-zh;=2oufKi-z{H5dVqE5|x`<%U@p92kAN? zy_XRymq*eYXKbV1W&*5x;~_sSn^{knuXrKd;`Qe zqGZ5LzL{x&RejagJ_2&$k?X`7)+oDR8eiXd!`O*sZ)iA6sNEeml#|P=kKta}eCX_; zdS~U|(Z3d=HDx}7+}LCxo9Y8!?9=4sk;LbZF_lmb0kE4w+@%ySD9Cz+It`5F*CHw zKIbCaBENj$6gu;B{YV-1B|BET@OpM_wPj)7ZJUht8hJ!W>;KT}XJ6q`g67V^h946NR#=TB2p)2>1?WBu7(`|@9f7j^` zCE5=wZGI=7tTMzh{etN}EPrxkGv6Z_Gavc118q zQ#|-WtGjAQ-{gmobt>x3{1ymFDIyD9NnSEs3ff6l38s2?=$o-$60l*&kg?gP8gTE> z%l1MJee?a((TR}%^+oL?dKXHsnYz)(uHv4q0rBnf^ti7qoi-3K9cd&qo^Hfn*&a7B zDck=xzIg_z-|_``pH(^IXz)sE4j8ClBIS>g74MLbYcORN-XDaDe7R?JsF)%Bt#(+~ zo^3U8bMbZ5$^mgS89JTiO{Z^DK{8#G+pI;;NF>v@temPw_rXR7Biu^U>na4hj9Tf( zLzR1XwWTsvru$K8VYp_TnBGDG*)qXzIntKk^c5LfXIBSBkBUsFpK(ZT{k5Oxb_%RB ztKn*G-1>4`s7iB`Mp|LCP)aLl@z<5*Gd^F?*i6gdSd0Cff2=$6V2^l3yHEWUamc%X z3h&jsDcO%%qd(H(ojnk}jm!5Kq_WX~WZ`rVzE9oK5+W{VESASYaA+dH|B6ESYGiIH znc^*(hCS;x|JnmjoNY~!U#rm{qj7K3uYX@kT`icu&?1Zfbr=}jI3mmhm4N7Ut9`mxORa)=>kBng zUNqj)V+YrBtHqr${v*8UJ?+)qG#>&6m^&1%*pq~2mc*u3g=eOSTJwhyZxUAnc#Q)L z(A@fm>{(u9JF0K?I`ZsVnag6uzCJSH6!34UhC13xEBXr0`h``%Iyl3l^$zSw-equ4 zoHevNqFOTo0=&e%tDX_ZI@Xnlo=$0a_Cz#xS{WB}zsq>{M1x)6E9xgXtx9Kel9H|x z&kxdgMJRN}9{DY}khO1W%Y|gIFayv>viAf4XQU+oDSG}Em3VDjM$g?ER_Fo-dvxg>v!#p1 zUkT?3vAge({KcO7Dk)E5X3@|9GyZ-O;9u-gyHU-OpQx(lnA)IpfToLQR7bR)fy*P7 zghE=GS#9^ZKAd7~IBVLy*uJrQaF^4NpX9$qNr{Ze%iie&2Xn&gSsy;l{mDZDE~Nbf z(ul&WT73DPWb=(A+SAar|==EL-HnM!Z0m`uF+@07RI*tK6yhSiQ+CxZ6T5>uCu! zC?@@%Ea2+{h$2;C%D>4RKVgyz0h0~ zsni{yQKWjR{tJy&&ftLb8A;FEePmmRUfnm?^VhUmxi>WPCQweogH=!CeFhpU1;bRn zD05BM%SVw|e=l=_qc4m<3%Zs$cB^I=JF%TlXTJz@Fsdd2Gm7{aUkTT5+11pbT>HB_uzXzBG%zhg?wqH3# zDRG?6I!fo=o=gZ_JQtW~bb3;g?qvx#apSG-{zURA!RIi@V*SdRc35{yOtBY1ZyeW0 z1_nScT}`bZADt`FV|Bf^si+|Hd9As&iM5gM5a1z;vhq*@2&@eGaYIz?N4Xwi0Y`TS zU+7W99rSn+O<=~bnXMj31G{;Vq;^r-R>PilIWWYB{4$Tywj;NLOc`B%wOX-rIxL2nH~N!~b?~T9Gm^&0oGUER?Y6 zuTR+utF0)CJz29B47#Ty8Dlz>QlkNGUp=0ujk$`M)*_ffyX%R%UK1A(7{ABb zdwW^+uj}b29sC9p`1-siT>ZUBqhH)IKySIS_^Ij~@AI^X8? z23*RzsK!kzHb;_la|L(9{W<*h0(BfXx!GpM%i%C4ITv)hbFh37S_^${V+}Hs3GzPM zH-0G`AEiO&?|PKNFnf5fv0nS?&rW2^S*+VU=4{ND^E$qu;V4>$=NWIcsB*ep*7^#_ z=ifm&%7Fq_&*oVn3#gC zg_s@)$eVY}pM}XMZypDRUTzU~vw%jOKMJl;dgn_1VKQUe5F`zfy9&Lyz@TJcd2gI+ z7*Ls+1tXh60Py5hz)`c1<8SYV@35Uk6bva7k#Awf1_Tsxn+PP%hTHm~^SzQKqC|~Q z1p)%{5j`tgl2L8z8a&g(qhDBI+B%B1kf5uxB>0j^r{k8dRCiZb=<%Q7^|3U#5IEEU z=B2GpVI`S&d$#OhXlUr*;Ly#x84W`vHu9o78tIf0o@!YsLbS?hxHvbDjl{g07LC9l z2VL5$o?a8a8mKju_w?O01|~>xrAzxD{-8&6XK!yJvr0hU{2o7V^=z#lr6(lh6nWJ^Y%+gXCTYzfk>f+MjZxq4EP%6xc*ctESgmzodaF!%d zaZtoGa;ue4EA$7h5K{IWjd}@8K!oPTY@sIK%Ag}gMkQLbYI@`Mw20}wm>i79+kaH< z?P0z_GlcxTy-&6$=;uWehi%02dP1=;B;?iV;<3RFywm&5?iDI?>4t_!Yu!0hD2Oi8 zFnTIZ2#&U+r`L%aBp_jrRWN^yoDW; zoUQ7aGBjr2l-zy3J&{STlYdG^1kf^vl{bld+;&`^41;LmHoV*SaKRJXdM;YZu!w7F z>o%DEb~H9vM@AsIM0Ffr0Db-WCrkuow46IZx8kq@`JhXYLoAhw+rEYVg|}bO#qLC= z3%Gf<6zZNmLbJBYw~~K$b9*kLC0vu9?%i$jvaA{knYHgG=#xCM>-Mnhl8}}Cc(mM+ z|Moe4ye2T$bE99B0_}_$z_s7>G;ZE(<>hfsy`u%X4*+b|#fK6buTOTS@T+s8vKcP* z{<#EeL2f8+HDHot^r7q9UlJ6SaYaHqm~Dp|?B6ZhSM9eqIQeF{PVW^XU>JIB4_M=%tO7R#t8}`UVB5D?4R}WBv>W%ACm@%~j~+ zqr%Sr74hObZ9bK<>#Mx`(_}II7!*vcB&ER~YStZe<=<{LiSilw-n86vgzngJXNyer zZZ|vcVO8^*dxP>4(E>wAs3#gZBgt4ClY5?tT}Rwm-su?5{L*Jo#nr!{8~_Ed0i(Fm z_5E&k=gQX2;J+k)=c6+1F7|ilBCa=Cy;6;8c(mG&D)2q5-?{z8NijFMk*U5u6|tTM z&$d$p+b`NChJ+|DZjupGX)6d!#T-!}AK{+;oMONPZnA43kmh%@HI~L2amn-M5h$iy zk+$>T&*(9mc6RyV79&8BN<>dCt#zTgtk8a<~}?OLv?`8_eZrV#*@+4cD) zb}^A2NEpjL?Dc4r#Zj){W!Z-kP>PU=sK!gTYKG)EDi#^mk$nkGx}TWV-rJM2spZPb zV(#(AYF>?zzo)0CSRMH}Pau1rU-0p84goqZR3Txl=DNOzlyK(WO z%0R}GNPFcHta5u5adU#m5kK??z|o@M{r%H@*1OG!f3v`RG9=k%jpRw#bl}g$tzZsx zworMxd$xVk7+C%d^PXQ~Xdp|%$?%^q^0$C}=k`YUL(-VL3)tPo$^3+bRty+jbUl~HqYdyS(0c@a`P`cp$d{q+X8H3yl{P<~O&OG=S~55H9y~er_bJ8e z5hGn%MXIfwsrmWG)x&>Fp~3?$&(g>pr=s6!{FnZDvyJ^oT#nB)3^uKtJpfXs z9sp|eKRG8z{f-UBuja&(g(sX64!NVc6ks+9h*Lb6LZ*O>fLh<~o(mMN>Qd7TUwT5L zHhXbFBEx#4NUkz;yt`dMK3n7cLL|{Y3JTfNe(pEY3wk|C1umwkJT{TtX zpecr`@o}TH=ev~1yGTV=$ZID-Qa1&PX(2H06AIFsp4kp3Tl0D2jGdfonEY*eq9kNi zzdJ3Mf5O22^EKiQCy(q3djG9#w&O+BQ|;;o$alZeQ%+kP&q|n47;@v!M;#6Ms%m-|~EWzAKL(RSZ3n?Q?UwE|bqR0u99g zK3OI4O{5CZsmxvse>}Pxz*td_j13PDUtCC1r#_w481xS33WI< z1&kPjh@I*v2~&xc*Fz^lmR_$(OP6?5H1SIRv}3tH$j|H(ziSn60W=jX>`WC~XR6Li zL63=ULWEg97Ey6Pin-|N*O@ff|Cx%b!&h)2#^q28{>+@I@|0gw&m%8f;m;i==_nOU z&sl=QsA>#dT=s*Za1Ei6YG}_(FtU67cX26ZN#3K}HN zq9=4WX>`5ohO{s6s@JR!6kC)dR07qTa)xUBv6af}3Bf(o=r@Y&`<^>hbm}TKuhAQU zo5pn`>MRRnBOb~-61-;rFjsBx5=Nu`NSYH|Bf3OE8WUc}6-(tbo<>YOeQ|Noengh* zGs3M!7B1eA8}HON{bj5^tO}3F)ykm@h=q--IWUx3^7UW>_P==mXY_?tzhLL&)f>Lv(3fr)EgBGj8yF;rmAX z%30;dX*Va5c+pk)0v*Ud$CFK}6~h|?$FzFfU83vo@J$GfeNt{-la`jYF;@{_%(ihr z-(AW8(o7wCf}U)1W?GJv3%g#ZMnpn$9yGUuwH?E-hX(}_x5fy+>~cSI{KT@HwD$6T zB^P$f1OazDy>D&C+CO8T5nNuQnohAc8|S~lj0s3Wp) zPqmjFS~en&AnTv7-rrD?R!LB;x!?L@3^Bujq4(wcf*;rzd6)nUHRvw@#O!zu5BjJ` zbs8e;NnjHo=>f?9A{Y&CTC8>|70nQO2u_nYmWAPN($Z)^F;nGJQ=PmO=_4TWs&6gu zM=9$v_h0J-Zpm=KUYE>>)Yqr&9`)Yo(%EI$!$CD4Kp*S>#p0$g9#ksa6NkoXPSFZ8xJ%_*s*B{yuZzzRIe zOlQ22_w&FLmn3$!Phcbt27@UQtDSo(7YZum{*dYI$#1K+&qu*cz;9_)HU67*1ab)H z9Khk!880Kt)6~rkt*J(IhZuxM@L2c!_I#^Ue-O^0Wz9>Mc(L3%JpZ^dgJCH3^!jxF z`ucinix{F97(gppv&{TXAF~LdM%ytEXwA8bF_wMEF6WqFV|?nAEEcZDNpp>Ch86J}!foI8~V&tI_4d10sG% zmCIOCL&CYU->6qviypK6V=z@K1~954wj$%&qo$_` zjNT)BcKsJ$M?6Q8gmh^itLW>7O;b+8++WEP zS|_L$)%Kc2u+O-PrRh1BO;k3Hl&k+b!q&v>xEmPTGLT1ee;#0iq)BM$sZG?QAHx~@ z;Ehm0Kl2)cDnW_@*$`5s&&-=dRe!RL`WeRA*hZFYQtgyLLOmsbNyPcTjmyg=lha`1 zIT84G5v{W7tDFACT?W8To5NxGNFRoZ*fD@~2jf2|q^g?3JCXX-%R)J^wiXd_eYWf? zr8RfT+RYLhdBpiSKm4lZTWTXq0+rg=2MHztOp&N<1bI9gA07GVQ^BP^8wpS!o%MM5pmSe^2%9;+vncnhrknu2XHs@-uD!my*}1d zy}17xhU*Qxcobegx1^Y0(_qA((Q||^pTRfOr*fxep}`Gq&$em4ywL`*Ia;9CK%Zm* z>-;R%llwF3LZIj3IVi7Lc&##me5Bq&n#-@jC@`OloQn^@Q$~72;G>ZO^h?^_yRnSu z4#Cy_BsXFM>SnyV53v?3Z4!>Po`|6h=-?>!{Vy*8VUTtH|wgudmEysXjz1M#yn19(OcR90?`XOY$xu{rY@t z{gh&<5b1I8AWy^rMx@JECK{IjfkWPizCdpEpy+d$==8=7nHxu)g*q1kgpmd}mc^_K6 z(?GaQ63@h z5D~X1U#Tc4#0&84HE8hPa3Z~cWv}XbYwJ#Rx3xZdvSM>CY@!iTvf#*xHgP$)>cM0_ z;R$1Bv+K6#4Y@kRYn*x-_t=^E7c~+l(2I80*H;+M1@Dp0uUaitYf;x>NUg|iNeA7NH==y+Br$vn{ax*td z$TmxJ5j(9N!o>+BfVEDLNPdt1UQj->cX`>7GG!(B6Qjgf1LZ&A_*^_Yb`L^I4>Z-V zV{CjSCLyVwIz;~3Gr3Zg*1E}QZyb$H|D}{L?>#2T`amtq$FAyr59Krt-N}+tzS1g4 z?3LNq@%XV-;>9nOv?$qBEYf=+R)KbKVQj0T7LTV|K|qw5=k4~MroaTA8{PYmv2FY6 z;`DfPeqLXfHhK8(RS%Vt%PJb%6N26AEC^T1KFFl|&RA!HMx)g^?bgZMJ8g|CzwP8& zhV^_d`H8#128UrUoEwZl;7}yjOd+zjsQRdp?(oIBtLXw5Qd2b?%HQTWaP-DTU*FED z!;F{oMozM;wlZ^WtTW(Byh4g$-`lepc7Ny$P5Ys@zkT!cLWE8qjTFdjx2rZ6cN_D%12_`+Ap zoX=3>zjCJpYKIl0_p~2T7pMvcDnhjAFXG&T>`X@4KY9xAouG#<6OF#(->8S3{-`dw z&k4p-{fp`R9ng#1b1k!~5e=5gqbk8V*Cf&9J3vyBWEk_Yjgw*zBw4tG>T8sPK*74r zgUghmUw~RA&G!dqyg2h^f}#ZpBPD|O(bJSF+l7rC69X#@bSn+j0ZN%fYep5k3`wfm zX6Nn@RFI!J(K>|aY!H9VK=yKe?G7^Quzo<3AT$D+Xxtx5;}Yn-5tEYbE;2tjAu~79 zGY|}Zl|}W&<)Cehe>UamE(*_KBYJEhLLAd14iJTC3>)zBCft-X(A3kuH9l0BlI~wO z7Mof8^PcCcx^J&cxYP$EBkm5neOj~2$1r$d(oi3ZR~B(cYt&z#?*84{8XH#e_KK2l zs-ic|BjXlr?}>xvdeuN1G9nv!nc2meDP~08G?jci7Rn}Ej4$9Z$85DeSdbN3c{^!ph zTN%|1N#Kup&!m@Y9gA>x+1Q!6vduF*26rgT)ilp|MxYGg4enmEZ?aYz@-ow(Ki`V| zL##!_a!6}3lkubNU_k^hRo>K5`RV7As-))}FwB4;Z=yHUNGhY^CDWVK=1jY$U6JI? zr|PODY4id;8{I4lKQxAfWO{3qwDjJzoAH)#zc{(}zdvSD;wO)0Pi8**EGV=7WRsuX zSo60xURBnuL*&5d-Ie*t^M~#!R0vr1KMCj*1SS@H`UXw6&8oV{{>3fJYBj6OBGGo> zB3ej`MxCJx#~$u7D4!8L!1hnpa{Rfv4b^|;$IGWr04wT=Bp)`wbp}-yaKbYC*>(Q*aast7esRX?$DL^Gtj}sZ4)S+1&GXry= zw({TxFp3g<2stQ{hjSAXRK9>^2IXJnqf$?YV$<<99}IKZEeD7Q4K4}x9DLm#WD^i( zY^n2Hm2tW~am7kk-;ZgSi>t)ov3F0|uzTWJeOePvhMS~+qL`R!^j>6BQgt;~nvB>S#n4+j5^7KF<% z7o0U#>+WH;w*`8y8_jA>Z=re<^W!uF zZ6K?r<5=7vrTl4dcOMQT6M@;8+6petRwajFhJKK^z0Hwm?aU%0<93OujHWWGK~zCe zL9Gv;I=mI_KQ-4+Lq~JNj*P?$GayTxE+4w_#Z8~UNpXaKc86J3 z)o6K5&x>X*LGe-jk575V2^Gx$XKGo%JDn1&`y9!kQuzGS;k@=A$CocU{X#X5j;ga3 zdwz({ltWW1^R+8#eR+{v$;%#mafAJM1O~&~g~YiLoXX~iI~3jpbupR~VO{IZ^t*vY z+%_GxWP-mR`u(@`Fldw5PBKSZ66Joc2AVS!2OQk^hiAo)@H8g7R5{&4Ov7o!h-uik zj&iZEmYq11vL`~E-_XX(ROAtH)qG>+xT@H<7evT_k6y|W^3r#s^0)mT6+n8a%8>km zJo8-3Yb?T&RW5YKgoaI`V9GuRyOT42xfpRx_KOy7(;ka@9ayOgUr_8VKz$T?!e*Bv zqR!wDg#q0Z4v)52H!QCtyj;+m@|Bu5ft3prTGdoZ9*4cw(w{$6SP^uq&u%1{I8dVt!AVj zx@*O&-uDpA+6w9inbsKQHuO<~ggBmj(cyuZxa@q&TMxH10mf!v5h8ZFQfcAA!S|7! zLIUxhGD9$Yl%FW1f1Ql7{F*-d&xzUiE{EY*){|d62OG?Mj`sEs(t$ft57e(Kq zFNeQ>@OZGSlzcqueMWv>J{}9zd@!cH31`(MuCadb2b7N>ba#KmBsuk%5FqF;mQ$sQ z4Ur{O=NV*sszgPMLZM{T*Y!44qPi67xZ(yg1uP$4hN-%WFnzP*k*FL0pPywJe#fjo z51;W6o7Q6}F?VZ8j3%bngX@AgC_I3@T~z`bQ}F*>wk~Ys0-hoAQPe3^(SQ={?s@t% zb<-)OAy7Q@!hSO(|L6h&axl|iP@^seE;aL+90qT=k=)dxwamqX>@{gi?%mxBbnAh4c>v1ZwCo1XLYjhK?ZP&dUxLOBQP z2Y}N{HnALSbO#=6vAgQ)ZwFCJ>}gS1HN?W#bMgKb7>SYHNYWYkcb&1h@7`e6Vm4^{ zU`TQR*h9%fkC6nscAL;dDI}%$peoe8rC4IftKmQ;TUlkH>W{2}|5KH>Aor%zB&>&u zx%D*6!>K_QuC^ZU*`9I7mxr)lTQax5yKY*fg3?HJGG`i*Cu4l#Ixq_=hjus zaR>luKNdODMnQz~Q7XEp*Neh|EHacqhwzvGVw#$SrzOC=z-ZoyYEf&@0Hv7_Ec|f$ ztdoy?b8buoMn26@Oo>toe3Au=@`=w@Pc4T^Xb*_VwzJb zL`PfUx3fDBhLY7jGZX6y|CQ#U^$a-h+F~n5h9a6*OLjwu!${&*vW$U{b!e&UJGodW zr5DpB0X1G1nHPbB5VeJsm1CI#$#Jd%0tBAygfP@lb~!th@o)X9gp2%$_pA}6ro2Kx zN?i(`I=Kk{Yi*b6qoAlGF5Srl{8GN!d~ZY!Yt=v4qsH6OupKza1>&47gP-A1tdUI_ z$aebfm1uD7$op|vfdC$Yq6H~(n?)MgXBHQYcZ@V+Zj&sQmt<<|6m$V!RT|9rWnn%_ z=&PO*Z%Wb_HuXZ$ge6$XuU{=K{lO1h%%4krF2)O^z$mSU9H6k7V4p8yXY;FJ!(rXE zN4Z^mPpw#8)`n9(Ou5zDzYBnLsZ`K@gCKo<73IPH$lSX9&#WKGkTGHpGtKG@^8Zyg z=qcJwYzkA;xD@i^j{ggHt?2#Fhe?e7v-XHMc zzGg+vjUb57^g^HvK1NdOjKq9%j^;MuGXw*)UeoL3N`5Z>iIFjcjDQ>jtcmW)#X3=bDI!Uei z^%1-l!AQt}mU=2UFXE>k6Di}7b*Idon8VcTRej~%{sQllt%)S*Ri-3q4i@C*_TjwH zI$ZY@ZW0q`9Z&znvr-Ko`0Zfi@6N$clgB~qZ2)?=w22nN{K6@lhWaHz8wfSn%;npV z7j0b0EO5lC!Exe2Zqzfj&$IYYTJG_1sCCkIu4E?}82VZ{7C{JCoH@ca>-C^$-iT^( zKI`No{Icm@H%S;oK=gA5pB8AW9Axul{|e6*ejXcmdmVJQUwt43;+i4V;H0>^=@D&l zdNSSSna=^^#)WU2Gk{Ki5OO?Em4!Ot6%XSYZ-DDkFdUYUit}D;; zr|c`8+^ZjgAv|Tpf-;f}Q0AQUHLq^>UWU#z*~HFzxzDLhO@T6`oQ`30Uk`v_r2jp# zRWxK)n`OsKYXzr1wV;08nPH&OKJaBY)Iwhr)m5nh&^N{gcb7Y9k8mAW@M=ab@qg2x zrUq|ausE0jiyl`)$A?$kX{6m#Oa2Ozsy*u{`Y1f|VQ$6S8B~%stG=uyoZKHMy)J@f zezTp9v&SGjdUYz^Pq)uXY3T{ZH9AjxD9oL; zM#F?C(D)-2W4e!V6>^rH@(fYV?013lXnDDw(80dOpJ1E3Rw2!CXd$Y1A!w(9S4=x zu4wXu`5(sQ#oJh@=BzizsH^AA3LZ%ZAj6QU{m?j+8+4;nRDhzxtH#cuDa++S)0hv3 zCp+-XpHk#eiIWLi!(7*Q^SklKYVE!cP~NYO2dO^w&ObxFEUJ(1Ss1K4+Wm`Odn~!z z@;qhu-X30z7%(Y&GU`K6nEn~Bv+Dg84eoAn$(SQv@*IheVdu1OcAsF08hN%qP-vHv zsgF)=&+buOrTy{l(Wo;2gFXqA7wxFiXH|Bzo2Wz?^T4t_<}lMz-qPF{3`#i)G8S<0 z$qWa;VyLKC;5i+Yp)m2Kzyb1@zQ=>7Az^_m<9qx`J_s&G=boS9lBitao#LSW;d*&1 zJktRHDj#W-{8aqSh-VhO6fwM0sZUu>uatkkxyNIwcP18%8Xp#8v}F*xh^IVaGS{Pe&>P6Izk1s|lh_`-x*4ty;P z4nBK`c_4efL2Z>G-;b`GQoZ>}Z*K7s2B2Ym-@=1?H<2BOwx2MeO*|(u6obXwl3>X3 zhSiTG779{YV!q{J(Zj_wIxf;$J>zWeXh{?fPs{*!=BH@Rzs!f z??|D_7C$C5-#+Ii=l&?6lpm8~UWbvvg;~C2CS`ZvO$OI|$SxJ9Z~gkf_5qJBt=n$b zukX`q*N6yn3yUW;_+%JwF}HUut(jtkzO-~bUd3{56mheC9jhw#@biJ4@kFq%w2=nY zp!c>TA~Q47gh%}8bRdZMrkbnlZQ4^=h8Uoe|C}6*<9~`CgV4N4?r|}<1h_HdCpj>x z(K#*dA=kG@NlK}OwV6jqn1hdlMJO^r8=PG#-xHpfn}_uE7|=S5W(P7ipP!D=a6OH= z?c>wX&wxKxG1Nz&wUHh?3~HtGyE!{pUi2MFxV-5}#FnKSXWyRA=^S6EFuJVnamH`1 zwpax;Z3WHXLl>Hh%DP*h$%#?=`racU$+AxwfptkGxx@Z-{5`{+?v^)@8}X}$W-l|Uc~;W)LXHg`}77bdctJ(R{()m){bz&C246H zU=Eo{`!uwRv8IvWwAmtlO;kD+bGu$m##?t1nbn<3s2bB1)U9=gw3_ikgmN1~yBpxA zjTRG|6of!ZmUrpg6T_j3h1g&|iB`yQq#+)jWIbzv*kl0Bjte1lpXRE(SwQCh4uI;uPx_w;D657OOL{OP@(gOmCBa z)vgq_U;AF{{(9mwh-!_-aBEn02hWF`Y?YS?t=2pJeeUV-Z{hp`AI1w7D-a%0SRbma z%zpd4!s$Npwejjk`-lV`Eb|MiT==;ozNOFyZAh_WLv9fAJ=6KJoi0&Tex^ZQh@p13 zPO#a{Kdq=>eS=(KDoN)8E@cp@TLemVAn{15E}$!CYQUt^BBK4Wam)wd1^0u7v7Ga2 zb*}w6J*Ur~J#KZSzC+%j@4~Bv<2aA_6it1{ft60RwLNAQ78xq+IU^0ZcqPVeBWM5@ zT7wU{vLWo+_;d*&Q>etyrdbU}FcarjpXY5<8aXn(U0uH2!wb7S?Nj)`@UshOn7hQi;^ie;QEtQm-!y%Sg+rHKG=(! zE1aLXsZsn(so}fTs-s^Rj2QY4DPG~fVxHV?JPH>)y?KSVF+LpRxUrSJ4MRdnRP;G1 z-f60xcjL2lQ#s;E>5y3~311SylG(o%1>qX`GEsP;Bp2KE-$H}*TWXi02Mp%4+xS>5 zSK6lrQhYWScil&s@FviLir9-b$P2>ecvbviK3v3a;=VBaar29^Qdh_<#0T+|+w&mZ zUC31G(c)YK{Ua6{&|c}tiig{ohBJ`vp~^>BI?RQ4dsk1-S~VgUW1U)!z$a8<`nWXq zI+k3;l_TIj{-5`5g zF>!H?*+zBL%EHJ8f7HH^*TP%%VPAamJ;aC|%kUlmM@{;KJzRf#kD^HB_Bm6NUj)rN8*xSoxwR z9ToJpUNNHHjCVlrgH~GGBrL7M&E=mA8T~rNQlxY~XmISjtN|~VOkh?Njr{Z@uFsFn zcv9>ViZhA~GbVO@#R^0lHy{M{Be9BtPm=iaWfZfOJb#jU1<&b_F?-l;P@o);G;7^q zofdUa_|o6X>b0J*5M6|E#H;6tww3am;!kKO<{n^^k(R&OS@xJcf+o@C zeP3VH0$p@~b)2ddb7E}4yXrgpBO zrh#y8ew4@B+vha&E#>NZ2J^nJtRco=tBtE3gUZ@6Q#nK3H_EyoQpI}XI@t8| z#IJdi#i{44Npb4Ac>U1aZmN>W;&1kDNx3kS8iVQ3&e$-f(E%4t ze2_F<@6|M)D<>m|#xGkLmXJG37emDFg$9>rSh1L-s3`Tr|Hl7Yx$?ffi|F9u5(s#1 z4YVRU%Q%ery}DQDCj5<7)DFl>irag}$ERL!WFB348QO6ZimzO6b;RxBmbB=mAMJ16I@z$B z%Vm$=gR{=o)>bEz8h(5#+Hj9RW&T?V{yQ80wAo$7ax5cm{Cpx!8OVNpe85P^HcMN+ zyqt4&b#)MNLnIfb!ABG5g}-_K;}H@`G>dkx8_agdH?&?l@*jAVphpS0Z{tztfmp^j znwosluAVrw%YrK}Wy6%i%Q@9~_4Nk=%ANrMy^AaIGNE@E>t19x>qC5z1Yr0(UWhoT zS69|1N3-y*z2Du%;m!`Jdu@px-W58kv;zPhz5Cz)0$^+~Qr1l}LZ1OP!vAd?9-=06 z0`Qq1B%%&~=f`BIpC9)8+#IV8Wr>KmW+~r2IXPh!7q<+*+&wv*9AhbXn$%F?Tg?v2N59N3Wu<4^zHEh3!-R^b2 zdw+X79%n$9rb)ZjPy_wd1Vq4MLRRiW#3(5D-nEYq9NuA?%%HS?h3Ds|r@x+`pZELy z`{5k`R~M^`i;MMUv)yhlw_8|W+N^OR*zX~b)mw@dcd44-?REDor$ZaHm9k>LdaS8* zw!NzSMM3-FULGG`US0rTd%fM<+?XDnMxl2Sl{T4y;ez$%%TfOQSWlh#5Mbt6BgNxx zH?24O$Hx!?h+OETbQT~wK0N`z;r)I6(@%<=;JO5JzTHh z6^%`DY@^f3St;K>Fp8hhxAi;JEPfzgqGwk;eCYX;lxk8WQGyxH;CL26CGw^KB zy!+qlt3^BQ%C~I4WjpBVs%Ex29XULtQ%F?61|iqW-`?PO$f-hd_4~FhdnN*a@cIhZ z+dOuZsJ~Vvmo4HC-R*2v^>z#Uojr}?5x#r@LU?(xVx>+(yuG!J12xIS3yu(W`?xDg znjL)~jJt+_!4^Cyzx~ylpL8BtWE{n%i&OPe9gCrA&$Kc@IW>GMFx2;j2oDc%e-97e zArO4N14Ntgmu}ycPS%`lM6$YK-`=e-ayS}^sZl`JP->T-$~g0^^Q`QMq}6uGL-F=% z&wjnOxg^XmP4Ip&qm+&;(^+S4@e{O1fG7@G6rcb)LPgC{2{3xr>ow8hhEBw`HYKjt zJG?dyR{wBy3<%~%PLYQw6svEV52LS^=s$2{P3^8fDn!|+}_yS@$D7t_qK|I z2#9R6B*#U91+lo65X3wLSbdOcS0e(R;W!)LZq{ZjAcEJu*$V^pHfBoUNmHp^FYBi# z5n0{b#GESRb-yEEoRG_gk{Zf?p87+_&&l;yM7F63* z7;khvH+oq0NmC5V31D_jpA2xA?W^>%JRE?z=p+G*e_|Ig*5+K!lRLp}c+<;Uw=;G{S5E3+OD{9C-O3jiMpJst^K40xrm5x=xEvc9o@$UuR6#f5H9GK-q6GO(1MQ)dOReoYtc_*bSEE zPN^oA7T|Ob{W)l<%tyV?nL3+zeG~RMd$IkZ*0cgH^`<7)4k7ncq~)xsv01C1e!*uV zfz)lUi)PctS&C?x0T5snfSpfPcTN;xkCgcFTVth|?g@UxhYQe+ogDkKb8RPQF;TI? zK-`AIb}2~xS9W2TKrvEOp}4xpN8HXmNOi4>MU;>!PqDi=7maJ7}pnYKk$v zbmqRuqHfml8es3k*a+5sf|>IQVC=QGw#3?0-))J}aR~E|w-q1hCEm}NmJn2E(eJFiptQ{%lH+yTJ_W6aDAzJW+n1(uL z$@>=;43`UFku!p{(V(ZaVG}(^#h4+B=xis#Gmz z8eCQ9&$?D1uSW-GJ})qXWgmF=MI0>L_1n_xM#6R`P;b3;X2nwFV;OfHx?i?UC)!Ai zN|5x!LW;t-l(Y1!y+hCm{LZN~;#eJB$WrPwW*C)CQ800!=}fn1ksv4B0Vh$^YUDny z!19FWk1zlNQ$`4TsFYqqa-VOp8IFH^b8CnUUlS~29?g7MfFxi4kUFvaAUr&)y45}< zPdiygk8dg05@?itzbrnXrJ2x(qvWizbYY`m(_*V5g9_uASRZ_&UV8t%cPiE|$HDX*0MoT)iXI(P4hE*d%I zOp`@1K`_6-$aPD1ViU$Jy0@33$*i1FhwOeq7i$SFk&L9d?0!)$79+FtcV`!$U>cGl zbpR&V@zVBE$RZf?>ytRvJ*`d3<%)=ds0{7OC>Vxwk+-@95Q}A9-FPg$j-EhLB-TZX zaP9}`Fw7v{LtO5H949bmaM1^&vIz+D$oj-ExkU_%SKCKxa&q?B;D(k4bva)55qyl= zC7pQ4bdf$nQ3e2qrmEpbIIEe`hGf#Skhq?oPViRdFj_q%-;SH0k{)A$mZdogSRe=8 z(w;;S9yWwfa3>adOU`^CLM0YD^Nu7Ox!I!~p~=6KN5My588Z6 zCe@8sd_-IwqnpymVxB9p?tzk3(W*F;^BFgw3@9pTzQ*THOGXaayZTg_YyXyXc}6l4 zYBs_=wmjPzqe_O6Rg7C2$PE)17k&A>uJ!@A6W_mv8`$Jvj0=Xr@i`M7UjGnXo=7hG zYSBVwjF28++AvHc6YPoj>WoBxIqo`@+>fHNDaYjk4Q6Eg!IE~Q>j@Yu1f2&`f+Xer zRj!XkPLfeX`4`slNS9i7D(Rq`{e`k&(ourHs|T3CmH9zwWVsg{liIx2V8!C3Dj`N~XelftuxXFO~u zmS6lYNo5F>c7mqVxyb$-sQ4@2<2nDjXJ0;KCv{*@mh-loGJSbSYkvb%R$#E zU)kiBZI#r4MJ0|#Y$L^|`6vrcIRiQ!I4-pFY?EaGay$bWLJ&*)K*g^^9ySOe`EDYXISE|YTar}{p-w(gpTJ<{E{l(=A;493VX;<~+!K)VGK&nkrTcC1 zq%$REnn%(u7hKFAX!6Gm;!! zumy}5<^*g21c7^7LItxwoJQo+6khu9XwXvm%?bwq+ribjRfJh2(BxjQ;2H9ncgPpK zw#U@vL#)?GB@0Z-WEf%u&$%*_z1Z+6$g2f1UxDGhvgQ8YVz< zLq6#-XUw#@{=&Ng0GzEN*=)v{a7YoQuN>QxG-b@C#TCy8<(q!yCMv6fBFu4-Ch?|R zOMSt!wN0Caf~4@6fs>)7H)aF}+MRHbyPMahsh@hxUs+f zv~CkYI&D5M1J~HBurY(WvrcKdm^3^i5CJ0=N!me&9$Lf|@=AG&rO=~NK^@V=Zf!K+ z$S?sqhUKcswwuGuVn=_L!bmC}Dv$?(YnNLJ#^#v102U!DMy*1))~{?QZpkgd;Y1&c z)2Vaz;=iHS43kNP}>j!=1Bq_^HNS6B4 z(XBoQH>!Acxx2Up@f}T>Vxm76>3$l@UIma+(aV5a6eQZCuiK++Y9SB|_bx6VI8F42g@%D1%{+bs=9lVKG7$XQLct z`>6&6vFegAgD^0RMT^jJhIxkLoX68pZ?9?_Kc^!eLgbSGAwngMD3DS`sOZIG56AGp zCUqGFT_cQrD2;)?0WEOuewbz0P!-6ag=#1bT4GKtXbJ&f9=rhDM+lS!O>dhmct&EY z0%cDMRyCrKzmJEFqD5mfopjMjW-xDKH_TA1QM&b|DJq-U7zWvJ#gcWcwj~DJo>0l~ zOX{%B+|bH$r&387EjFHp`~44{WFxXAh0H4Y79w)2urp`*xGlMWWLwixRS{27${DE( zj?xwUi0%Ia$9?*7w8(&PJZv=2QNl5{X~E;{;w&BSyU4))9P1dV5g=hkQyPv2g+l8K zIg=?;@Bjor0whsrZiO;8|3EXDtcDRFWs=eFkQio;av8hcl`4l3aqXgRm8a@m#~5XG z3`q_)Izr@_=!HQf`pvLdlG8oqgibgPv%M@q;$X9 zCk1X26_kKU#rp~>Q?RithLhPjUz#kxZIE8_vy^dHHHojrMu`yoPyqHfaLakJ@()M? z-d)eJd6*F}6o4rnYuJ`(C%PD0_q+7^1+s7%F(Vbv1XmOS%UJrDnWD-p&7eJKoMUX{ zX=gIn*)@_;z_5jdBoM^@8sg0p>6@owsQVM?Pf@5S$xKsOsiaID$GHX!HEuUUOB0W! z{3PfiL5CKiSo(C_!dw$nH@!w^`oOy&sTc;&%5CtY(lDOe6EOZC{}2B<+F*Hn%&q_c N002ovPDHLkV1hq@+yVdq literal 0 HcmV?d00001 diff --git a/public/stylesheets/proto/custom.css b/public/stylesheets/proto/custom.css new file mode 100644 index 00000000..c5397b14 --- /dev/null +++ b/public/stylesheets/proto/custom.css @@ -0,0 +1,172 @@ +html { + height: 100%; +} + +html, body { + background: #ddd; + padding: 0; + margin: 0; + font-family: Arial, Helvetica, sans-serif; + font-size: 14px; +} + +#pagewidth { + width:984px; + background-color:#fff; +} + +#front-bar { + background-color: #54b948; + border-top: 1px solid white; +} + +#front-bar .button { + display: inline-block; + padding:0; + margin:0; +} + +#front-bar .button-right { + display: inline-block; + padding:0; + margin:0; +} + +#front-bar a { + padding:10px; + display: inline-block; + background-color: #54b948; + color: #fff; + text-transform: uppercase; + font-weight: bold; +} + +#front-bar .button a { + border-right: 1px solid white; +} + +#front-bar .button-right a { + border-left: 1px solid white; +} + +#front-bar a:hover { + background-color: #000; +} + +#manitoba-button-find a { + background-color: #000; +} + +#front-bar .flip-color { + display: none; +} + +#userstatus { + display: none; +} + +.subtitle { + color: white; +} + +#header .header_material, #search_tips { + background-color: #8a8; +} + +.titleblock img { + margin-top: 20px; + margin-left: 20px; +} + +#basic_search { + background-color: #fff; + padding-left: 20px; + padding-right: 20px; + padding-bottom: 20px; + margin-right: 20px; + border-radius: 10px; +} + +#search_tips { + padding-right: 20px; +} + +#search_filters { + padding-top: 20px; + padding-right: 20px; + background-color: #8a8; +} + +.example_bubble { + border: none; + border-radius: 2px; +} + +#maincol { + padding-left: 20px; + padding-right: 20px; +} + +#button-help { + display: none !important; +} + +#footer { + padding: 10px; +} + +#testing { + font-size: 200%; + text-shadow: 2px 2px 8px #FF0000; +} + +#big_front_map .surround_map_insert { + width: 100%; +} +#big_front_map .search_listing { + display: none; +} +#dso_status { + display: none; +} +#maincol.welcome-page { + height: 75%; + padding: 0; + margin: 0; +} +body.welcome-page { + height: 100%; +} +body.welcome-page #bigwrapper, #pagewidth { + height: 100%; +} +body.welcome-page #big_front_map { + height: 100%; +} +body.welcome-page #all_update { + height: 100%; +} +body.welcome-page .surround_map_insert { + height: 100% !important; +} +body.welcome-page #big_front_map .map_insert { + height: 100%; + padding: 0; + margin: 0; +} + +#legal_structure_filter_form { + display: none; +} +#sector_filter_form { + display: none; +} +#organization_editors { + display: none; +} +#organization_edit_link { + display: none; +} +.listing_menu_bar { + display: none; +} \ No newline at end of file From 52876281810740d42bfcc6d92ac6bda7d02a7e37 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Sat, 30 Sep 2017 18:57:27 +0000 Subject: [PATCH 02/40] tweaks for prototype site --- app/sites/default_site.rb | 2 +- app/views/search/_filters2.html.erb | 5 +++-- app/views/search/_list.rhtml | 2 +- app/views/search/_map_core_leaflet.rhtml | 7 +++++-- config/ferret_server.yml | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/sites/default_site.rb b/app/sites/default_site.rb index 4c3a652c..6e1f5866 100644 --- a/app/sites/default_site.rb +++ b/app/sites/default_site.rb @@ -5,7 +5,7 @@ def site_searches end def aliases - ['find.coop', 'www.find.coop', 'proto.find.coop'] + ['find.coop', 'www.find.coop'] end def layout diff --git a/app/views/search/_filters2.html.erb b/app/views/search/_filters2.html.erb index 24537326..0bec9021 100644 --- a/app/views/search/_filters2.html.erb +++ b/app/views/search/_filters2.html.erb @@ -6,6 +6,7 @@ <%- unless filter[:value].blank? and !filter[:has_default] -%>
<%= link_to_remote( 'x', :url => {:controller => 'search', :action => 'change_filter', :name => filter[:name]}, + :complete => "jQuery('#search_form').submit()", :update => 'search_filters') %>
<%- end -%> <%= refine_filter_label(filter[:label]) %>
@@ -69,14 +70,14 @@ function filter_apply_change(e,name) { lnk["ac_label"] = a.label; lnk["ac_link"] = item; lnk["ac_cat"] = a.cat; - new Ajax.Updater('search_filters', item, {parameters: params, asynchronous:true, evalScripts:true}); + new Ajax.Updater('search_filters', item, {parameters: params, asynchronous:true, evalScripts:true, onComplete: function(){ jQuery("#search_form").submit(); }}); } if (e.removed) { var a = e.removed.text; var ac_link = "/search/change_filter"; var params = {act: 'remove'}; params[name] = a; - new Ajax.Updater('search_filters', ac_link, {parameters: params, asynchronous:true, evalScripts:true}); + new Ajax.Updater('search_filters', ac_link, {parameters: params, asynchronous:true, evalScripts:true, onComplete: function(){ jQuery("#search_form").submit(); }}); } return false; } diff --git a/app/views/search/_list.rhtml b/app/views/search/_list.rhtml index 02b01e3e..d7809446 100644 --- a/app/views/search/_list.rhtml +++ b/app/views/search/_list.rhtml @@ -1,6 +1,6 @@ <% if @welcome_page %>
- <%= render :partial => "search/map", :locals => { :name => "all", :link => { :no_override => false }, :immediate => false } %> + <%= render :partial => "search/map", :locals => { :name => "all", :link => { :q => "*" }, :immediate => false } %>
<% else %> diff --git a/app/views/search/_map_core_leaflet.rhtml b/app/views/search/_map_core_leaflet.rhtml index 550c15c9..5d2f0901 100644 --- a/app/views/search/_map_core_leaflet.rhtml +++ b/app/views/search/_map_core_leaflet.rhtml @@ -56,8 +56,11 @@ var dx = <%= j dx %>; var dy = <%= j dy %>; var map = L.map(name).fitBounds([[x1-dx,y1-dy],[x2+dx,y2+dy]]); -var mapquest = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; -var attrib = '©OpenStreetMap contributors'; +// var mapquest = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; +// var attrib = '©OpenStreetMap contributors'; +var mapquest = 'http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}'; +var attrib = 'Tiles © Esri — National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC'; + L.tileLayer(mapquest, { attribution: attrib, maxZoom: 19 diff --git a/config/ferret_server.yml b/config/ferret_server.yml index 55f75413..03227506 100644 --- a/config/ferret_server.yml +++ b/config/ferret_server.yml @@ -7,7 +7,7 @@ # log_level: log level for the server's logger production: host: localhost - port: 9010 + port: 9012 pid_file: log/ferret.pid log_file: log/ferret_server.log log_level: warn From 60c4b51c8d1742fa44061cf1df7adb38c83cfed9 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Sun, 1 Oct 2017 23:58:32 +0000 Subject: [PATCH 03/40] gray out inactive material --- app/views/layouts/sprint/template.rhtml | 2 +- app/views/search/_teaser.html.rhtml | 2 +- public/stylesheets/proto/custom.css | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/sprint/template.rhtml b/app/views/layouts/sprint/template.rhtml index 4e9a9146..e946fbd7 100644 --- a/app/views/layouts/sprint/template.rhtml +++ b/app/views/layouts/sprint/template.rhtml @@ -13,7 +13,7 @@ Event.observe(window, 'load', function() { }); - + <%=render :partial => 'layouts/adminmenu'%> <%- diff --git a/app/views/search/_teaser.html.rhtml b/app/views/search/_teaser.html.rhtml index 2b5fc36e..85c3bb50 100644 --- a/app/views/search/_teaser.html.rhtml +++ b/app/views/search/_teaser.html.rhtml @@ -2,7 +2,7 @@ <%- show_country = true if local_assigns[:show_country].nil? -%> <%- show_state = true if local_assigns[:show_state].nil? -%> <%- show_class = true if local_assigns[:show_class].nil? -%> -
+
<%= show_link entry %><% if is_admin? %> (<%= link_to 'delete', url_for(entry) + "?recent=1", :confirm => 'Are you sure?', :method => :delete %>)<% end %>
<%- if entry.respond_to? "website" and !entry.website.blank? -%> <%= website_link(entry.website, :shorten => true) %>
diff --git a/public/stylesheets/proto/custom.css b/public/stylesheets/proto/custom.css index c5397b14..823e4447 100644 --- a/public/stylesheets/proto/custom.css +++ b/public/stylesheets/proto/custom.css @@ -10,11 +10,19 @@ html, body { font-size: 14px; } +body.tag-inactive { + background-color:#000; +} + #pagewidth { width:984px; background-color:#fff; } +body.tag-inactive #pagewidth { + background-color:#ddd; +} + #front-bar { background-color: #54b948; border-top: 1px solid white; @@ -169,4 +177,8 @@ body.welcome-page #big_front_map .map_insert { } .listing_menu_bar { display: none; +} + +div.left_listing div.tag-inactive a { + color: gray; } \ No newline at end of file From 299c2fcbdce613356ce07c6f121836dba117d2e0 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Sun, 26 Nov 2017 20:29:04 +0000 Subject: [PATCH 04/40] show dso --- public/stylesheets/proto/custom.css | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/public/stylesheets/proto/custom.css b/public/stylesheets/proto/custom.css index 823e4447..dd0aa6eb 100644 --- a/public/stylesheets/proto/custom.css +++ b/public/stylesheets/proto/custom.css @@ -134,9 +134,7 @@ body.tag-inactive #pagewidth { #big_front_map .search_listing { display: none; } -#dso_status { - display: none; -} + #maincol.welcome-page { height: 75%; padding: 0; From ea8e730eec0ea800143f9e773eb1f6bbbc9d89ab Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Sun, 26 Nov 2017 15:32:51 -0500 Subject: [PATCH 05/40] add groupings --- Gemfile | 2 + app/controllers/organizations_controller.rb | 7 + app/helpers/application_helper.rb | 1 + app/views/locations/_display.rhtml | 2 +- app/views/organizations/_show_main.rhtml | 144 ++++++++ app/views/organizations/show.rhtml | 147 +------- ...122031132_add_grouping_to_organizations.rb | 9 + db/schema.rb | 343 ++++++------------ 8 files changed, 278 insertions(+), 377 deletions(-) create mode 100644 app/views/organizations/_show_main.rhtml create mode 100644 db/migrate/20171122031132_add_grouping_to_organizations.rb diff --git a/Gemfile b/Gemfile index ac203bb5..0c29ae5e 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,8 @@ source "https://rubygems.org" ruby '1.8.7' +ruby '1.8.7' + gem "rack", "~> 1.1.0" gem "geokit", "~> 1.6.7" gem "google-v3-geocoder", "~> 1.0.0" diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 73cf3144..c5a6e3fe 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -25,6 +25,13 @@ def show redirect_to :controller => 'search' and return end + @peers = [] + if @organization.grouping + @peers = Organization.find_all_by_grouping(@organization.grouping).select{ + |x| x.id != @organization.id + } + end + #if not(@organization.latitude) # @organization.save_ll # @organization.save diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e8e52f82..56bb57e5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -219,6 +219,7 @@ def search_core_org_ppl(search_query,pagination,opts,include_counts = false) :conditions => org_conditions, :joins => org_joinSQL, :select => org_select, + :group => 'coalesce(grouping, organizations.id)', :order => org_order) entries2 = Person.find(:all, :limit => :all, diff --git a/app/views/locations/_display.rhtml b/app/views/locations/_display.rhtml index e5728b20..0538ee0f 100644 --- a/app/views/locations/_display.rhtml +++ b/app/views/locations/_display.rhtml @@ -19,7 +19,7 @@ <% end %>
'> <%- if @organization -%> -
<%- if location.taggable_id != @organization.id -%>Unmerged: <%- end -%><%= location.note.blank? ? 'Address' : location.note %> +
<%- if location.taggable_id != @organization.id -%><%- end -%><%= location.note.blank? ? 'Address' : location.note %> <% unless hide_links %> <%- if location.taggable_id != @organization.id -%> diff --git a/app/views/organizations/_show_main.rhtml b/app/views/organizations/_show_main.rhtml new file mode 100644 index 00000000..ea6d2b43 --- /dev/null +++ b/app/views/organizations/_show_main.rhtml @@ -0,0 +1,144 @@ +

<%= organization.name %>

+
+<%- unless organization.updated_at.nil? -%> + This entry was last updated on <%= date_format_long(organization.updated_at) %> + <%- unless organization.updated_by.nil? -%> + <%- if current_user -%> + by <%= organization.updated_by.login %> + <%- if organization.updated_by.data_sharing_orgs.any? -%> + (manager for <%= organization.updated_by.data_sharing_orgs.map(&:name).to_sentence %>) + <%- end -%> + <%- end -%> + <%- end -%> +<%- end -%> +
+ +<%= render :partial => "tags/dso_link", :locals => { :included_view => included_view, :entry => organization } %> + +<%- verified_nonuser_dsos = (organization.verified_dsos - ( (!included_view and current_user and current_user.data_sharing_orgs.any?) ? current_user.data_sharing_orgs : [])) -%> +<%- if verified_nonuser_dsos.any? -%> +
+ This record is in the + data pool of... +
    + <%- verified_nonuser_dsos.each do |dso| -%> +
  • <%= dso.name %>
  • + <%- end -%> +
+
+<%- end -%> + +<% if map %> +<% unless organization.locations.length == 0 %> + +
+ <%= render :partial => "search/map_core_leaflet", :locals => { :map_id => "the_map", :map_class => nil, :orgs => organization.locations } %> +
+ Meet the neighbors: +
    + <%- organization.locations.each do |loc| -%> +
  • Near <%= link_to loc.name, :action => 'map', :controller => 'search', :params => { :within => "20 #{default_distance_unit}", :location_origin => loc.id, :reset => 1 } %>
  • + <%- end -%> + <% if organization.primary_location %> + <% @zip = organization.primary_location.summary_zip %> + <% @city = organization.primary_location.summary_city %> + <% @state = organization.primary_location.summary_state %> + <% @country = organization.primary_location.summary_country %> + <% if @city and @state %> +
  • In <%= link_to @city, :controller => 'search', :action => 'map', :params => { :city => @city, :state => @state, :country => @country, :reset => 1 } %>
  • + <% end %> + <% if @zip %> +
  • In zip code <%= link_to @zip, :controller => 'search', :action => 'map', :params => { :zip => @zip, :country => @country, :reset => 1 } %>
  • + <% end %> + <% if not(session[:city_filter]) %> + <% if @state %> +
  • In <%= link_to @state, :controller => 'search', :action => 'search', :params => { :state => @state, :country => @country, :reset => 1 } %>
  • + <% end %> + <% end %> + <% end %> +
+
+
+<% end %> +<% end %> + +

<%= simple_format organization.description %>

+<%- unless organization.website.blank? %> + See <%= website_link(organization.website) %> +<%- end -%> + +
+ <% if organization.primary_location %> + <%= render :partial => 'locations/display', :locals => {:location => organization.primary_location, :hide_links => true}%> + <% end %> + + <% unless organization.phone.blank? %> +
+
Phone
+
<%= organization.phone %>
+
+ <% end %> + <% unless organization.website.blank? %> +
+
Website
+
+ <% if /https?:\/\/(.*)/.match(organization.website)==nil %> + <%= link_to organization.website, "http://#{organization.website}" %> + <% else %> + <%= link_to organization.website, "#{organization.website}" %> + <% end %> +
+
+ <% end %> + <% unless organization.fax.blank? %> +
+
Fax
+
<%= organization.fax %>
+
+ <% end %> + <% unless organization.email.blank? %> +
+
Email
+
<%= javascript_email(organization.email) %>
+
+ <% end %> +
+ +<% if organization.locations.length > 1 %> +

Other Locations

+ <% organization.locations.each do |loc| + next if loc.id == organization.primary_location.id %> + <%= render :partial => 'locations/display', :locals => {:location => loc, :hide_links => true}%> + <% end %> +<% end %> + + +
+ <%- if(!organization.year_founded.nil? or !organization.legal_structure.nil?) -%> +

Attributes

+ <% unless organization.year_founded.nil? %> + Year Founded: <%= organization.year_founded.year %>
+ <% end %> + <% unless organization.legal_structure.nil? %> + Legal Structure: <%= organization.legal_structure.name %>
+ <% end %> + <%- end -%> + + <% unless organization.products_services.empty? %> +

Products & Services

+
    + <% organization.products_services.each do |ps| %> +
  • <%= ps.name %>
  • + <% end %> +
+ <% end %> + + <% organization.tags.group_by{|x| x.effective_parent}.each do |parent,tags| %> +

<%= parent ? parent.readable_name : "Tags" %>

+
    + <% tags.each do |t| %> +
  • <%= show_link(t.leaf) %>
  • + <% end %> +
+ <% end %> +
diff --git a/app/views/organizations/show.rhtml b/app/views/organizations/show.rhtml index 9d4b26a8..e8d9c4fc 100644 --- a/app/views/organizations/show.rhtml +++ b/app/views/organizations/show.rhtml @@ -1,153 +1,18 @@ +<% content_for :title, @organization.name %> <%- unless @site.search_bar_in_header -%> <%= render :partial => 'search/search_form', :locals => {:hide_examples => true} %> <%- end -%> - -<% content_for :title, @organization.name %> <%- included_view = (params && params[:widget]) if included_view.nil? -%> -

<%= @organization.name %>

-
-<%- unless @organization.updated_at.nil? -%> - This entry was last updated on <%= date_format_long(@organization.updated_at) %> - <%- unless @organization.updated_by.nil? -%> - <%- if current_user -%> - by <%= @organization.updated_by.login %> - <%- if @organization.updated_by.data_sharing_orgs.any? -%> - (manager for <%= @organization.updated_by.data_sharing_orgs.map(&:name).to_sentence %>) - <%- end -%> - <%- end -%> - <%- end -%> -<%- end -%> -
- -<%= render :partial => "tags/dso_link", :locals => { :included_view => included_view, :entry => @organization } %> - -<%- verified_nonuser_dsos = (@organization.verified_dsos - ( (!included_view and current_user and current_user.data_sharing_orgs.any?) ? current_user.data_sharing_orgs : [])) -%> -<%- if verified_nonuser_dsos.any? -%> -
- This record is in the - data pool of... -
    - <%- verified_nonuser_dsos.each do |dso| -%> -
  • <%= dso.name %>
  • - <%- end -%> -
-
-<%- end -%> - -<% unless @organization.locations.length == 0 %> - -
- <%= render :partial => "search/map_core_leaflet", :locals => { :map_id => "the_map", :map_class => nil, :orgs => @organization.locations } %> -
- Meet the neighbors: -
    - <%- @organization.locations.each do |loc| -%> -
  • Near <%= link_to loc.name, :action => 'map', :controller => 'search', :params => { :within => "20 #{default_distance_unit}", :location_origin => loc.id, :reset => 1 } %>
  • - <%- end -%> - <% if @organization.primary_location %> - <% @zip = @organization.primary_location.summary_zip %> - <% @city = @organization.primary_location.summary_city %> - <% @state = @organization.primary_location.summary_state %> - <% @country = @organization.primary_location.summary_country %> - <% if @city and @state %> -
  • In <%= link_to @city, :controller => 'search', :action => 'map', :params => { :city => @city, :state => @state, :country => @country, :reset => 1 } %>
  • - <% end %> - <% if @zip %> -
  • In zip code <%= link_to @zip, :controller => 'search', :action => 'map', :params => { :zip => @zip, :country => @country, :reset => 1 } %>
  • - <% end %> - <% if not(session[:city_filter]) %> - <% if @state %> -
  • In <%= link_to @state, :controller => 'search', :action => 'search', :params => { :state => @state, :country => @country, :reset => 1 } %>
  • - <% end %> - <% end %> - <% end %> -
-
-
-<% end %> - -

<%= simple_format @organization.description %>

-<%- unless @organization.website.blank? %> - See <%= website_link(@organization.website) %> -<%- end -%> -
- <% if @organization.primary_location %> - <%= render :partial => 'locations/display', :locals => {:location => @organization.primary_location, :hide_links => true}%> - <% end %> +<%= render :partial => 'organizations/show_main', :locals => {:organization => @organization, :included_view => included_view, :map => true} %> - <% unless @organization.phone.blank? %> -
-
Phone
-
<%= @organization.phone %>
-
- <% end %> - <% unless @organization.website.blank? %> -
-
Website
-
- <% if /https?:\/\/(.*)/.match(@organization.website)==nil %> - <%= link_to @organization.website, "http://#{@organization.website}" %> - <% else %> - <%= link_to @organization.website, "#{@organization.website}" %> - <% end %> -
-
- <% end %> - <% unless @organization.fax.blank? %> -
-
Fax
-
<%= @organization.fax %>
-
- <% end %> - <% unless @organization.email.blank? %> -
-
Email
-
<%= javascript_email(@organization.email) %>
-
- <% end %> -
+<% for peer in @peers %> +

+
(Another related entry: <%= show_link peer %>)
+ <%= render :partial => 'organizations/show_main', :locals => {:organization => peer, :included_view => included_view, :map => false} %> -<% if @organization.locations.length > 1 %> -

Other Locations

- <% @organization.locations.each do |loc| - next if loc.id == @organization.primary_location.id %> - <%= render :partial => 'locations/display', :locals => {:location => loc, :hide_links => true}%> - <% end %> <% end %> - -
- <%- if(!@organization.year_founded.nil? or !@organization.legal_structure.nil?) -%> -

Attributes

- <% unless @organization.year_founded.nil? %> - Year Founded: <%= @organization.year_founded.year %>
- <% end %> - <% unless @organization.legal_structure.nil? %> - Legal Structure: <%= @organization.legal_structure.name %>
- <% end %> - <%- end -%> - - <% unless @organization.products_services.empty? %> -

Products & Services

-
    - <% @organization.products_services.each do |ps| %> -
  • <%= ps.name %>
  • - <% end %> -
- <% end %> - - <% @organization.tags.group_by{|x| x.effective_parent}.each do |parent,tags| %> -

<%= parent ? parent.readable_name : "Tags" %>

-
    - <% tags.each do |t| %> -
  • <%= show_link(t.leaf) %>
  • - <% end %> -
- <% end %> -
- - <% unless @organization.organizations_people.empty? %>

People associated with this organization

diff --git a/db/migrate/20171122031132_add_grouping_to_organizations.rb b/db/migrate/20171122031132_add_grouping_to_organizations.rb new file mode 100644 index 00000000..64d904ea --- /dev/null +++ b/db/migrate/20171122031132_add_grouping_to_organizations.rb @@ -0,0 +1,9 @@ +class AddGroupingToOrganizations < ActiveRecord::Migration + def self.up + add_column :organizations, :grouping, :string + end + + def self.down + remove_column :organizations, :grouping + end +end diff --git a/db/schema.rb b/db/schema.rb index cdd0d9c5..824ad5bd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,297 +9,170 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120616194703) do +ActiveRecord::Schema.define(:version => 0) do create_table "access_rules", :force => true do |t| - t.string "access_type" + t.text "access_type" end - create_table "data_sharing_orgs", :force => true do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" - t.string "default_import_plugin_name" - end + add_index "access_rules", ["id"], :name => "ix_access_rules_87ea5dfc8b8e384d" - create_table "data_sharing_orgs_taggables", :force => true do |t| - t.integer "data_sharing_org_id", :null => false - t.integer "taggable_id", :null => false - t.boolean "verified", :default => false, :null => false - t.datetime "created_at" - t.datetime "updated_at" - t.string "foreign_key_id" - t.string "taggable_type", :default => "Organization" + create_table "data_sharing_orgs", :force => true do |t| + t.text "name" end - add_index "data_sharing_orgs_taggables", ["data_sharing_org_id", "foreign_key_id"], :name => "dsoo_dso_fk", :unique => true + add_index "data_sharing_orgs", ["name"], :name => "ix_data_sharing_orgs_6ae999552a0d2dca" - create_table "data_sharing_orgs_users", :id => false, :force => true do |t| - t.integer "data_sharing_org_id", :null => false - t.integer "user_id", :null => false - t.datetime "created_at" - t.datetime "updated_at" + create_table "data_sharing_orgs_taggables", :force => true do |t| + t.text "dso" + t.text "dso_update" + t.integer "data_sharing_org_id" + t.integer "foreign_key_id" + t.integer "taggable_id" + t.text "taggable_type" + t.integer "verified" end - create_table "entries", :force => true do |t| - t.string "name" - t.string "physical_address1" - t.string "physical_address2" - t.string "physical_city" - t.string "physical_state" - t.string "physical_zip" - t.string "physical_country" - t.string "mailing_address1" - t.string "mailing_address2" - t.string "mailing_city" - t.string "mailing_state" - t.string "mailing_zip" - t.string "mailing_country" - t.string "phone1" - t.string "phone2" - t.string "fax" - t.string "email" - t.string "website" - t.string "preferred_contact" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "created_by_id" - t.integer "updated_by_id" - t.float "latitude" - t.float "longitude" - t.float "distance" - t.integer "member_id" - t.string "prod_serv1" - t.string "prod_serv2" - t.string "prod_serv3" - t.boolean "support_organization" - t.boolean "worker_coop" - t.boolean "producer_coop" - t.boolean "marketing_coop" - t.boolean "housing_coop" - t.boolean "consumer_coop" - t.boolean "community_land_trust" - t.boolean "conservation_ag_land_trust" - t.boolean "alternative_currency" - t.boolean "intentional_community" - t.boolean "collective" - t.boolean "artist_run_center" - t.boolean "community_center" - t.boolean "community_development_financial_institution" - t.boolean "cooperative_financial_institution" - t.boolean "mutual_aid_self_help_group" - t.boolean "activist_social_change_organization" - t.boolean "union_labor_organization" - t.boolean "government" - t.boolean "fair_trade_organization" - t.boolean "network_association" - t.boolean "non_profit_org" - t.boolean "esop" - t.boolean "majority_owned_esop" - t.boolean "percentage_owned" - t.boolean "other" - t.string "type_of_other" - t.integer "naics_code" - t.boolean "informal" - t.boolean "cooperative" - t.boolean "partnership" - t.boolean "llc" - t.boolean "s_corporation" - t.boolean "c_corporation" - t.boolean "non_profit_corporation_501c3" - t.boolean "non_profit_corporation_501c4" - t.boolean "non_profit_corporation_other" - t.boolean "other_type_of_incorp" - t.string "type_of_other_incorp" - t.boolean "have_a_fiscal_sponsor" - t.date "year_founded" - t.boolean "democratic" - t.boolean "union_association" - t.string "which_union" - end + add_index "data_sharing_orgs_taggables", ["data_sharing_org_id", "taggable_id", "taggable_type"], :name => "ix_data_sharing_orgs_taggables_90868c357657838e" - create_table "legal_structures", :force => true do |t| - t.text "name" + create_table "locations", :force => true do |t| + t.text "mailing_address1" + t.text "mailing_address2" + t.text "mailing_city" + t.text "mailing_state" + t.text "mailing_zip" + t.text "mailing_country" + t.text "mailing_county" + t.text "physical_county" t.datetime "created_at" t.datetime "updated_at" - end - - create_table "locations", :force => true do |t| - t.integer "taggable_id", :null => false - t.string "note" - t.string "physical_address1" - t.string "physical_address2" - t.string "physical_city" - t.string "physical_state" - t.string "physical_zip" - t.string "physical_country" - t.string "mailing_address1" - t.string "mailing_address2" - t.string "mailing_city" - t.string "mailing_state" - t.string "mailing_zip" - t.string "mailing_country" + t.text "note" + t.text "dso" + t.text "dso_update" + t.text "physical_zip" + t.text "taggable_type" + t.text "dccid" + t.text "physical_address1" t.float "latitude" t.float "longitude" - t.datetime "created_at" - t.datetime "updated_at" - t.string "mailing_county" - t.string "physical_county" - t.string "taggable_type", :default => "Organization" + t.text "physical_country" + t.integer "taggable_id" + t.text "physical_city" + t.text "physical_address2" + t.text "physical_state" end - add_index "locations", ["taggable_id"], :name => "index_locations_on_organization_id" + add_index "locations", ["dccid"], :name => "ix_locations_1d6d94da1e93927d" - create_table "member_orgs", :force => true do |t| - t.text "name" - t.datetime "created_at" - t.datetime "updated_at" + create_table "oids", :force => true do |t| + t.text "dccid" + t.text "oid" end - create_table "member_orgs_organizations", :id => false, :force => true do |t| - t.integer "member_org_id", :null => false - t.integer "organization_id", :null => false - end + add_index "oids", ["dccid"], :name => "ix_oids_1d6d94da1e93927d" create_table "org_types", :force => true do |t| - t.string "name" - t.text "description" - t.datetime "created_at" - t.datetime "updated_at" - end - - create_table "org_types_organizations", :id => false, :force => true do |t| - t.integer "org_type_id", :null => false - t.integer "organization_id", :null => false + t.text "name" end create_table "organizations", :force => true do |t| - t.string "name", :null => false - t.text "description" - t.integer "created_by_id" - t.integer "updated_by_id" - t.string "phone" - t.string "fax" - t.string "email" - t.string "website" - t.date "year_founded" - t.boolean "democratic" - t.integer "primary_location_id" t.datetime "created_at" t.datetime "updated_at" - t.integer "legal_structure_id" - t.integer "access_rule_id", :null => false - t.datetime "import_notice_sent_at" - t.string "email_response_token" - t.datetime "responded_at" - t.string "response" + t.text "fax" + t.text "year_founded" + t.text "dso" + t.text "dso_update" + t.text "description" + t.integer "access_rule_id" + t.text "oid" + t.text "website" + t.text "name" + t.text "phone" + t.text "email" + t.integer "primary_location_id" + t.text "group" + t.text "grouping" end - add_index "organizations", ["email_response_token"], :name => "index_organizations_on_email_response_token" + add_index "organizations", ["oid"], :name => "ix_organizations_2118c8699c550662" create_table "organizations_people", :force => true do |t| - t.integer "organization_id", :null => false - t.integer "person_id", :null => false - t.string "role_name" - t.string "phone" - t.string "email" - t.datetime "created_at" - t.datetime "updated_at" + t.integer "person_id" + t.integer "organization_id" end - add_index "organizations_people", ["organization_id"], :name => "index_organizations_people_on_organization_id" - add_index "organizations_people", ["person_id"], :name => "index_organizations_people_on_person_id" - - create_table "organizations_sectors", :id => false, :force => true do |t| - t.integer "organization_id", :null => false - t.integer "sector_id", :null => false - end - - add_index "organizations_sectors", ["organization_id"], :name => "index_organizations_sectors_on_organization_id" - add_index "organizations_sectors", ["sector_id"], :name => "index_organizations_sectors_on_sector_id" - - create_table "organizations_users", :id => false, :force => true do |t| - t.integer "organization_id", :null => false - t.integer "user_id", :null => false - t.datetime "created_at" - t.datetime "updated_at" + create_table "organizations_users", :force => true do |t| + t.integer "user_id" + t.integer "organization_id" end create_table "people", :force => true do |t| - t.string "firstname" - t.string "lastname" - t.string "phone_mobile" - t.string "phone_home" - t.string "fax" - t.string "email" - t.boolean "phone_contact_preferred" - t.boolean "email_contact_preferred" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "access_rule_id", :null => false + t.text "firstname" + t.text "lastname" end create_table "product_services", :force => true do |t| - t.string "name" - t.integer "organization_id" - t.datetime "created_at" - t.datetime "updated_at" + t.text "name" + t.integer "organization_id" end - add_index "product_services", ["organization_id"], :name => "index_product_services_on_organization_id" - - create_table "sectors", :force => true do |t| - t.string "name" - t.datetime "created_at" - t.datetime "updated_at" + create_table "tag_contexts", :force => true do |t| + t.text "name" + t.text "friendly_name" end - create_table "tag_contexts", :force => true do |t| - t.string "name" - t.string "friendly_name" + add_index "tag_contexts", ["name"], :name => "ix_tag_contexts_6ae999552a0d2dca" + + create_table "taggings", :force => true do |t| + t.text "dso" + t.text "dso_update" + t.integer "tag_id" + t.integer "taggable_id" + t.text "taggable_type" end - add_index "tag_contexts", ["name"], :name => "index_tag_contexts_on_name" + add_index "taggings", ["tag_id", "taggable_id", "taggable_type"], :name => "ix_taggings_94bc7f962f82a803" - create_table "tag_worlds", :force => true do |t| - t.string "name" + create_table "tags", :force => true do |t| + t.text "root_type" + t.integer "root_id" + t.text "name" + t.integer "effective_id" + t.integer "parent_id" end - add_index "tag_worlds", ["name"], :name => "index_tag_worlds_on_name" + add_index "tags", ["root_id", "root_type"], :name => "ix_tags_c51485bf1a773cf3" - create_table "taggings", :force => true do |t| - t.integer "tag_id" - t.integer "taggable_id" - t.string "taggable_type" - t.datetime "created_at" +# Could not dump table "units" because of following StandardError +# Unknown type '' for column 'taggable_id' + +# Could not dump table "units_content" because of following StandardError +# Unknown type '' for column 'c0taggable_id' + + create_table "units_docsize", :primary_key => "docid", :force => true do |t| + t.binary "size" end - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" - add_index "taggings", ["taggable_id", "taggable_type"], :name => "index_taggings_on_taggable_id_and_taggable_type" + create_table "units_segdir", :primary_key => "level", :force => true do |t| + t.integer "idx" + t.integer "start_block" + t.integer "leaves_end_block" + t.integer "end_block" + t.binary "root" + end - create_table "tags", :force => true do |t| - t.string "name" - t.integer "root_id" - t.string "root_type" - t.integer "parent_id" - t.integer "effective_id" - t.datetime "created_at" - t.datetime "updated_at" + add_index "units_segdir", ["level", "idx"], :name => "sqlite_autoindex_units_segdir_1", :unique => true + + create_table "units_segments", :primary_key => "blockid", :force => true do |t| + t.binary "block" end - add_index "tags", ["name"], :name => "index_tags_on_name" - add_index "tags", ["parent_id"], :name => "index_tags_on_parent_id" - add_index "tags", ["root_id", "root_type"], :name => "index_tags_on_root_id_and_root_type" + create_table "units_stat", :force => true do |t| + t.binary "value" + end create_table "users", :force => true do |t| - t.string "login", :limit => 80 - t.string "password", :limit => 40 - t.boolean "is_admin" - t.datetime "created_at" - t.datetime "last_login" - t.integer "person_id" - t.boolean "update_notifications_enabled", :default => true + t.text "login" end end From d6b1b37eb453b861642a1191036a305039ebb4fd Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Tue, 28 Nov 2017 22:21:27 -0500 Subject: [PATCH 06/40] speed up full map --- Gemfile | 1 + Gemfile.lock | 2 ++ app/controllers/search_controller.rb | 8 ++++++++ app/helpers/application_helper.rb | 10 ++++------ app/models/organization.rb | 2 +- app/sites/proto_site.rb | 4 ++-- app/views/search/_map.rhtml | 2 +- 7 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 0c29ae5e..7a1617ab 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,7 @@ ruby '1.8.7' ruby '1.8.7' +gem "oj", "~> 2.2.0" gem "rack", "~> 1.1.0" gem "geokit", "~> 1.6.7" gem "google-v3-geocoder", "~> 1.0.0" diff --git a/Gemfile.lock b/Gemfile.lock index d025370a..6e416543 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,6 +11,7 @@ GEM json (1.8.1) multi_json (1.10.1) mysql (2.9.1) + oj (2.2.3) rack (1.1.6) rake (0.9.2.2) sqlite3 (1.3.11) @@ -25,6 +26,7 @@ DEPENDENCIES google-v3-geocoder (~> 1.0.0) json (~> 1.8.1) mysql (~> 2.9.1) + oj (~> 2.2.0) rack (~> 1.1.0) rake (~> 0.9.2.2) sqlite3 diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 76f5d452..a757f1cc 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -140,6 +140,14 @@ def mini_map render :partial => "search/map" end + def mini_map2 + @name = params[:name] + @link = YAML::load(params[:link]) + @orgs = @template.get_listing_for_link(@name,@link,@site.name) + @rendered = true + render :partial => "search/map2" + end + def change_filter if params[:name] key = ("active_" + params[:name] + "_filter").to_sym diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 56bb57e5..ec3d211c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -527,16 +527,14 @@ def get_listing_uncached(query,opts) p = {} p[:q] = query opts = {:no_override => true, :unlimited_search => true}.merge(opts) - search_core(p,nil,opts,false) + result = search_core(p,nil,opts,false) + MultiJson.dump(result, + :only => [:id, :latitude, :longitude, :name]) end def get_listing_core(query,name,site_name,opts = {}) # long cache for now - key = "findcoop_get_listingv29:#{site_name}:#{name}" - if Rails.env.development? - # Say the magic words to avoid a YAML problem - logger.debug([Organization,Person]) - end + key = "findcoop_get_listingv30:#{site_name}:#{name}" result = YAML::load(Rails.cache.fetch(key, :expires_in => 14400.minute) { { :list => get_listing_uncached(query,opts), :query => query, :opts => opts }.to_yaml }) return [] if result[:query] != query or result[:opts] != opts result[:list] diff --git a/app/models/organization.rb b/app/models/organization.rb index 621fe855..d16794bd 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -531,7 +531,7 @@ def to_xml(options = {}) end def to_json(options) - options[:include] ||= :locations + # options[:include] ||= :locations super(options) end diff --git a/app/sites/proto_site.rb b/app/sites/proto_site.rb index 1b33d5ab..d495c6d3 100644 --- a/app/sites/proto_site.rb +++ b/app/sites/proto_site.rb @@ -5,7 +5,7 @@ def site_searches end def aliases - ['proto.find.coop'] + ['proto.find.coop', 'test.proto.find.coop'] end def dso_filter @@ -41,7 +41,7 @@ def title end def home - 'http://proto.find.coop:4000' + 'http://proto.find.coop' end def menu diff --git a/app/views/search/_map.rhtml b/app/views/search/_map.rhtml index 86e9eafa..5c03eb55 100644 --- a/app/views/search/_map.rhtml +++ b/app/views/search/_map.rhtml @@ -43,7 +43,7 @@ end
From e8bda28183e7dea46f55b52b8f01cae3678e9f5f Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Tue, 28 Nov 2017 22:23:54 -0500 Subject: [PATCH 07/40] band-aid on crufty old map cache --- app/views/search/_map2.rhtml | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 app/views/search/_map2.rhtml diff --git a/app/views/search/_map2.rhtml b/app/views/search/_map2.rhtml new file mode 100644 index 00000000..022094cc --- /dev/null +++ b/app/views/search/_map2.rhtml @@ -0,0 +1,56 @@ +
+ + +
+
+ + + + + +
From 7e9eb3561b4cb5fd79d5746a4263ff1977218636 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Wed, 29 Nov 2017 21:50:39 -0500 Subject: [PATCH 08/40] make map style consistent --- app/sites/proto_site.rb | 2 +- app/views/search/_map2.rhtml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/sites/proto_site.rb b/app/sites/proto_site.rb index d495c6d3..62758972 100644 --- a/app/sites/proto_site.rb +++ b/app/sites/proto_site.rb @@ -1,7 +1,7 @@ class ProtoSite < Site def site_searches - ['housing', 'Australia'] + nil end def aliases diff --git a/app/views/search/_map2.rhtml b/app/views/search/_map2.rhtml index 022094cc..c4ee6753 100644 --- a/app/views/search/_map2.rhtml +++ b/app/views/search/_map2.rhtml @@ -27,8 +27,8 @@ var dx = (x2 - x1) / 10; var dy = (y2 - y1) / 10; var map = L.map(name).fitBounds([[x1-dx,y1-dy],[x2+dx,y2+dy]]); -var mapquest = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; -var attrib = '©OpenStreetMap contributors'; +var mapquest = 'http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}'; +var attrib = 'Tiles © Esri — National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC'; L.tileLayer(mapquest, { attribution: attrib, maxZoom: 19 From 89569c623c6108ca14ff7120f052c08ec07db10d Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Wed, 29 Nov 2017 21:54:27 -0500 Subject: [PATCH 09/40] tweak title --- app/sites/proto_site.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/sites/proto_site.rb b/app/sites/proto_site.rb index 62758972..b9ca9942 100644 --- a/app/sites/proto_site.rb +++ b/app/sites/proto_site.rb @@ -37,7 +37,7 @@ def use_logo end def title - 'Proto Find.coop' + 'Stone Soup directory' end def home From 1dc79043b5f1d1b75a78366d846b78a577166268 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Wed, 29 Nov 2017 22:27:20 -0500 Subject: [PATCH 10/40] be more active about reporting unverified listings --- app/controllers/organizations_controller.rb | 3 +++ app/views/organizations/show.rhtml | 16 ++++++++++++++++ public/stylesheets/sprint/main.css | 5 +++++ 3 files changed, 24 insertions(+) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index c5a6e3fe..b1c62f5e 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -31,6 +31,9 @@ def show |x| x.id != @organization.id } end + @orgs = [@organization] + @peers + + @all_verified_dsos = @orgs.map{|x| x.verified_dsos}.flatten.compact.uniq #if not(@organization.latitude) # @organization.save_ll diff --git a/app/views/organizations/show.rhtml b/app/views/organizations/show.rhtml index e8d9c4fc..32c4f859 100644 --- a/app/views/organizations/show.rhtml +++ b/app/views/organizations/show.rhtml @@ -4,6 +4,22 @@ <%- end -%> <%- included_view = (params && params[:widget]) if included_view.nil? -%> +<% if @all_verified_dsos.length == 0 %> +
+ Data from: +
Unverified sources
+ (your mileage may vary) +
+<% else %> +
+ Data from: + <% for dso in @all_verified_dsos %> +
<%= link_to dso.name, :controller => 'search', :action => 'search', :params => { :dso => dso.name, :reset => 1 } %>
+ <% end %> + (if we've garbled it, blame us not them) +
+<% end %> + <%= render :partial => 'organizations/show_main', :locals => {:organization => @organization, :included_view => included_view, :map => true} %> <% for peer in @peers %> diff --git a/public/stylesheets/sprint/main.css b/public/stylesheets/sprint/main.css index a9736145..4402c926 100644 --- a/public/stylesheets/sprint/main.css +++ b/public/stylesheets/sprint/main.css @@ -1093,6 +1093,11 @@ body.page-users-prefs .listing { background: #cccc66; } +.filter_listing.danger { + color: #fff; + background: #f00; +} + .filter_listing.default { /*background: #cccc66; border: 1px solid #ddddaa;*/ From 5b5df694166983ce180d31985bc04c29c2c0afdc Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Fri, 1 Dec 2017 17:22:57 -0500 Subject: [PATCH 11/40] switch to db-internal fts (sqlite style for demo), to reduce moving parts --- app/helpers/application_helper.rb | 52 +++++++++++++------------------ 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ec3d211c..9882a5fa 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -194,6 +194,12 @@ def search_core_org_ppl(search_query,pagination,opts,include_counts = false) joinSQL, condSQLs, condParams, org_select, org_order = Organization.all_join(session,opts.merge(:entity => "Entity")) + if search_query != "" + joinSQL = "#{joinSQL} INNER JOIN units ON units.taggable_id = entities.id AND units.taggable_type = 'Entity'" + condSQLs << "units match ?" + condParams << search_query + end + org_joinSQL, org_condSQLs, org_condParams = [joinSQL, condSQLs, condParams] # org_joinSQL = nil if org_condSQLs.empty? org_conditions = [] @@ -213,38 +219,22 @@ def search_core_org_ppl(search_query,pagination,opts,include_counts = false) ppl_select = org_select.gsub("DISTINCT organizations","DISTINCT people") - if search_query == "" - entries = Organization.find(:all, - :limit => :all, - :conditions => org_conditions, - :joins => org_joinSQL, - :select => org_select, - :group => 'coalesce(grouping, organizations.id)', - :order => org_order) - entries2 = Person.find(:all, - :limit => :all, - :conditions => ppl_conditions, - :joins => ppl_joinSQL, - :select => ppl_select) - if entries.length>0 and entries2.length>0 - @entry_name = "result" - end - entries += entries2 - else - entries = ActsAsFerret::find(search_query, - [Organization,Person], - { - :page => 1, - :per_page => 50000, - }, # disable pagination, we need counts - { - :limit => :all, - :conditions => { :organization => org_conditions, :person => ppl_conditions }, - :joins => { :organization => org_joinSQL, :person => ppl_joinSQL }, - :select => { :organization => org_select, :person => ppl_select }, - :order => { :organization => org_order } - }) + entries = Organization.find(:all, + :limit => :all, + :conditions => org_conditions, + :joins => org_joinSQL, + :select => org_select, + :group => 'coalesce(grouping, organizations.id)', + :order => org_order) + entries2 = Person.find(:all, + :limit => :all, + :conditions => ppl_conditions, + :joins => ppl_joinSQL, + :select => ppl_select) + if entries.length>0 and entries2.length>0 + @entry_name = "result" end + entries += entries2 if include_counts counts = ApplicationHelper.count_tags(entries) entries = entries.paginate(pagination) From feb6a7bc0b867cf34e6de484b3bdd55953b9b74f Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Sat, 2 Dec 2017 17:56:59 -0500 Subject: [PATCH 12/40] use grouping in autocomplete also --- app/controllers/search_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index a757f1cc..9aad87ce 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -385,7 +385,7 @@ def auto_complete condParams << value conditions = [] conditions = [condSQLs.collect{|c| "(#{c})"}.join(' AND ')] + condParams unless condSQLs.empty? - organizations = Organization.find(:all, :conditions => conditions, :joins => joinSQL, :limit => limit*5) + organizations = Organization.find(:all, :conditions => conditions, :joins => joinSQL, :limit => limit*5, :group => 'coalesce(grouping, organizations.id)') end if name.length>=2 From 00115455fe2a15f3656fcce1faf1bb45599767d6 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Sat, 2 Dec 2017 22:15:48 -0500 Subject: [PATCH 13/40] speed up faceted search --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9882a5fa..e6368f82 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -195,7 +195,7 @@ def search_core_org_ppl(search_query,pagination,opts,include_counts = false) joinSQL, condSQLs, condParams, org_select, org_order = Organization.all_join(session,opts.merge(:entity => "Entity")) if search_query != "" - joinSQL = "#{joinSQL} INNER JOIN units ON units.taggable_id = entities.id AND units.taggable_type = 'Entity'" + joinSQL = "#{joinSQL} INNER JOIN units_taggables ON units_taggables.taggable_id = entities.id AND units_taggables.taggable_type = 'Entity' INNER JOIN units ON units.docid = units_taggables.id" condSQLs << "units match ?" condParams << search_query end From dff2f71ae89a35472d05eb6b12bd5e37c12cdea5 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Mon, 4 Dec 2017 22:19:37 -0500 Subject: [PATCH 14/40] list dsos --- app/controllers/search_controller.rb | 6 ++++-- app/helpers/application_helper.rb | 11 ++++++++++- app/views/search/_list_map.rhtml | 11 +++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 9aad87ce..6601dac4 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -16,7 +16,9 @@ def index def test _params = {} - @entries, @counts = @template.search_core(_params,@site,{ :unlimited_search => true }, true) + @entries, @counts, @counts_dsos = @template.search_core(_params,@site,{ + :unlimited_search => true + }, true) @entries.reject!{|e| e.kind_of? Person} @entries.uniq! @entries.sort!{|a,b| a.oname <=> b.oname} @@ -38,7 +40,7 @@ def search # _params[:q] = search_query #end - @entries, @counts = @template.search_core(_params,@site,{ :unlimited_search => @unlimited_search, :params => _params }, true) + @entries, @counts, @counts_dsos = @template.search_core(_params,@site,{ :unlimited_search => @unlimited_search, :params => _params }, true) if params[:merge] @merge_active = true diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6368f82..e756b6d4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -183,6 +183,14 @@ def ApplicationHelper.count_tags(entries) return [] if lst == "" Tag.find_by_sql("SELECT t.*, COUNT(DISTINCT o.id) AS count FROM organizations o, tags t, taggings ot WHERE ot.tag_id = t.id AND ot.taggable_id = o.id AND ot.taggable_type = 'Organization' AND ot.taggable_id IN (#{lst}) GROUP BY t.id ORDER BY count DESC") end + + def ApplicationHelper.count_dsos(entries) + # this is currently being called inefficiently in some cases, where + # it would be faster to repeat sql joins rather than list entries + lst = entries.select{|x| Organization === x}.map{|x| x.id}.join(",") + return [] if lst == "" + DataSharingOrg.find_by_sql("SELECT t.*, COUNT(DISTINCT o.id) AS count FROM organizations o, data_sharing_orgs t, data_sharing_orgs_taggables ot WHERE ot.data_sharing_org_id = t.id AND ot.taggable_id = o.id AND ot.taggable_type = 'Organization' AND ot.taggable_id IN (#{lst}) GROUP BY t.id ORDER BY count DESC") + end def search_core_org_ppl(search_query,pagination,opts,include_counts = false) # In SQL conditions, we replace: @@ -237,8 +245,9 @@ def search_core_org_ppl(search_query,pagination,opts,include_counts = false) entries += entries2 if include_counts counts = ApplicationHelper.count_tags(entries) + counts2 = ApplicationHelper.count_dsos(entries) entries = entries.paginate(pagination) - return [entries, counts] + return [entries, counts, counts2] end entries = entries.paginate(pagination) entries diff --git a/app/views/search/_list_map.rhtml b/app/views/search/_list_map.rhtml index dc961ec4..262f867a 100644 --- a/app/views/search/_list_map.rhtml +++ b/app/views/search/_list_map.rhtml @@ -25,6 +25,17 @@
Remember: not all organizations are tagged. <% end %> + <% unless @counts_dsos.blank? %> +

Sources

+
+ + <% @counts_dsos.each do |tag| %> + + <% end %> +
<%= tag.count %><%= link_to tag.name, tag %>
+
+
+ <% end %> <% else %> Not complete?
From 791c0fb290d2b8fbe6c695d2c1588d3faf79e322 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Mon, 4 Dec 2017 22:26:07 -0500 Subject: [PATCH 15/40] fix dso link --- app/views/search/_list_map.rhtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/search/_list_map.rhtml b/app/views/search/_list_map.rhtml index 262f867a..412f47de 100644 --- a/app/views/search/_list_map.rhtml +++ b/app/views/search/_list_map.rhtml @@ -30,7 +30,7 @@
<% @counts_dsos.each do |tag| %> - + <% end %>
<%= tag.count %><%= link_to tag.name, tag %>
<%= tag.count %><%= link_to tag.name, :controller => 'search', :action => 'search', :params => { :dso => tag.name, :reset => 1 } %>
From 848f1982f62a9dd226ef9aa7ad21cad4772898a6 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Mon, 4 Dec 2017 22:47:51 -0500 Subject: [PATCH 16/40] show number of listings on search page --- app/helpers/application_helper.rb | 5 ++++- app/views/search/_teaser.html.rhtml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e756b6d4..09a2096e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -224,6 +224,7 @@ def search_core_org_ppl(search_query,pagination,opts,include_counts = false) org_select = ApplicationHelper.get_org_select(org_select) org_order = nil if org_order.blank? org_order = 'organizations.updated_at DESC' if org_order.blank? + org_select = "#{org_select}, count(*) as grouping_count" ppl_select = org_select.gsub("DISTINCT organizations","DISTINCT people") @@ -238,7 +239,9 @@ def search_core_org_ppl(search_query,pagination,opts,include_counts = false) :limit => :all, :conditions => ppl_conditions, :joins => ppl_joinSQL, - :select => ppl_select) + :select => ppl_select, + :group => 'coalesce(grouping, people.id)') + if entries.length>0 and entries2.length>0 @entry_name = "result" end diff --git a/app/views/search/_teaser.html.rhtml b/app/views/search/_teaser.html.rhtml index 85c3bb50..a3c46ea4 100644 --- a/app/views/search/_teaser.html.rhtml +++ b/app/views/search/_teaser.html.rhtml @@ -3,7 +3,7 @@ <%- show_state = true if local_assigns[:show_state].nil? -%> <%- show_class = true if local_assigns[:show_class].nil? -%>
-<%= show_link entry %><% if is_admin? %> (<%= link_to 'delete', url_for(entry) + "?recent=1", :confirm => 'Are you sure?', :method => :delete %>)<% end %>
+<%= show_link entry %><% if entry.respond_to? 'grouping_count' %><% if entry.grouping_count > 1 %> (<%= entry.grouping_count %> listings)<% end %><% end %><% if is_admin? %> (<%= link_to 'delete', url_for(entry) + "?recent=1", :confirm => 'Are you sure?', :method => :delete %>)<% end %>
<%- if entry.respond_to? "website" and !entry.website.blank? -%> <%= website_link(entry.website, :shorten => true) %>
<%- end -%> From 419c96f7d8b2fb49465dce258807a546b4e401f8 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Sat, 9 Dec 2017 18:00:11 -0500 Subject: [PATCH 17/40] make org display and order a bit smarter --- app/controllers/organizations_controller.rb | 3 +++ app/helpers/application_helper.rb | 5 ++++- app/views/locations/_display.rhtml | 6 +++--- app/views/organizations/_show_main.rhtml | 8 +++++--- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index b1c62f5e..396bad42 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -30,6 +30,9 @@ def show @peers = Organization.find_all_by_grouping(@organization.grouping).select{ |x| x.id != @organization.id } + past = DateTime.now - 10000.years + @peers = @peers.sort_by { |x| x.updated_at || past } + @peers.reverse! end @orgs = [@organization] + @peers diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 09a2096e..e95bd425 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -13,7 +13,10 @@ def data_import_plugins end def date_format_long(date) - return '' if date.nil? + return 'at a date and time unknown' if date.nil? + if date.day == 1 and date.month == 1 + return date.strftime('in %Y') + end return date.strftime('%B %d, %Y') # "July 20, 2009" end diff --git a/app/views/locations/_display.rhtml b/app/views/locations/_display.rhtml index 0538ee0f..63e3326e 100644 --- a/app/views/locations/_display.rhtml +++ b/app/views/locations/_display.rhtml @@ -18,11 +18,11 @@
<% end %>
'> - <%- if @organization -%> -
<%- if location.taggable_id != @organization.id -%><%- end -%><%= location.note.blank? ? 'Address' : location.note %> + <%- if organization and !location.physical_state.blank? -%> +
<%- if location.taggable_id != organization.id -%><%- end -%><%= location.note.blank? ? 'Address' : location.note %> <% unless hide_links %> - <%- if location.taggable_id != @organization.id -%> + <%- if location.taggable_id != organization.id -%> [ <%= link_to_remote( 'merge', :url => {:controller => 'locations', :action => 'move', :id => location.id, :trunk_id => get_trunk_id, :branch_id => get_branch_id }, :update => 'locations', diff --git a/app/views/organizations/_show_main.rhtml b/app/views/organizations/_show_main.rhtml index ea6d2b43..3e728151 100644 --- a/app/views/organizations/_show_main.rhtml +++ b/app/views/organizations/_show_main.rhtml @@ -1,7 +1,7 @@

<%= organization.name %>

<%- unless organization.updated_at.nil? -%> - This entry was last updated on <%= date_format_long(organization.updated_at) %> + This entry was last updated <%= date_format_long(organization.updated_at) %> <%- unless organization.updated_by.nil? -%> <%- if current_user -%> by <%= organization.updated_by.login %> @@ -34,6 +34,7 @@
<%= render :partial => "search/map_core_leaflet", :locals => { :map_id => "the_map", :map_class => nil, :orgs => organization.locations } %>
+<% unless organization.locations[0].physical_state.blank? %> Meet the neighbors:
    <%- organization.locations.each do |loc| -%> @@ -57,6 +58,7 @@ <% end %> <% end %>
+<% end %>
<% end %> @@ -69,7 +71,7 @@
<% if organization.primary_location %> - <%= render :partial => 'locations/display', :locals => {:location => organization.primary_location, :hide_links => true}%> + <%= render :partial => 'locations/display', :locals => {:location => organization.primary_location, :hide_links => true, :organization => organization}%> <% end %> <% unless organization.phone.blank? %> @@ -108,7 +110,7 @@

Other Locations

<% organization.locations.each do |loc| next if loc.id == organization.primary_location.id %> - <%= render :partial => 'locations/display', :locals => {:location => loc, :hide_links => true}%> + <%= render :partial => 'locations/display', :locals => {:location => loc, :hide_links => true, :organization => organization}%> <% end %> <% end %> From 0823da7536834a59ed173c8f51bd09c73fb23b48 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Sat, 9 Dec 2017 22:23:37 -0500 Subject: [PATCH 18/40] work-around for co-op search --- app/helpers/application_helper.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e95bd425..f42129e1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -206,9 +206,16 @@ def search_core_org_ppl(search_query,pagination,opts,include_counts = false) joinSQL, condSQLs, condParams, org_select, org_order = Organization.all_join(session,opts.merge(:entity => "Entity")) if search_query != "" + sq = search_query + if not sq.include? '"' + # not-great hack to make "co-op" non-disastrous + sq = sq.split ' ' + sq = sq.map { |x| if x.include? '-' then "\"#{x}\"" else x end } + sq = sq.join ' ' + end joinSQL = "#{joinSQL} INNER JOIN units_taggables ON units_taggables.taggable_id = entities.id AND units_taggables.taggable_type = 'Entity' INNER JOIN units ON units.docid = units_taggables.id" condSQLs << "units match ?" - condParams << search_query + condParams << sq end org_joinSQL, org_condSQLs, org_condParams = [joinSQL, condSQLs, condParams] From 670fc63890ebd501626d13beef821ebc5ae7d079 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Tue, 12 Dec 2017 16:48:45 -0500 Subject: [PATCH 19/40] clean up merged listings somewhat --- app/helpers/organizations_helper.rb | 103 ++++++++++++++++++++++++++++ app/views/organizations/show.rhtml | 15 ++-- 2 files changed, 113 insertions(+), 5 deletions(-) diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 24cc9a80..bc903477 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -1,2 +1,105 @@ +require 'ostruct' + + module OrganizationsHelper + + def summary(orgs) + orgs = orgs.sort_by{ |x| x[:updated_at] or Time.now - 1000.years }.reverse + locs, primary = summary_locations(orgs) + phone, email, website = summary_contacts(orgs) + tags = summary_tags(orgs) + OpenStruct.new(:name => summary_name(orgs), + :description => summary_description(orgs), + :updated_at => nil, + :verified_dsos => [], + :locations => locs, + :primary_location => primary, + :products_services => [], + :tags => [], + :phone => phone, + :email => email, + :website => website, + :orgs => orgs, + :tags => tags + ) + end + + def summary_name(orgs) + titles = orgs.map { |x| x.name } + uppers = titles.map{ |x| x.gsub(/[^A-Z]/, '').length } + mu = uppers.inject{ |sum, el| sum + el }.to_f / uppers.size + lowers = titles.zip(uppers).select{ |t, ct| ct < mu * 1.25 } + titles, uppers = lowers.transpose + mu = uppers.inject{ |sum, el| sum + el }.to_f / lowers.size + vals = uppers.map{ |x| (x - mu).abs } + results = vals.zip(titles).sort + results[0][1] + end + + def summary_description(orgs) + descs = orgs.map { |x| x.description or "" } + lens = descs.map { |x| -x.length } + lens.zip(descs).sort[0][1] + end + + def summary_locations(orgs) + good_location = false + locations = [] + primary_location = nil + for org in orgs + if not good_location + use_location = primary_location.blank? + if org.primary_location + if not org.primary_location.physical_state.blank? + good_location = true + use_location = true + end + end + if use_location + primary_location = org.primary_location + locations = org.locations + end + end + end + return locations, primary_location + end + + def prefer_site(v1, v2) + return v1 if v2.blank? + return v2 if v1.blank? + if v2.include? '.coop' and !v1.include? '.coop' + return v2 + end + v1 + end + + def summary_contacts(orgs) + phone = nil + email = nil + website = nil + for org in orgs + phone = org.phone if phone.blank? + email = prefer_site(email, org.email) + website = prefer_site(website, org.website) + end + return phone, email, website + end + + def summary_tags(orgs) + keys = {} + tags = [] + for org in orgs + for tag in org.tags + parent = "" + parent = tag.effective_parent.readable_name if tag.effective_parent + key = "#{parent} -- #{tag.root_id} / #{tag.root_type}" + unless keys.include? key + tags << tag + keys[key] = 1 + end + end + end + tags + end + end diff --git a/app/views/organizations/show.rhtml b/app/views/organizations/show.rhtml index 32c4f859..737c3744 100644 --- a/app/views/organizations/show.rhtml +++ b/app/views/organizations/show.rhtml @@ -20,13 +20,18 @@
<% end %> -<%= render :partial => 'organizations/show_main', :locals => {:organization => @organization, :included_view => included_view, :map => true} %> +<% if @orgs.length > 1 %> + <%- org_summary = summary(@orgs) -%> + <%= render :partial => 'organizations/show_main', :locals => {:organization => org_summary, :included_view => included_view, :map => true} %> + <% @orgs.each_with_index do |peer, idx| %> +

 
 

+
Original listing <%= idx+1 %> of <%= @orgs.length %>
+ <%= render :partial => 'organizations/show_main', :locals => {:organization => peer, :included_view => included_view, :map => false} %> + <% end %> -<% for peer in @peers %> -

-
(Another related entry: <%= show_link peer %>)
- <%= render :partial => 'organizations/show_main', :locals => {:organization => peer, :included_view => included_view, :map => false} %> +<% else %> + <%= render :partial => 'organizations/show_main', :locals => {:organization => @organization, :included_view => included_view, :map => true} %> <% end %> <% unless @organization.organizations_people.empty? %> From 00eb48892567c4229e7c74a0c82fb40a7a004784 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Tue, 19 Dec 2017 18:20:43 -0500 Subject: [PATCH 20/40] clean up csv output minimally --- app/controllers/application_controller.rb | 30 +++++++++++++++++++++-- app/models/location.rb | 2 ++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4d7ef7a1..5364a45e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -330,8 +330,34 @@ def render_entries } format.csv do data = [@entries].flatten - data = data.map {|r| r.reportable_data}.flatten - cols = Organization.column_names + data = data.map {|r| r.reportable_data(:include => [:primary_location])}.flatten + cols = Organization.column_names + Location.column_names + cols.reject!{|x| x.include? 'mailing_'} + cols.reject!{|x| x.include? '_id'} + cols.reject!{|x| x.include? 'created_at'} + cols.reject!{|x| x.include? 'updated_at'} + cols.reject!{|x| ['dccid', 'grouping', 'dso_update', 'oid', 'id'].include? x} + cols.reject!{|x| ['taggable_type', 'dso'].include? x} + + cols = [ + 'name', + 'phone', + 'website', + 'email', + 'fax', + 'physical_address1', + 'physical_address2', + 'physical_city', + 'physical_state', + 'physical_zip', + 'physical_country', + 'description', + 'year_founded', + 'latitude', + 'longitude', + ] + + table = Ruport::Data::Table.new(:data => data, :column_names => cols) send_data table.to_csv, diff --git a/app/models/location.rb b/app/models/location.rb index 85929683..9347dc59 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -15,6 +15,8 @@ class Location < ActiveRecord::Base :lng_column_name => 'longitude', :distance_field_name => 'distance' + acts_as_reportable + validates_presence_of :taggable_id, :on => :save validates_each :physical_city, :physical_country do |record, attr, value| record.errors.add attr, "(or mailing city & country) must be specified" unless \ From 54c43ee0ae1e8434e4c0e1bfc7e4f4bff5c8946d Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Tue, 19 Dec 2017 22:37:59 -0500 Subject: [PATCH 21/40] add tag names for csv --- app/controllers/application_controller.rb | 15 +++------------ app/helpers/application_helper.rb | 1 + 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5364a45e..1a46a42f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -330,15 +330,7 @@ def render_entries } format.csv do data = [@entries].flatten - data = data.map {|r| r.reportable_data(:include => [:primary_location])}.flatten - cols = Organization.column_names + Location.column_names - cols.reject!{|x| x.include? 'mailing_'} - cols.reject!{|x| x.include? '_id'} - cols.reject!{|x| x.include? 'created_at'} - cols.reject!{|x| x.include? 'updated_at'} - cols.reject!{|x| ['dccid', 'grouping', 'dso_update', 'oid', 'id'].include? x} - cols.reject!{|x| ['taggable_type', 'dso'].include? x} - + data = data.map {|r| r.reportable_data}.flatten cols = [ 'name', 'phone', @@ -352,12 +344,11 @@ def render_entries 'physical_zip', 'physical_country', 'description', - 'year_founded', + 'tag_names', + 'founded', 'latitude', 'longitude', ] - - table = Ruport::Data::Table.new(:data => data, :column_names => cols) send_data table.to_csv, diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f42129e1..d04dba4b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -235,6 +235,7 @@ def search_core_org_ppl(search_query,pagination,opts,include_counts = false) org_order = nil if org_order.blank? org_order = 'organizations.updated_at DESC' if org_order.blank? org_select = "#{org_select}, count(*) as grouping_count" + org_select = "#{org_select}, (select group_concat(name, ' ~ ') from taggings join tags on taggings.tag_id = tags.id where taggings.taggable_id = organizations.id and taggings.taggable_type = 'Organization' order by name) as tag_names, strftime('%Y', organizations.year_founded) as founded" ppl_select = org_select.gsub("DISTINCT organizations","DISTINCT people") From 3d75a89d3b9394adb1098e3d5cd32aa3c8cce7df Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Thu, 21 Dec 2017 20:34:45 -0500 Subject: [PATCH 22/40] switch to classic style --- app/sites/default_site.rb | 2 +- app/sites/proto_site.rb | 2 +- app/views/layouts/default/_index.rhtml | 2 +- app/views/layouts/sprint/template.rhtml | 2 +- app/views/search/_map2.rhtml | 1 - public/stylesheets/sprint/main.css | 6 +++++- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/sites/default_site.rb b/app/sites/default_site.rb index 6e1f5866..6be6b602 100644 --- a/app/sites/default_site.rb +++ b/app/sites/default_site.rb @@ -5,7 +5,7 @@ def site_searches end def aliases - ['find.coop', 'www.find.coop'] + ['find.coop', 'www.find.coop', 'test.find.coop', 'proto.find.coop'] end def layout diff --git a/app/sites/proto_site.rb b/app/sites/proto_site.rb index b9ca9942..9d5abeb0 100644 --- a/app/sites/proto_site.rb +++ b/app/sites/proto_site.rb @@ -5,7 +5,7 @@ def site_searches end def aliases - ['proto.find.coop', 'test.proto.find.coop'] + ['proto2.find.coop', 'test.proto2.find.coop'] end def dso_filter diff --git a/app/views/layouts/default/_index.rhtml b/app/views/layouts/default/_index.rhtml index 1d7f570b..31a0e2b3 100644 --- a/app/views/layouts/default/_index.rhtml +++ b/app/views/layouts/default/_index.rhtml @@ -26,7 +26,7 @@ var carousel_active = true;

Cooperative Development

-<%= render :partial => "search/map", :locals => { :name => "coopdev3", :immediate => true, :link => { :sector => "Cooperative Development" } } %> +<%= render :partial => "search/map", :locals => { :name => "coopdev3", :immediate => false, :link => { :sector => "Cooperative Development " } } %>
diff --git a/app/views/layouts/sprint/template.rhtml b/app/views/layouts/sprint/template.rhtml index e946fbd7..9fd18c1a 100644 --- a/app/views/layouts/sprint/template.rhtml +++ b/app/views/layouts/sprint/template.rhtml @@ -48,7 +48,7 @@ Event.observe(window, 'load', function() {
<%= render :partial => 'search/post_search_form', :locals => { :this_is_the_header => true } %>
-
<%= link_to "+ #{t :add_organization}", :controller => 'organizations', :action => 'new' %>
+
<%= link_to "+ #{t :add_organization}", :controller => 'organizations', :action => 'new' %>
<%= link_to t(:help), help_path %>
<%= link_to t(:recent_changes), recent_path %>
<%- @site.menu.each do |button| -%><%- end -%> diff --git a/app/views/search/_map2.rhtml b/app/views/search/_map2.rhtml index c4ee6753..70093425 100644 --- a/app/views/search/_map2.rhtml +++ b/app/views/search/_map2.rhtml @@ -1,6 +1,5 @@
-
diff --git a/public/stylesheets/sprint/main.css b/public/stylesheets/sprint/main.css index 4402c926..02366515 100644 --- a/public/stylesheets/sprint/main.css +++ b/public/stylesheets/sprint/main.css @@ -905,7 +905,7 @@ body.page-users-prefs .listing { } #carousel-area .surround_map_insert { - width: 400px; + width: 650px; height: 400px; float: left; margin-right: 10px; @@ -1296,4 +1296,8 @@ position: relative; .ajax { min-width: 200px; +} + +.add-org { + display: none !important; } \ No newline at end of file From 9025ec45e051f5bd5ad8dfe18f26e5ccf2e855d1 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Fri, 5 Jan 2018 14:37:57 -0500 Subject: [PATCH 23/40] autoupdate behavior is too annoying --- app/views/search/_filters2.html.erb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/search/_filters2.html.erb b/app/views/search/_filters2.html.erb index 0bec9021..3452a2c4 100644 --- a/app/views/search/_filters2.html.erb +++ b/app/views/search/_filters2.html.erb @@ -6,7 +6,6 @@ <%- unless filter[:value].blank? and !filter[:has_default] -%>
<%= link_to_remote( 'x', :url => {:controller => 'search', :action => 'change_filter', :name => filter[:name]}, - :complete => "jQuery('#search_form').submit()", :update => 'search_filters') %>
<%- end -%> <%= refine_filter_label(filter[:label]) %>
@@ -70,14 +69,14 @@ function filter_apply_change(e,name) { lnk["ac_label"] = a.label; lnk["ac_link"] = item; lnk["ac_cat"] = a.cat; - new Ajax.Updater('search_filters', item, {parameters: params, asynchronous:true, evalScripts:true, onComplete: function(){ jQuery("#search_form").submit(); }}); + new Ajax.Updater('search_filters', item, {parameters: params, asynchronous:true, evalScripts:true}); } if (e.removed) { var a = e.removed.text; var ac_link = "/search/change_filter"; var params = {act: 'remove'}; params[name] = a; - new Ajax.Updater('search_filters', ac_link, {parameters: params, asynchronous:true, evalScripts:true, onComplete: function(){ jQuery("#search_form").submit(); }}); + new Ajax.Updater('search_filters', ac_link, {parameters: params, asynchronous:true, evalScripts:true}); } return false; } From 89213b8a9b3ed949bad86ea25bc4d6b8a6ef8c0d Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Fri, 5 Jan 2018 15:16:39 -0500 Subject: [PATCH 24/40] add dso to csv --- app/controllers/application_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1a46a42f..48724b6b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -348,6 +348,7 @@ def render_entries 'founded', 'latitude', 'longitude', + 'dso' ] table = Ruport::Data::Table.new(:data => data, :column_names => cols) From 4f15f803b9e4666b44be19bf659bcf617c5f43b7 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Sat, 6 Jan 2018 11:29:44 -0500 Subject: [PATCH 25/40] remove a duplication in sql clause that was slowing things down --- app/helpers/application_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d04dba4b..33139e84 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -223,6 +223,9 @@ def search_core_org_ppl(search_query,pagination,opts,include_counts = false) org_conditions = [] org_conditions = [org_condSQLs.collect{|c| "(#{c})"}.join(' AND ')] + org_condParams unless org_condSQLs.empty? org_joinSQL = org_joinSQL.gsub('Entity','Organization').gsub('entities','organizations') + # remove a nasty duplication + org_joinSQL = org_joinSQL.gsub("OR (data_sharing_orgs_taggables.taggable_id = organizations.id AND data_sharing_orgs_taggables.taggable_type = 'Organization')", "") + ppl_joinSQL, ppl_condSQLs, ppl_condParams = [joinSQL, condSQLs, condParams] ppl_joinSQL = "INNER JOIN organizations_people ON organizations_people.person_id = people.id INNER JOIN organizations ON organizations_people.organization_id = organizations.id #{ppl_joinSQL}" From 879402540af2cf4d5ddc4261973f9ed64c37842c Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Sat, 6 Jan 2018 12:28:57 -0500 Subject: [PATCH 26/40] use some mailing info if that is all we have in csv --- app/controllers/application_controller.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 48724b6b..321205c0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -331,6 +331,13 @@ def render_entries format.csv do data = [@entries].flatten data = data.map {|r| r.reportable_data}.flatten + data.each do |d| + if (!d['mailing_state'].blank?) and d['physical_state'].blank? + d['physical_city'] = d['mailing_city'] + d['physical_state'] = d['mailing_state'] + d['physical_country'] = d['mailing_country'] + end + end cols = [ 'name', 'phone', From c91d58041671d497202e0ac81a373dec62e247b5 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Tue, 13 Mar 2018 21:56:41 -0400 Subject: [PATCH 27/40] remove 'submit query' showing in firefox --- app/views/search/_search_form.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/search/_search_form.html.erb b/app/views/search/_search_form.html.erb index 80d44b85..4f792b81 100644 --- a/app/views/search/_search_form.html.erb +++ b/app/views/search/_search_form.html.erb @@ -6,11 +6,11 @@ <% form_tag( {:controller => 'search', :action => 'search'}, :id => 'search_form', :name => 'search_form', :method => 'get' ) do %>
<%- if @site.search_bar_in_header %> - <%= text_field_tag 'q', @query, :size => 30, :placeholder=>"#{t :search}...", :autocomplete => "off" %><%= image_submit_tag "/images/spacer.gif", :id => "see_list" %> + <%= text_field_tag 'q', @query, :size => 30, :placeholder=>"#{t :search}...", :autocomplete => "off" %><%= image_submit_tag "/images/spacer.gif", :id => "see_list", :value => "" %>
<%- else -%> - <%= text_field_tag 'q', @query, :size => 30 %><%= submit_tag "see list", :id => "see_list" %> + <%= text_field_tag 'q', @query, :size => 30 %><%= submit_tag "see list", :id => "see_list", :value => "" %> <%- end -%> <%= submit_tag 'See Map', :name => 'Map', :id => "see_map" %> <%= link_to 'Add...', {:controller => 'organizations', :action => 'new'}, {:id=>'see_add'} %> From 7fd45c535579103a5566f49f3b614397f3c9b7d5 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Tue, 13 Mar 2018 23:24:17 -0400 Subject: [PATCH 28/40] my goodness this site is rusty --- app/controllers/search_controller.rb | 4 ++ app/controllers/users_controller.rb | 39 ++++++++++++++++- app/sites/default_site.rb | 6 +-- app/views/layouts/_usermenu.rhtml | 4 +- app/views/layouts/default/_recipe.html.erb | 2 +- app/views/search/_help_main.rhtml | 49 ++++++++++++++-------- app/views/users/login.rhtml | 12 +++--- config/locales/default.yml | 2 +- config/locales/en.yml | 2 +- 9 files changed, 85 insertions(+), 35 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 6601dac4..28278a32 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -2,6 +2,10 @@ class SearchController < ApplicationController # before_filter :login_required, :only => [:inspect] + before_filter(:only => :search) do |controller| + controller.send(:login_required) if ['json', 'kml', 'pdf', 'csv', 'yaml', 'xml'].include? controller.request.format + end + public def index diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index fd8cea23..50042b3f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,5 @@ class UsersController < ApplicationController - before_filter :login_required, :only => [:new, :create, :edit, :update, :destroy, :index, :list, :show, :prefs, :update_prefs] + before_filter :login_required, :only => [:new, :create, :edit, :update, :destroy, :index, :list, :show, :prefs, :update_prefs, :old_signup] before_filter :admin_required, :only => [:index, :list, :new, :create, :edit, :update, :destroy] def index @@ -45,8 +45,43 @@ def login end end end + + def old_login + case request.method + when :post + if params[:login] # attempting a login + if session[:user] = User.authenticate(params['user_login'], params['user_password']) + + session[:user].update_attribute('last_login', DateTime.now) + flash['notice'] = "Login successful" + redirect_back_or_default :controller => 'search', :action => "index" + else + @login = params['user_login'] + @message = "Login unsuccessful" + end + elsif params[:forgot_pass] # requesting password reset + if params[:user_login].blank? + @login = params['user_login'] + @message = "Enter your e-mail address to reset your password." + else + user = User.find_by_login(params[:user_login]) + if user.nil? + @login = params['user_login'] + @message = "No user was found with for that e-mail address." + else + # reset password and send e-mail + newpass = Common::random_password(user.login) + user.password_cleartext = newpass + user.save! + Email.deliver_password_reset(user, newpass) + @message = "A new password was e-mailed to #{user.login} (if you don't see it, check your spam folder, or whitelist \"find.coop\")" + end + end + end + end + end - def signup + def old_signup case request.method when :post @user = User.new(params['user']) diff --git a/app/sites/default_site.rb b/app/sites/default_site.rb index 6be6b602..a2c7c126 100644 --- a/app/sites/default_site.rb +++ b/app/sites/default_site.rb @@ -24,15 +24,15 @@ def menu [ { :name => "About", - :link => "http://datacommons.find.coop/about" + :link => "http://datacommons.coop/" }, { :name => "Join", - :link => "http://datacommons.find.coop/content/member-packet" + :link => "http://member.datacommons.coop/applications/new" }, { :name => "Contact", - :link => "http://datacommons.find.coop/contact" + :link => "http://datacommons.coop/contact/" }, ] end diff --git a/app/views/layouts/_usermenu.rhtml b/app/views/layouts/_usermenu.rhtml index d388d1ca..5f5b9cd2 100644 --- a/app/views/layouts/_usermenu.rhtml +++ b/app/views/layouts/_usermenu.rhtml @@ -7,8 +7,8 @@ <% else %> <%= link_to t(:edit_personal_entry), :controller => 'people', :action => 'edit', :id => current_user.person %> <% end %> - | <%= link_to t(:report_problem), 'http://datacommons.find.coop/contact'%> + | <%= link_to t(:report_problem), 'http://datacommons.coop/contact/'%> ) <%- else -%> -<%= link_to t(:login), :controller => 'users', :action => 'login' %> | <%= t(:report_problem) %> +<%= link_to t(:login), :controller => 'users', :action => 'login' %> | <%= t(:report_problem) %> <% end %> diff --git a/app/views/layouts/default/_recipe.html.erb b/app/views/layouts/default/_recipe.html.erb index daa7e5e4..81b8e57f 100644 --- a/app/views/layouts/default/_recipe.html.erb +++ b/app/views/layouts/default/_recipe.html.erb @@ -2,7 +2,7 @@

Every -Data Commons +Data Commons Co-op member has different interests, so this collaborative directory has any number of community views. Examples: diff --git a/app/views/search/_help_main.rhtml b/app/views/search/_help_main.rhtml index fe458a45..7946ff54 100644 --- a/app/views/search/_help_main.rhtml +++ b/app/views/search/_help_main.rhtml @@ -24,7 +24,7 @@ gambol around your feet whenever you chose to visit, and we'd have a team of enthusiastic researchers on call to find whatever you needed. Unfortunately we've made the questionable decision to use computers instead, inevitably leading to sadness and ill-feeling. -When that happens, please contact us! +When that happens, please contact us! We're a helpful bunch, when not hiding behind a computer.

@@ -36,6 +36,7 @@ We're a helpful bunch, when not hiding behind a computer. <% end %> +<% if false %> <%= faq("add","Can I add a missing organization?",content_run) %> <% if content_run %> @@ -50,8 +51,10 @@ Additions are subject to verification and reversion by editors and moderators.
<% end %> +<% end %> +<% if false %> <%= faq("login","How do I log in, or sign on, or whatever you call it?",content_run) %> <% if content_run %> @@ -62,8 +65,10 @@ leading to the <%= link_to "login page", :controller=>"users", :action=>"login"
<% end %> +<% end %> +<% if false %> <%= faq("edit","I found a mistake in a listing. Can I fix it myself?",content_run) %> <% if content_run %> @@ -75,7 +80,9 @@ and moderators.
<% end %> +<% end %> +<% if false %> <%= faq("dups","I found some near-duplicate listings. Can I merge them?",content_run) %> <% if content_run %> @@ -87,12 +94,14 @@ now see a new “Set as main version” link beneath each search result. Click this link for the best of the near-duplicates. Then click “Merge” for one other version, and follow the guidance on merging any useful bits and pieces from it. -Or just send us a note +Or just send us a note and we'll do it.
<% end %> +<% end %> +<% if false %> <%= faq("defunct","I found a defunct organization. Should I delete it?",content_run) %> <% if content_run %> @@ -107,6 +116,7 @@ at the bottom of every listing.
<% end %> +<% end %> @@ -116,7 +126,7 @@ at the bottom of every listing.
The directory is curated by small teams of moderators from various -member organizations of the Data Commons Co-op. At the start of any +member organizations of the Data Commons Co-op. At the start of any listing, you should see a note about when it was last updated. Anything older than a year or two is not likely to be accurate. Each listing will also give all editors of that listing. Listings with @@ -133,12 +143,12 @@ editors are more likely to be accurate. If the listing for that organization says it is in the “data pool” of such-and-such, that shows which of our co-op members have approved it. If there is no language like that, then nobody is very attached to -it, it just wafted in on the breeze. You could tag it as evil (or +it, it just wafted in on the breeze.
<% end %> @@ -152,19 +162,19 @@ We're working on better communicating the quality of individual listings. Access to the database is currently limited to members of the Data Commons Cooperative. We encourage you to apply for membership to +href="http://member.datacommons.coop/applications/new">apply for membership to get complete access (including the full database, plus full database history since DCC incorporation, plus contributed data in source format from members, plus continuous updates for the duration of your -membership). -We are working to migrate as much data as possible to an +membership). +
<% end %> @@ -175,15 +185,15 @@ you under different terms than they provide it to the Co-op.
Be our guest! The Data Commons Directory software is available under a free license at -<%= link_to 'launchpad.net/datacommons', "https://code.launchpad.net/~datacommons/datacommons/trunk" %>. -There are tips on installing it on <%= link_to 'Cultivate', "http://cultivate.coop/wiki/Data_Commons_Directory" %>. +<%= link_to 'github.com/datacommons/stonesoup', "https://github.com/datacommons/stonesoup" %>. +There are elderly tips on installing it on <%= link_to 'Cultivate', "http://cultivate.coop/wiki/Data_Commons_Directory" %>. We'd appreciate if you share improvements you make to the software. If you need to integrate the directory with an existing website, and don't have a team in place to do it, we may be able to put you in touch with a co-op familiar with the software that is available to do the work - -contact us (or +contact us (or check the fine print at the bottom of any page for leads).
<% end %> @@ -193,18 +203,17 @@ check the fine print at the bottom of any page for leads). <% if content_run %>
-Love. It is the one thing we have plenty of. Also, as of July 2012, -membership fees of the Data commons Cooperative. Along the way, we've +Membership fees of the Data commons Cooperative. Along the way, we've had wonderful help from funders and volunteers, check the acknowledgments at the bottom of this page, and the list on our -donation page. +donation page.
<% end %> - +<% if false %> <%= faq("moderator","How do I become a moderator?",content_run) %> <% if content_run %> @@ -216,10 +225,11 @@ Data Commons Cooperative can also nominate moderators.
<% end %> +<% end %> - +<% if false %> <%= faq("moderator_do","Ok, I\'m a moderator. What can I actually do?",content_run) %> <% if content_run %> @@ -240,9 +250,11 @@ an association between your team (or teams) and individual listings. <% end %> +<% end %> +<% if false %> <%= faq("moderator_recent","How can I see a list of recent changes?",content_run) %> <% if content_run %> @@ -258,3 +270,4 @@ need a complete report before we fix this, an administrator can produce it for y <% end %> +<% end %> diff --git a/app/views/users/login.rhtml b/app/views/users/login.rhtml index 7482a629..a7a39088 100644 --- a/app/views/users/login.rhtml +++ b/app/views/users/login.rhtml @@ -1,12 +1,13 @@ -
-<%= t(:login_message) %> -
+

+Changes to this directory, along with bulk downloads of its contents, are managed +by the Data Commons Cooperative. Some operations are not public, but only +available with express authorization of data contributors. +

<% form_tag :action=> "login" do %> -

<%= t(:login_option) %>

<% if @message %>
<%= @message %>
@@ -19,12 +20,9 @@

- <% end %>
-<%= render :file => 'users/signup' %> -
\ No newline at end of file diff --git a/config/locales/default.yml b/config/locales/default.yml index c5f398f1..03500e0f 100644 --- a/config/locales/default.yml +++ b/config/locales/default.yml @@ -22,7 +22,7 @@ default: signup: Sign up a_directory: A directory of the cooperative economy collaborative_directory: Collaborative Directory - login_needed: Please log in or sign up first. + login_needed: Please log in first. access_denied: Access to that function is restricted. logged_in_as: Logged in as preferences: Preferences diff --git a/config/locales/en.yml b/config/locales/en.yml index 1b81be9e..6a7f0581 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -22,7 +22,7 @@ en: signup: Sign up a_directory: A directory of alternative economic initiatives collaborative_directory: Collaborative Directory - login_needed: Please log in or sign up first. + login_needed: Please log in first. access_denied: Access to that function is restricted. logged_in_as: Logged in as preferences: Preferences From 95846f18e3046f1d37c0ffa0a3af3487d1340048 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Thu, 15 Mar 2018 12:19:01 -0400 Subject: [PATCH 29/40] close map+near endpoints also --- app/controllers/search_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 28278a32..a11c0299 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -2,7 +2,7 @@ class SearchController < ApplicationController # before_filter :login_required, :only => [:inspect] - before_filter(:only => :search) do |controller| + before_filter(:only => [:search, :map, :near]) do |controller| controller.send(:login_required) if ['json', 'kml', 'pdf', 'csv', 'yaml', 'xml'].include? controller.request.format end From a5c0fb858d66a93c95b1228b6ce94870fddff4a8 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Thu, 15 Mar 2018 15:11:53 -0400 Subject: [PATCH 30/40] ferret is unused now --- Gemfile | 1 - Gemfile.lock | 2 - README.md | 5 - .../data_sharing_orgs_controller.rb | 1 - app/controllers/locations_controller.rb | 4 - app/controllers/org_types_controller.rb | 2 - app/controllers/plumbing_controller.rb | 4 +- app/controllers/sectors_controller.rb | 2 - app/controllers/tags_controller.rb | 2 - app/models/organization.rb | 19 - app/models/person.rb | 5 - config/ferret_server.yml | 24 - doc/README | 17 +- doc/README.test | 2 - lib/import_helper.rb | 63 +- script/ferret_server | 12 - vendor/plugins/acts_as_ferret/.gitignore | 11 - vendor/plugins/acts_as_ferret/LICENSE | 20 - vendor/plugins/acts_as_ferret/README | 104 --- .../acts_as_ferret/acts_as_ferret.gemspec | 59 -- vendor/plugins/acts_as_ferret/bin/aaf_install | 29 - .../acts_as_ferret/config/ferret_server.yml | 24 - .../plugins/acts_as_ferret/doc/README.win32 | 23 - .../acts_as_ferret/doc/demo/.gitignore | 1 - vendor/plugins/acts_as_ferret/doc/demo/README | 154 ---- .../acts_as_ferret/doc/demo/README_DEMO | 23 - .../plugins/acts_as_ferret/doc/demo/Rakefile | 10 - .../controllers/admin/backend_controller.rb | 14 - .../app/controllers/admin_area_controller.rb | 4 - .../doc/demo/app/controllers/application.rb | 5 - .../app/controllers/contents_controller.rb | 49 -- .../app/controllers/searches_controller.rb | 8 - .../demo/app/helpers/admin/backend_helper.rb | 2 - .../demo/app/helpers/application_helper.rb | 3 - .../doc/demo/app/helpers/content_helper.rb | 2 - .../doc/demo/app/helpers/search_helper.rb | 2 - .../doc/demo/app/models/comment.rb | 48 -- .../doc/demo/app/models/content.rb | 12 - .../doc/demo/app/models/content_base.rb | 28 - .../doc/demo/app/models/search.rb | 19 - .../doc/demo/app/models/shared_index1.rb | 3 - .../doc/demo/app/models/shared_index2.rb | 3 - .../doc/demo/app/models/special_content.rb | 3 - .../doc/demo/app/models/stats.rb | 20 - .../demo/app/views/admin/backend/search.rhtml | 18 - .../doc/demo/app/views/contents/_form.rhtml | 10 - .../doc/demo/app/views/contents/edit.rhtml | 9 - .../doc/demo/app/views/contents/index.rhtml | 24 - .../doc/demo/app/views/contents/new.rhtml | 8 - .../doc/demo/app/views/contents/show.rhtml | 8 - .../app/views/layouts/application.html.erb | 17 - .../demo/app/views/searches/_content.html.erb | 2 - .../demo/app/views/searches/search.html.erb | 20 - .../acts_as_ferret/doc/demo/config/boot.rb | 109 --- .../doc/demo/config/database.yml | 38 - .../doc/demo/config/environment.rb | 69 -- .../demo/config/environments/development.rb | 16 - .../demo/config/environments/production.rb | 19 - .../doc/demo/config/environments/test.rb | 21 - .../doc/demo/config/ferret_server.yml | 18 - .../doc/demo/config/lighttpd.conf | 40 - .../acts_as_ferret/doc/demo/config/routes.rb | 9 - .../doc/demo/db/development_structure.sql | 15 - .../demo/db/migrate/001_initial_migration.rb | 18 - .../db/migrate/002_add_type_to_contents.rb | 9 - .../db/migrate/003_create_shared_index1s.rb | 11 - .../db/migrate/004_create_shared_index2s.rb | 11 - .../doc/demo/db/migrate/005_special_field.rb | 9 - .../doc/demo/db/migrate/006_create_stats.rb | 15 - .../acts_as_ferret/doc/demo/db/schema.sql | 18 - .../acts_as_ferret/doc/demo/db/schema.sqlite | 14 - .../doc/demo/doc/README_FOR_APP | 2 - .../acts_as_ferret/doc/demo/doc/howto.txt | 70 -- .../acts_as_ferret/doc/demo/public/.htaccess | 40 - .../acts_as_ferret/doc/demo/public/404.html | 8 - .../acts_as_ferret/doc/demo/public/500.html | 8 - .../doc/demo/public/dispatch.cgi | 10 - .../doc/demo/public/dispatch.fcgi | 24 - .../doc/demo/public/dispatch.rb | 10 - .../doc/demo/public/favicon.ico | 0 .../doc/demo/public/images/rails.png | Bin 1787 -> 0 bytes .../acts_as_ferret/doc/demo/public/index.html | 277 ------- .../acts_as_ferret/doc/demo/public/robots.txt | 1 - .../doc/demo/public/stylesheets/scaffold.css | 74 -- .../acts_as_ferret/doc/demo/script/about | 3 - .../doc/demo/script/breakpointer | 3 - .../acts_as_ferret/doc/demo/script/console | 3 - .../acts_as_ferret/doc/demo/script/destroy | 3 - .../doc/demo/script/ferret_server | 10 - .../acts_as_ferret/doc/demo/script/generate | 3 - .../doc/demo/script/performance/benchmarker | 3 - .../doc/demo/script/performance/profiler | 3 - .../acts_as_ferret/doc/demo/script/plugin | 3 - .../doc/demo/script/process/inspector | 3 - .../doc/demo/script/process/reaper | 3 - .../doc/demo/script/process/spawner | 3 - .../doc/demo/script/process/spinner | 3 - .../acts_as_ferret/doc/demo/script/runner | 3 - .../acts_as_ferret/doc/demo/script/server | 3 - .../doc/demo/test/fixtures/comments.yml | 12 - .../doc/demo/test/fixtures/contents.yml | 13 - .../demo/test/fixtures/remote_contents.yml | 9 - .../doc/demo/test/fixtures/shared_index1s.yml | 7 - .../doc/demo/test/fixtures/shared_index2s.yml | 7 - .../admin/backend_controller_test.rb | 35 - .../functional/contents_controller_test.rb | 81 -- .../functional/searches_controller_test.rb | 71 -- .../doc/demo/test/smoke/drb_smoke_test.rb | 321 -------- .../doc/demo/test/smoke/process_stats.rb | 21 - .../doc/demo/test/test_helper.rb | 30 - .../doc/demo/test/unit/comment_test.rb | 217 ------ .../doc/demo/test/unit/content_test.rb | 705 ------------------ .../doc/demo/test/unit/ferret_result_test.rb | 24 - .../doc/demo/test/unit/multi_index_test.rb | 329 -------- .../doc/demo/test/unit/remote_index_test.rb | 23 - .../doc/demo/test/unit/shared_index1_test.rb | 108 --- .../doc/demo/test/unit/shared_index2_test.rb | 13 - .../doc/demo/test/unit/sort_test.rb | 21 - .../demo/test/unit/special_content_test.rb | 25 - .../demo/vendor/plugins/will_paginate/LICENSE | 18 - .../demo/vendor/plugins/will_paginate/README | 108 --- .../vendor/plugins/will_paginate/Rakefile | 23 - .../demo/vendor/plugins/will_paginate/init.rb | 21 - .../lib/will_paginate/collection.rb | 45 -- .../lib/will_paginate/core_ext.rb | 44 -- .../will_paginate/lib/will_paginate/finder.rb | 159 ---- .../lib/will_paginate/view_helpers.rb | 95 --- .../test/array_pagination_test.rb | 23 - .../vendor/plugins/will_paginate/test/boot.rb | 27 - .../vendor/plugins/will_paginate/test/console | 10 - .../plugins/will_paginate/test/finder_test.rb | 219 ------ .../will_paginate/test/fixtures/admin.rb | 3 - .../will_paginate/test/fixtures/companies.yml | 24 - .../will_paginate/test/fixtures/company.rb | 23 - .../will_paginate/test/fixtures/developer.rb | 11 - .../test/fixtures/developers_projects.yml | 13 - .../will_paginate/test/fixtures/project.rb | 4 - .../will_paginate/test/fixtures/projects.yml | 7 - .../will_paginate/test/fixtures/replies.yml | 20 - .../will_paginate/test/fixtures/reply.rb | 5 - .../will_paginate/test/fixtures/schema.sql | 44 -- .../will_paginate/test/fixtures/topic.rb | 19 - .../will_paginate/test/fixtures/topics.yml | 30 - .../will_paginate/test/fixtures/user.rb | 2 - .../will_paginate/test/fixtures/users.yml | 35 - .../plugins/will_paginate/test/helper.rb | 42 -- .../test/lib/activerecord_test_connector.rb | 64 -- .../will_paginate/test/lib/load_fixtures.rb | 10 - .../will_paginate/test/pagination_test.rb | 136 ---- .../plugins/acts_as_ferret/doc/monit-example | 22 - vendor/plugins/acts_as_ferret/init.rb | 24 - vendor/plugins/acts_as_ferret/install.rb | 18 - .../plugins/acts_as_ferret/lib/act_methods.rb | 147 ---- .../acts_as_ferret/lib/acts_as_ferret.rb | 633 ---------------- .../lib/ar_mysql_auto_reconnect_patch.rb | 41 - .../plugins/acts_as_ferret/lib/blank_slate.rb | 54 -- .../acts_as_ferret/lib/bulk_indexer.rb | 56 -- .../acts_as_ferret/lib/class_methods.rb | 267 ------- .../acts_as_ferret/lib/ferret_extensions.rb | 192 ----- .../acts_as_ferret/lib/ferret_find_methods.rb | 144 ---- .../acts_as_ferret/lib/ferret_result.rb | 53 -- .../acts_as_ferret/lib/ferret_server.rb | 238 ------ vendor/plugins/acts_as_ferret/lib/index.rb | 99 --- .../acts_as_ferret/lib/instance_methods.rb | 172 ----- .../plugins/acts_as_ferret/lib/local_index.rb | 202 ----- .../acts_as_ferret/lib/more_like_this.rb | 217 ------ .../plugins/acts_as_ferret/lib/multi_index.rb | 133 ---- .../acts_as_ferret/lib/rdig_adapter.rb | 149 ---- .../acts_as_ferret/lib/remote_functions.rb | 43 -- .../acts_as_ferret/lib/remote_index.rb | 54 -- .../acts_as_ferret/lib/remote_multi_index.rb | 20 - .../acts_as_ferret/lib/search_results.rb | 50 -- .../acts_as_ferret/lib/server_manager.rb | 71 -- .../plugins/acts_as_ferret/lib/unix_daemon.rb | 86 --- .../plugins/acts_as_ferret/lib/without_ar.rb | 52 -- vendor/plugins/acts_as_ferret/rails/init.rb | 24 - vendor/plugins/acts_as_ferret/rakefile | 117 --- .../acts_as_ferret/recipes/aaf_recipes.rb | 116 --- .../acts_as_ferret/script/ferret_daemon | 94 --- .../acts_as_ferret/script/ferret_server | 12 - .../acts_as_ferret/script/ferret_service | 178 ----- .../plugins/acts_as_ferret/tasks/ferret.rake | 22 - 182 files changed, 5 insertions(+), 9150 deletions(-) delete mode 100644 config/ferret_server.yml delete mode 100755 script/ferret_server delete mode 100644 vendor/plugins/acts_as_ferret/.gitignore delete mode 100644 vendor/plugins/acts_as_ferret/LICENSE delete mode 100644 vendor/plugins/acts_as_ferret/README delete mode 100644 vendor/plugins/acts_as_ferret/acts_as_ferret.gemspec delete mode 100755 vendor/plugins/acts_as_ferret/bin/aaf_install delete mode 100644 vendor/plugins/acts_as_ferret/config/ferret_server.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/README.win32 delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/.gitignore delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/README delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/README_DEMO delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/Rakefile delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/controllers/admin/backend_controller.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/controllers/admin_area_controller.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/controllers/application.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/controllers/contents_controller.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/controllers/searches_controller.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/helpers/admin/backend_helper.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/helpers/application_helper.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/helpers/content_helper.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/helpers/search_helper.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/models/comment.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/models/content.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/models/content_base.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/models/search.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/models/shared_index1.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/models/shared_index2.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/models/special_content.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/models/stats.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/views/admin/backend/search.rhtml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/_form.rhtml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/edit.rhtml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/index.rhtml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/new.rhtml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/show.rhtml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/views/layouts/application.html.erb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/views/searches/_content.html.erb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/app/views/searches/search.html.erb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/config/boot.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/config/database.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/config/environment.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/config/environments/development.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/config/environments/production.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/config/environments/test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/config/ferret_server.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/config/lighttpd.conf delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/config/routes.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/db/development_structure.sql delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/db/migrate/001_initial_migration.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/db/migrate/002_add_type_to_contents.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/db/migrate/003_create_shared_index1s.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/db/migrate/004_create_shared_index2s.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/db/migrate/005_special_field.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/db/migrate/006_create_stats.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/db/schema.sql delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/db/schema.sqlite delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/doc/README_FOR_APP delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/doc/howto.txt delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/public/.htaccess delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/public/404.html delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/public/500.html delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.cgi delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.fcgi delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/public/favicon.ico delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/public/images/rails.png delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/public/index.html delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/public/robots.txt delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/public/stylesheets/scaffold.css delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/about delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/breakpointer delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/console delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/destroy delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/ferret_server delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/generate delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/performance/benchmarker delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/performance/profiler delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/plugin delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/process/inspector delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/process/reaper delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/process/spawner delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/process/spinner delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/runner delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/script/server delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/comments.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/contents.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/remote_contents.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/shared_index1s.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/shared_index2s.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/functional/admin/backend_controller_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/functional/contents_controller_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/functional/searches_controller_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/smoke/drb_smoke_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/smoke/process_stats.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/test_helper.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/unit/comment_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/unit/content_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/unit/ferret_result_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/unit/multi_index_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/unit/remote_index_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/unit/shared_index1_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/unit/shared_index2_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/unit/sort_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/test/unit/special_content_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/LICENSE delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/README delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/Rakefile delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/init.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/collection.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/finder.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/boot.rb delete mode 100755 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/console delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/finder_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/admin.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/companies.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/company.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/developer.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/project.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/projects.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/replies.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/reply.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/schema.sql delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/topic.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/topics.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/user.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/users.yml delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/helper.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/lib/load_fixtures.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/pagination_test.rb delete mode 100644 vendor/plugins/acts_as_ferret/doc/monit-example delete mode 100644 vendor/plugins/acts_as_ferret/init.rb delete mode 100644 vendor/plugins/acts_as_ferret/install.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/act_methods.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/ar_mysql_auto_reconnect_patch.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/blank_slate.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/class_methods.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/ferret_find_methods.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/ferret_result.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/ferret_server.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/index.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/instance_methods.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/local_index.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/more_like_this.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/multi_index.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/rdig_adapter.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/remote_functions.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/remote_index.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/remote_multi_index.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/search_results.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/server_manager.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/unix_daemon.rb delete mode 100644 vendor/plugins/acts_as_ferret/lib/without_ar.rb delete mode 100644 vendor/plugins/acts_as_ferret/rails/init.rb delete mode 100644 vendor/plugins/acts_as_ferret/rakefile delete mode 100644 vendor/plugins/acts_as_ferret/recipes/aaf_recipes.rb delete mode 100644 vendor/plugins/acts_as_ferret/script/ferret_daemon delete mode 100644 vendor/plugins/acts_as_ferret/script/ferret_server delete mode 100644 vendor/plugins/acts_as_ferret/script/ferret_service delete mode 100644 vendor/plugins/acts_as_ferret/tasks/ferret.rake diff --git a/Gemfile b/Gemfile index 7a1617ab..5d84672b 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,6 @@ gem "oj", "~> 2.2.0" gem "rack", "~> 1.1.0" gem "geokit", "~> 1.6.7" gem "google-v3-geocoder", "~> 1.0.0" -gem "ferret", "~> 0.11.8.5" gem "json", "~> 1.8.1" gem "mysql", "~> 2.9.1" gem "fastercsv", "~> 1.5.5" diff --git a/Gemfile.lock b/Gemfile.lock index 6e416543..964c64d8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,6 @@ GEM remote: https://rubygems.org/ specs: fastercsv (1.5.5) - ferret (0.11.8.5) geokit (1.6.7) multi_json (>= 1.3.2) google-v3-geocoder (1.0.0) @@ -21,7 +20,6 @@ PLATFORMS DEPENDENCIES fastercsv (~> 1.5.5) - ferret (~> 0.11.8.5) geokit (~> 1.6.7) google-v3-geocoder (~> 1.0.0) json (~> 1.8.1) diff --git a/README.md b/README.md index cdb1b51c..2f26f067 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,3 @@ You can then run the development server as: ``` $ ./script/server ``` - -To enable search indexing, do: -``` -$ ruby ./script/ferret_server -e development -R `pwd` start -``` diff --git a/app/controllers/data_sharing_orgs_controller.rb b/app/controllers/data_sharing_orgs_controller.rb index 61401f47..5192f8a0 100644 --- a/app/controllers/data_sharing_orgs_controller.rb +++ b/app/controllers/data_sharing_orgs_controller.rb @@ -184,7 +184,6 @@ def link_taggable if(DataSharingOrgsTaggable.set_status(dso, org, params[:verified] || false)) status = (params[:verified] ? 'verified' : 'unverified') flash[:notice] = "#{org.name} was successfully added to the data pool for #{dso.name} as #{status}" - org.ferret_update else flash[:error] = "Couldn't add Org to DSO" end diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index b6d418cc..5d15640c 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -59,7 +59,6 @@ def create merge_check @location = @organization.locations.create(params[:location]) @location.save! - @organization.ferret_update flash[:notice] = 'Location was successfully created.' respond_to do |format| format.html { redirect_to(@location) } @@ -84,7 +83,6 @@ def update respond_to do |format| if @location.update_attributes(params[:location]) - @organization.ferret_update flash[:notice] = 'Location was successfully updated.' format.html { redirect_to(@location) } format.xml { head :ok } @@ -106,7 +104,6 @@ def move if @organization2.primary_location == @location @organization2.update_attribute(:primary_location, nil) end - @organization.ferret_update flash[:notice] = 'Location was successfully updated.' respond_to do |format| format.html { redirect_to(@location) } @@ -122,7 +119,6 @@ def destroy @organization = @location.taggable merge_check @location.destroy - @organization.ferret_update respond_to do |format| format.html { redirect_to(locations_url) } diff --git a/app/controllers/org_types_controller.rb b/app/controllers/org_types_controller.rb index 747d7d36..cf2a792a 100644 --- a/app/controllers/org_types_controller.rb +++ b/app/controllers/org_types_controller.rb @@ -9,7 +9,6 @@ def dissociate @organization.org_types.delete(@org_type) @organization.save! @organization.notify_related_record_change(:deleted, @org_type) - @organization.ferret_update render :partial => 'manage' end @@ -20,7 +19,6 @@ def associate @organization.org_types.push(@org_type) @organization.save! @organization.notify_related_record_change(:added, @org_type) - @organization.ferret_update render :partial => 'manage' end diff --git a/app/controllers/plumbing_controller.rb b/app/controllers/plumbing_controller.rb index bd498d3e..d36a2107 100644 --- a/app/controllers/plumbing_controller.rb +++ b/app/controllers/plumbing_controller.rb @@ -8,14 +8,14 @@ def index def org @orgs = Organization.find(:all) @orgs.each do |org| - org.ferret_update + # do not need to do anything anymore end end def ppl @data = Person.find(:all) @data.each do |datum| - datum.ferret_update + # do not need to do anything anymore end end diff --git a/app/controllers/sectors_controller.rb b/app/controllers/sectors_controller.rb index cc076fc1..60c1993b 100644 --- a/app/controllers/sectors_controller.rb +++ b/app/controllers/sectors_controller.rb @@ -9,7 +9,6 @@ def dissociate @organization.sectors.delete(@sector) @organization.save! @organization.notify_related_record_change(:deleted, @sector) - @organization.ferret_update render :partial => 'manage' end @@ -20,7 +19,6 @@ def associate @organization.sectors.push(@sector) @organization.save! @organization.notify_related_record_change(:added, @sector) - @organization.ferret_update render :partial => 'manage' end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 222db0c5..07181d5d 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -30,7 +30,6 @@ def dissociate @taggable.taggings.delete(@tagging) @taggable.save! # @taggable.notify_related_record_change(:deleted, @tag) - @taggable.ferret_update @organization = @taggable render :partial => 'manage' end @@ -54,7 +53,6 @@ def associate @organization.tags.push(@tag) @organization.save! # @organization.notify_related_record_change(:added, @tag) - @organization.ferret_update render :partial => 'manage' end diff --git a/app/models/organization.rb b/app/models/organization.rb index d16794bd..96d57f93 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -29,25 +29,6 @@ class Organization < ActiveRecord::Base has_many :tags, :through => :taggings has_many :taggings, :as => :taggable - acts_as_ferret(:fields => { - :name => {:boost => 2.0, :store => :yes }, - :description => { :store => :yes }, - :products_services_to_s => { :store => :yes }, - :location => { :via => :locations_to_s, - :store => :yes }, - # some different tags to enable more selective searches - :state => { :via => :states_to_s }, - :zip => { :via => :zips_to_s }, - :country => { :via => :countries_to_s }, - :sector => { :via => :sectors_to_s }, - :org_type => { :via => :org_types_to_s }, - :access_type => { :store => :yes }, - :verified => { :via => :verified_to_s }, - :city => { :via => :cities_to_s }, -# :public => { :store => :yes }, - :pool => { :via => :pool_to_s }, - } ) - acts_as_reportable validates_presence_of :name diff --git a/app/models/person.rb b/app/models/person.rb index 5b2fe102..8ef5a77d 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -19,11 +19,6 @@ def as_json(options) validates_presence_of :firstname - acts_as_ferret(:fields => { - :name => {:boost => 2.0, :store => :yes }, - :access_type => { :store => :yes } - }) - def access_type self.access_rule.access_type end diff --git a/config/ferret_server.yml b/config/ferret_server.yml deleted file mode 100644 index 03227506..00000000 --- a/config/ferret_server.yml +++ /dev/null @@ -1,24 +0,0 @@ -# configuration for the acts_as_ferret DRb server -# host: where to reach the DRb server (used by application processes to contact the server) -# port: which port the server should listen on -# socket: where the DRb server should create the socket (absolute path), this setting overrides host:port configuration -# pid_file: location of the server's pid file (relative to RAILS_ROOT) -# log_file: log file (default: RAILS_ROOT/log/ferret_server.log -# log_level: log level for the server's logger -production: - host: localhost - port: 9012 - pid_file: log/ferret.pid - log_file: log/ferret_server.log - log_level: warn - -# aaf won't try to use the DRb server in environments that are not -# configured here. -development: - host: localhost - port: 9010 - pid_file: log/ferret.pid -#test: -# host: localhost -# port: 9009 -# pid_file: log/ferret.pid diff --git a/doc/README b/doc/README index a19a55e4..a10b5cc5 100644 --- a/doc/README +++ b/doc/README @@ -5,7 +5,6 @@ This application requires the following gems: rails v2.2.2 ruport acts_as_reportable - ferret geokit mysql @@ -13,7 +12,7 @@ Installation on a generic debian/ubuntu machine: apt-get install rubygems gem install --version 2.2.2 --no-rdoc --no-ri rails apt-get install ruby-dev # needed for building native extensions - gem install --no-rdoc --no-ri ruport acts_as_reportable ferret geokit + gem install --no-rdoc --no-ri ruport acts_as_reportable geokit apt-get install libmysqlclient-dev gem install --no-rdoc --no-ri mysql apt-get install ruby @@ -39,20 +38,6 @@ Then (do "rake -T" to see all options): At this point, running a test server should work: ./script/server -============================================================================ -== Searches - -To get Searches working in the DCP Directory: -1) Start up the Ferret Server: -script/ferret_server -e production -R `pwd` start -or -script/ferret_server -e development -R `pwd` start - -2) If the index has never been built (i.e. first installation, first run, etc.): -script/runner -e production 'Organization.rebuild_index' -or -script/runner -e development 'Organization.rebuild_index' - ============================================================================ == Development diff --git a/doc/README.test b/doc/README.test index fd30c53d..eef2fd3e 100644 --- a/doc/README.test +++ b/doc/README.test @@ -13,7 +13,5 @@ To view a test server: #rm -rf index #rm -rf log - script/ferret_server -e test -R `pwd` start - script/runner -e test 'Organization.rebuild_index' script/server -e test diff --git a/lib/import_helper.rb b/lib/import_helper.rb index 79ea7077..7b652ccd 100644 --- a/lib/import_helper.rb +++ b/lib/import_helper.rb @@ -25,68 +25,9 @@ def match_with_ferret_base(org_attr, loc_attr, dso) errors = [] match_status = {} orgs = [] - - orgName = org_attr[:name] || "NOTHINGTOSEEHEARMOVEALONGFOLKS" - seek_name = orgName.gsub(/\(.*\)/,'') - orgs = Organization.find_with_ferret("\"#{seek_name}\"") - prev_seek_name = "" - if orgs.length>1 - orgs = Organization.find_with_ferret("name:\"#{seek_name}\"") - end - seek_name = seek_name.gsub(/[^a-zA-Z0-9]/,'* ').gsub(/^ */,'').gsub(/ *$/,'').gsub(/ +/,' ') - while orgs.length == 0 - prev_seek_name = seek_name - seek_name = seek_name.gsub(/ [^ ]*$/,'') - # errors.push "Trying #{prev_seek_name} vs #{seek_name}" - break if seek_name == prev_seek_name - orgs = Organization.find_with_ferret("name:\"#{seek_name}\"") - unless seek_name.include? " " - match_status[:weak] = true - end - if orgs.length>1 - orgs = [] - break - end - end match = nil - if orgs.nil? - errors.push "Do not know what to do with #{orgName}" - elsif orgs.length == 1 - match = orgs.first - match_status[:linked] = match.data_sharing_orgs.member? dso - unless match_status[:linked] - if match_status[:weak] - plausible = false - match.locations.each do |loc| - if loose_match(loc.summary_city,loc_attr[:physical_city]) - plausible = true - end - addr = "" - x = loc.physical_address1 - unless x.nil? - unless x.gsub(/[^A-Za-z0-9]/,'').length>0 - x = nil - end - end - unless x.nil? - addr = loc.physical_address1 unless loc.physical_address1.nil? - addr = addr + " " + loc.physical_address2 unless loc.physical_address2.nil? - else - addr = loc.mailing_address1 unless loc.mailing_address1.nil? - addr = addr + " " + loc.mailing_address2 unless loc.mailing_address2.nil? - end - if loose_match(addr,loc_attr[:physical_address1]) - plausible = true - end - end - unless plausible - errors.push "Implausible location match for #{orgName}" - match = nil - orgs = [] - end - end - end - end + + # No longer does anything - old unused code. @errors = errors @match_status = match_status diff --git a/script/ferret_server b/script/ferret_server deleted file mode 100755 index b2ecc1a6..00000000 --- a/script/ferret_server +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env ruby - -FERRET_SERVER = File.expand_path(__FILE__) - -begin - require File.join(File.dirname(__FILE__), '../vendor/plugins/acts_as_ferret/lib/server_manager') -rescue LoadError - # try the gem - require 'rubygems' - gem 'acts_as_ferret' - require 'server_manager' -end diff --git a/vendor/plugins/acts_as_ferret/.gitignore b/vendor/plugins/acts_as_ferret/.gitignore deleted file mode 100644 index f9991814..00000000 --- a/vendor/plugins/acts_as_ferret/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -*.swp -*.log -doc/demo/log/* -doc/demo/tmp/* -index/* -doc/demo/index/* -doc/demo/db/schema.rb -doc/demo/vendor/plugins/acts_as_ferret -html -pkg -tmp diff --git a/vendor/plugins/acts_as_ferret/LICENSE b/vendor/plugins/acts_as_ferret/LICENSE deleted file mode 100644 index b07e5a5c..00000000 --- a/vendor/plugins/acts_as_ferret/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2006 Kasper Weibel, Jens Kraemer - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/acts_as_ferret/README b/vendor/plugins/acts_as_ferret/README deleted file mode 100644 index e6d64e1c..00000000 --- a/vendor/plugins/acts_as_ferret/README +++ /dev/null @@ -1,104 +0,0 @@ -= acts_as_ferret - -This ActiveRecord mixin adds full text search capabilities to any Rails model. - -It is heavily based on the original acts_as_ferret plugin done by -Kasper Weibel and a modified version done by Thomas Lockney, which -both can be found on http://ferret.davebalmain.com/trac/wiki/FerretOnRails - -== Project Wiki and Issue tracker - -http://wiki.github.com/jkraemer/acts_as_ferret/ -http://j-k.lighthouseapp.com/projects/45560-acts-as-ferret - -== Installation - -Aaf is available as a gem (gem install acts_as_ferret), or via git from github.com. -Github also offers tarball downloads, check out -http://github.com/jkraemer/acts_as_ferret/tree/master . - -=== Set up your Rails > 2.1 project to use the acts_as_ferret gem. - -Add this to your project's config/environment.rb (inside the Rails::Initializer.run block): - - - config.gem 'acts_as_ferret', :version => '~> 0.4.8' - config.after_initialize { ActsAsFerret::load_config } - config.to_prepare { ActsAsFerret::load_config } - - -With the gem installed, change into your RAILS_ROOT and run the supplied aaf_install script. -This will copy rake tasks, capistrano recipes and the ferret server config and startup script -into your project. - -In order to have the capistrano recipe loaded you'll have to patch your Capfile a bit. I use to have -a line like that in my Capfiles, loading everything found below RAILS_ROOT/lib/recipes: - -Dir['lib/recipes/**/*.rb'].each { |plugin| load(plugin) } - - -=== Installation inside your Rails project via script/plugin - -script/plugin install git://github.com/jkraemer/acts_as_ferret.git - -No additional setup needed. - - -== Usage - -There are two ways to make your models searchable with aaf. The option to configure acts_as_ferret with -a single configuration file has been introduced because it makes more sense when a single index holds multiple -models - it's simply more logicl to define that index and tell which models should go into it than to call -acts_as_ferret in each model pointing to the same index every time. - -=== central configuration file - -With this option, all acts_as_ferret indexes are configured in a single file, RAILS_ROOT/config/aaf.rb: - -ActsAsFerret::define_index( 'my_index', - :models => { - SomeModel => { - :fields => { - :name => { :boost => 4, :store => :yes, :via => :ferret_title }, - :foo => { :store => :no, :index => :untokenized }, - :baz => { :store => :yes, :via => :ferret_content } - } - } - } ) - -ActsAsFerret::define_index( 'some_other_index', - :models => { - Foo => { :fields => { ... } }, - Bar => { ... }, - } ) - - -As you can see for every index you want to define there's a single call, and each model that should go -into the index gets it's own ferret options hash (see the acts_as_ferret class method docs for all available options). - -=== In your models (the old fashioned way) -include the following in your model class (specifiying the fields you want to get indexed): - -acts_as_ferret :fields => [ :title, :description ] - -now you can use ModelClass.find_with_ferret(query) to find instances of your model -whose indexed fields match a given query. All query terms are required by default, -but explicit OR queries are possible. This differs from the ferret default, but -imho is the more often needed/expected behaviour (more query terms result in -less results). - -Please see ActsAsFerret::ActMethods#acts_as_ferret for more information. - -== Known issues - -aaf is not yet ready for Rails3. Feel free to submit patches! - -== License - -Released under the MIT license. - -== Authors - -* Kasper Weibel Nielsen-Refs (original author) -* Jens Kraemer (current maintainer) - diff --git a/vendor/plugins/acts_as_ferret/acts_as_ferret.gemspec b/vendor/plugins/acts_as_ferret/acts_as_ferret.gemspec deleted file mode 100644 index 3e5f2451..00000000 --- a/vendor/plugins/acts_as_ferret/acts_as_ferret.gemspec +++ /dev/null @@ -1,59 +0,0 @@ -Gem::Specification.new do |s| - - s.name = 'acts_as_ferret' - s.version = '0.4.8.2' - s.authors = ['Jens Kraemer'] - s.summary = 'acts_as_ferret - Ferret based full text search for any ActiveRecord model' - s.description = 'Rails plugin that adds powerful full text search capabilities to ActiveRecord models.' - s.email = 'jk@jkraemer.net' - s.homepage = 'http://github.com/jkraemer/acts_as_ferret' - s.rubyforge_project = 'acts_as_ferret' - - s.bindir = 'bin' - s.executables = ['aaf_install'] - s.default_executable = 'aaf_install' - s.require_paths = ["lib"] - - - s.platform = Gem::Platform::RUBY - s.required_ruby_version = '>=1.8.6' - s.rubygems_version = '1.3.6' - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency('jk-ferret', [">= 0.11.8"]) - else - s.add_dependency('jk-ferret', [">= 0.11.8"]) - end - else - s.add_dependency('jk-ferret', [">= 0.11.8"]) - end - - - s.has_rdoc = true - s.rdoc_options = ["--charset=UTF-8"] - s.extra_rdoc_files = [ - 'LICENSE', - 'README' - ] - s.test_files = Dir['test/**/*rb'] - s.files = [ - 'bin/*', - 'config/*', - 'doc/**/*', - 'recipes/*', - 'script/*', - 'tasks/*', - 'lib/**/*rb' - ].map{|p| Dir[p]}.flatten + - [ - 'acts_as_ferret.gemspec', - 'init.rb', - 'install.rb', - 'README', - 'LICENSE', - ] - -end diff --git a/vendor/plugins/acts_as_ferret/bin/aaf_install b/vendor/plugins/acts_as_ferret/bin/aaf_install deleted file mode 100755 index f0978b34..00000000 --- a/vendor/plugins/acts_as_ferret/bin/aaf_install +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env ruby -# acts_as_ferret gem install script -# Use inside the root of your Rails project -require 'fileutils' - -@basedir = File.join(File.dirname(__FILE__), '..') - -def install(src, target_dir, executable=false) - puts "Installing: #{src}" - src = File.join(@basedir, src) - fname = File.basename(src) - target = File.join(target_dir, fname) - if File.exists?(target) - puts "#{target} already exists, skipping" - else - FileUtils.mkdir_p target_dir - FileUtils.cp src, target - FileUtils.chmod 0755, target if executable - end -end - - -install 'script/ferret_server', 'script', true -install 'config/ferret_server.yml', 'config' -install 'tasks/ferret.rake', 'lib/tasks' -install 'recipes/aaf_recipes.rb', 'lib/recipes' - -puts IO.read(File.join(@basedir, 'README')) - diff --git a/vendor/plugins/acts_as_ferret/config/ferret_server.yml b/vendor/plugins/acts_as_ferret/config/ferret_server.yml deleted file mode 100644 index 402e54ee..00000000 --- a/vendor/plugins/acts_as_ferret/config/ferret_server.yml +++ /dev/null @@ -1,24 +0,0 @@ -# configuration for the acts_as_ferret DRb server -# host: where to reach the DRb server (used by application processes to contact the server) -# port: which port the server should listen on -# socket: where the DRb server should create the socket (absolute path), this setting overrides host:port configuration -# pid_file: location of the server's pid file (relative to RAILS_ROOT) -# log_file: log file (default: RAILS_ROOT/log/ferret_server.log -# log_level: log level for the server's logger -production: - host: localhost - port: 9010 - pid_file: log/ferret.pid - log_file: log/ferret_server.log - log_level: warn - -# aaf won't try to use the DRb server in environments that are not -# configured here. -#development: -# host: localhost -# port: 9010 -# pid_file: log/ferret.pid -#test: -# host: localhost -# port: 9009 -# pid_file: log/ferret.pid diff --git a/vendor/plugins/acts_as_ferret/doc/README.win32 b/vendor/plugins/acts_as_ferret/doc/README.win32 deleted file mode 100644 index 97bb4653..00000000 --- a/vendor/plugins/acts_as_ferret/doc/README.win32 +++ /dev/null @@ -1,23 +0,0 @@ -Credits -======= - -The Win32 service support scripts have been written by -Herryanto Siatono . - -See his accompanying blog posting at -http://www.pluitsolutions.com/2007/07/30/acts-as-ferret-drbserver-win32-service/ - - -Usage -===== - -There are two scripts: - -script/ferret_service is used to install/remove/start/stop the win32 service. - -script/ferret_daemon is to be called by Win32 service to start/stop the -DRbServer. - -Run 'ruby script/ferret_service -h' for more info. - - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/.gitignore b/vendor/plugins/acts_as_ferret/doc/demo/.gitignore deleted file mode 100644 index 6bfe6b19..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/.gitignore +++ /dev/null @@ -1 +0,0 @@ -log diff --git a/vendor/plugins/acts_as_ferret/doc/demo/README b/vendor/plugins/acts_as_ferret/doc/demo/README deleted file mode 100644 index 12a5e915..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/README +++ /dev/null @@ -1,154 +0,0 @@ -== Welcome to Rails - - -Rails is a web-application and persistence framework that includes everything -needed to create database-backed web-applications according to the -Model-View-Control pattern of separation. This pattern splits the view (also -called the presentation) into "dumb" templates that are primarily responsible -for inserting pre-built data in between HTML tags. The model contains the -"smart" domain objects (such as Account, Product, Person, Post) that holds all -the business logic and knows how to persist themselves to a database. The -controller handles the incoming requests (such as Save New Account, Update -Product, Show Post) by manipulating the model and directing data to the view. - -In Rails, the model is handled by what's called an object-relational mapping -layer entitled Active Record. This layer allows you to present the data from -database rows as objects and embellish these data objects with business logic -methods. You can read more about Active Record in -link:files/vendor/rails/activerecord/README.html. - -The controller and view are handled by the Action Pack, which handles both -layers by its two parts: Action View and Action Controller. These two layers -are bundled in a single package due to their heavy interdependence. This is -unlike the relationship between the Active Record and Action Pack that is much -more separate. Each of these packages can be used independently outside of -Rails. You can read more about Action Pack in -link:files/vendor/rails/actionpack/README.html. - - -== Getting started - -1. Run the WEBrick servlet: ruby script/server (run with --help for options) - ...or if you have lighttpd installed: ruby script/lighttpd (it's faster) -2. Go to http://localhost:3000/ and get "Congratulations, you've put Ruby on Rails!" -3. Follow the guidelines on the "Congratulations, you've put Ruby on Rails!" screen - - -== Example for Apache conf - - - ServerName rails - DocumentRoot /path/application/public/ - ErrorLog /path/application/log/server.log - - - Options ExecCGI FollowSymLinks - AllowOverride all - Allow from all - Order allow,deny - - - -NOTE: Be sure that CGIs can be executed in that directory as well. So ExecCGI -should be on and ".cgi" should respond. All requests from 127.0.0.1 go -through CGI, so no Apache restart is necessary for changes. All other requests -go through FCGI (or mod_ruby), which requires a restart to show changes. - - -== Debugging Rails - -Have "tail -f" commands running on both the server.log, production.log, and -test.log files. Rails will automatically display debugging and runtime -information to these files. Debugging info will also be shown in the browser -on requests from 127.0.0.1. - - -== Breakpoints - -Breakpoint support is available through the script/breakpointer client. This -means that you can break out of execution at any point in the code, investigate -and change the model, AND then resume execution! Example: - - class WeblogController < ActionController::Base - def index - @posts = Post.find_all - breakpoint "Breaking out from the list" - end - end - -So the controller will accept the action, run the first line, then present you -with a IRB prompt in the breakpointer window. Here you can do things like: - -Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint' - - >> @posts.inspect - => "[#nil, \"body\"=>nil, \"id\"=>\"1\"}>, - #\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]" - >> @posts.first.title = "hello from a breakpoint" - => "hello from a breakpoint" - -...and even better is that you can examine how your runtime objects actually work: - - >> f = @posts.first - => #nil, "body"=>nil, "id"=>"1"}> - >> f. - Display all 152 possibilities? (y or n) - -Finally, when you're ready to resume execution, you press CTRL-D - - -== Console - -You can interact with the domain model by starting the console through script/console. -Here you'll have all parts of the application configured, just like it is when the -application is running. You can inspect domain models, change values, and save to the -database. Starting the script without arguments will launch it in the development environment. -Passing an argument will specify a different environment, like console production. - - -== Description of contents - -app - Holds all the code that's specific to this particular application. - -app/controllers - Holds controllers that should be named like weblog_controller.rb for - automated URL mapping. All controllers should descend from - ActionController::Base. - -app/models - Holds models that should be named like post.rb. - Most models will descend from ActiveRecord::Base. - -app/views - Holds the template files for the view that should be named like - weblog/index.rhtml for the WeblogController#index action. All views use eRuby - syntax. This directory can also be used to keep stylesheets, images, and so on - that can be symlinked to public. - -app/helpers - Holds view helpers that should be named like weblog_helper.rb. - -config - Configuration files for the Rails environment, the routing map, the database, and other dependencies. - -components - Self-contained mini-applications that can bundle together controllers, models, and views. - -lib - Application specific libraries. Basically, any kind of custom code that doesn't - belong under controllers, models, or helpers. This directory is in the load path. - -public - The directory available for the web server. Contains subdirectories for images, stylesheets, - and javascripts. Also contains the dispatchers and the default HTML files. - -script - Helper scripts for automation and generation. - -test - Unit and functional tests along with fixtures. - -vendor - External libraries that the application depends on. Also includes the plugins subdirectory. - This directory is in the load path. diff --git a/vendor/plugins/acts_as_ferret/doc/demo/README_DEMO b/vendor/plugins/acts_as_ferret/doc/demo/README_DEMO deleted file mode 100644 index 0e04ae92..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/README_DEMO +++ /dev/null @@ -1,23 +0,0 @@ -Acts_as_Ferret demo project -=========================== - -This project is intended to run with edge rails which can -be installed with - -rake rails:freeze:edge - - -You'll also need to set up a database for it. -SQL scripts for both SQLite and MySQL are provided in db/ . - -Just set up one of these, and configure your db connection -in config/database.yml . - -after that run -rake -to see the unit tests pass. - - -Please feel free to post bugs/enhancements/patches at -http://projects.jkraemer.net/acts_as_ferret . - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/Rakefile b/vendor/plugins/acts_as_ferret/doc/demo/Rakefile deleted file mode 100644 index cffd19f0..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/Rakefile +++ /dev/null @@ -1,10 +0,0 @@ -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/switchtower.rake, and they will automatically be available to Rake. - -require(File.join(File.dirname(__FILE__), 'config', 'boot')) - -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -require 'tasks/rails' \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/admin/backend_controller.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/admin/backend_controller.rb deleted file mode 100644 index d658a22d..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/admin/backend_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -class Admin::BackendController < AdminAreaController - - def search - @query = params[:query] || '' - unless @query.blank? - @results = Content.find_with_ferret @query - end - end - - def show - @content = Content.find(params[:id]) - render :template => 'content/show' - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/admin_area_controller.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/admin_area_controller.rb deleted file mode 100644 index b86f0191..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/admin_area_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class AdminAreaController < ApplicationController - -end - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/application.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/application.rb deleted file mode 100644 index 92e7d21b..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/application.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Filters added to this controller will be run for all controllers in the application. -# Likewise, all the methods added will be available for all controllers. -class ApplicationController < ActionController::Base -end - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/contents_controller.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/contents_controller.rb deleted file mode 100644 index 8ffb07e4..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/contents_controller.rb +++ /dev/null @@ -1,49 +0,0 @@ -class ContentsController < ApplicationController - before_filter :find_content, :only => [ :show, :edit, :update, :destroy ] - - def index - @contents = Content.paginate :page => params[:page] - end - - def show - end - - def new - @content = Content.new - end - - def create - @content = Content.new(params[:content]) - if @content.save - flash[:notice] = 'Content was successfully created.' - redirect_to contents_url - else - render :action => 'new' - end - logger.error "#############{@content.errors.full_messages}" - end - - def edit - end - - def update - if @content.update_attributes(params[:content]) - flash[:notice] = 'Content was successfully updated.' - redirect_to :action => 'show', :id => @content - else - render :action => 'edit' - end - end - - def destroy - @content.destroy - redirect_to :action => 'list' - end - - protected - - def find_content - @content = Content.find params[:id] - end - -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/searches_controller.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/searches_controller.rb deleted file mode 100644 index 3507a3c8..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/controllers/searches_controller.rb +++ /dev/null @@ -1,8 +0,0 @@ -class SearchesController < ApplicationController - - def search - @search = Search.new params[:q], params[:page] - @results = @search.run if @search.valid? - end - -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/admin/backend_helper.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/admin/backend_helper.rb deleted file mode 100644 index bbec4a8b..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/admin/backend_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Admin::BackendHelper -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/application_helper.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/application_helper.rb deleted file mode 100644 index 22a7940e..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/application_helper.rb +++ /dev/null @@ -1,3 +0,0 @@ -# Methods added to this helper will be available to all templates in the application. -module ApplicationHelper -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/content_helper.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/content_helper.rb deleted file mode 100644 index 31996048..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/content_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ContentHelper -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/search_helper.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/search_helper.rb deleted file mode 100644 index b3ce20ac..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/helpers/search_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module SearchHelper -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/models/comment.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/models/comment.rb deleted file mode 100644 index f725c029..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/models/comment.rb +++ /dev/null @@ -1,48 +0,0 @@ - -class PlainAsciiAnalyzer < ::Ferret::Analysis::Analyzer - include ::Ferret::Analysis - def token_stream(field, str) - StopFilter.new( - StandardTokenizer.new(str) , - ["fax", "gsm"] - ) - # raise #<<<----- is never executed when uncommented !! - end -end - - -class Comment < ActiveRecord::Base - belongs_to :parent, :class_name => 'Content', :foreign_key => :parent_id - - # simplest case: just index all fields of this model: - # acts_as_ferret - - # use the :additional_fields property to specify fields you intend - # to add in addition to those fields from your database table (which will be - # autodiscovered by acts_as_ferret) - # the :ignore flag tells aaf to not try to set this field's value itself (we - # do this in our custom to_doc method) - acts_as_ferret( :if => Proc.new { |comment| comment.do_index? }, - :fields => { - :content => { :store => :yes }, - :author => { }, - :added => { :index => :untokenized, :store => :yes, :ignore => true }, - :aliased => { :via => :content } - }, :ferret => { :analyzer => Ferret::Analysis::StandardAnalyzer.new(['fax', 'gsm', 'the', 'or']) } ) - #}, :ferret => { :analyzer => PlainAsciiAnalyzer.new(['fax', 'gsm', 'the', 'or']) } ) - - def do_index? - self.content !~ /do not index/ - end - - # you can override the default to_doc method - # to customize what gets into your index. - def to_doc - # doc now has all the fields of our model instance, we - # just add another field to it: - doc = super - # add a field containing the current time - doc[:added] = Time.now.to_i.to_s - return doc - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/models/content.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/models/content.rb deleted file mode 100644 index 8aadc0ed..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/models/content.rb +++ /dev/null @@ -1,12 +0,0 @@ -class Content < ContentBase #ActiveRecord::Base - - def self.per_page; 10; end - - has_many :comments - - # returns the number of comments attached to this content. - # the value returned by this method will be indexed, too. - def comment_count - comments.size - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/models/content_base.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/models/content_base.rb deleted file mode 100644 index 6de01924..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/models/content_base.rb +++ /dev/null @@ -1,28 +0,0 @@ -# common base class for Content and SpecialContent -class ContentBase < ActiveRecord::Base - set_table_name 'contents' - - # a higher boost means more importance for the field --> documents having a - # match in a field with a higher boost value will be ranked higher - # - # we use the store_class_name flag to be able to retrieve model instances when - # searching multiple indexes at once. - # the contents of the description field are stored in the index for running - # 'more like this' queries to find other content instances with similar - # descriptions - acts_as_ferret( :fields => { :comment_count => { :index => :untokenized }, - :title => { :boost => :title_boost }, - :description => { :boost => 1, :store => :yes }, - :special => {} }, - :boost => :record_boost) - - def comment_count; 0 end - - attr_accessor :record_boost - attr_writer :title_boost - def title_boost - @title_boost || 2 - end -end - - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/models/search.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/models/search.rb deleted file mode 100644 index 1ba1b644..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/models/search.rb +++ /dev/null @@ -1,19 +0,0 @@ -# search form model -class Search - - attr_reader :query - - def initialize(query, page) - @query = query - @page = page ? page.to_i : 1 - end - - def valid? - !@query.blank? - end - - # run the search - def run - Content.find_with_ferret @query, :page => @page, :per_page => 10, :sort => 'title', :lazy => true - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/models/shared_index1.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/models/shared_index1.rb deleted file mode 100644 index ee47d87c..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/models/shared_index1.rb +++ /dev/null @@ -1,3 +0,0 @@ -class SharedIndex1 < ActiveRecord::Base - acts_as_ferret :index => 'shared' -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/models/shared_index2.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/models/shared_index2.rb deleted file mode 100644 index e40f6edb..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/models/shared_index2.rb +++ /dev/null @@ -1,3 +0,0 @@ -class SharedIndex2 < ActiveRecord::Base - acts_as_ferret :index => 'shared' -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/models/special_content.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/models/special_content.rb deleted file mode 100644 index 99fb3a06..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/models/special_content.rb +++ /dev/null @@ -1,3 +0,0 @@ -class SpecialContent < ContentBase - -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/models/stats.rb b/vendor/plugins/acts_as_ferret/doc/demo/app/models/stats.rb deleted file mode 100644 index 032d78ae..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/models/stats.rb +++ /dev/null @@ -1,20 +0,0 @@ -class Stats < ActiveRecord::Base - def self.compute(kind) - start_date = minimum :created_at - sql = <<-END - select min(processing_time), max(processing_time), avg(processing_time), stddev(processing_time), - concat_ws(':', hour(timediff(created_at, ?)), lpad(minute(timediff(created_at, ?)), 2, '0')) as time, - group_concat(processing_time) as data - from stats - where kind=? group by time; - END - result = connection.execute sanitize_sql([sql, start_date, start_date, kind.to_s]) - [].tap do |res| - while row = result.fetch_row - data = row.last.split(',').map{|t|t.to_i} - median = data.size.odd? ? data[data.size/2] : ((data[data.size/2-1]+data[data.size/2]) / 2.0) - res << { :min => row[0].to_f, :max => row[1].to_f, :avg => row[2].to_f, :stddev => row[3].to_f, :time => row[4], :median => median } - end - end - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/views/admin/backend/search.rhtml b/vendor/plugins/acts_as_ferret/doc/demo/app/views/admin/backend/search.rhtml deleted file mode 100644 index 85fb4619..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/views/admin/backend/search.rhtml +++ /dev/null @@ -1,18 +0,0 @@ -

Search Content (backend)

-<% form_tag :action => 'search' do %> -
- Search - -
- <%= submit_tag 'search' %> -<% end %> - -<% if @results -%> -

Your search for <%= h @query %> returned <%= @results.size %> Results:

-
    - <% @results.each { |result| -%> -
  • <%= link_to result.title, :action => 'show', :id => result %>
  • - <% } -%> -
-<% end -%> - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/_form.rhtml b/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/_form.rhtml deleted file mode 100644 index aa1bde5e..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/_form.rhtml +++ /dev/null @@ -1,10 +0,0 @@ -<%= error_messages_for 'content' %> - - -


-<%= form.text_field 'title' %>

- -


-<%= form.text_area 'description' %>

- - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/edit.rhtml b/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/edit.rhtml deleted file mode 100644 index 48fdc5b4..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/edit.rhtml +++ /dev/null @@ -1,9 +0,0 @@ -

Editing content

- -<% form_for :content, @content, content_path(@content), :html => { :method => :put } do |f| %> - <%= render :partial => 'form', :object => f %> - <%= submit_tag 'Edit' %> -<% end %> - -<%= link_to 'Show', content_path(@content) %> | -<%= link_to 'Back', contents_path %> diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/index.rhtml b/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/index.rhtml deleted file mode 100644 index 52afa035..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/index.rhtml +++ /dev/null @@ -1,24 +0,0 @@ -

Listing contents

- -

<%= will_paginate @contents %>

- - - <% for column in Content.content_columns %> - - <% end %> - - -<% for content in @contents %> - - <% for column in Content.content_columns %> - - <% end %> - - - - -<% end %> -
<%= column.human_name %>
<%=h content.send(column.name) %><%= link_to 'Show', :action => 'show', :id => content %><%= link_to 'Edit', :action => 'edit', :id => content %><%= link_to 'Destroy', { :action => 'destroy', :id => content }, :confirm => 'Are you sure?' %>
- -

<%= will_paginate @contents %>

-

<%= link_to 'New content', :action => 'new' %>

diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/new.rhtml b/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/new.rhtml deleted file mode 100644 index 5e4629b5..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/new.rhtml +++ /dev/null @@ -1,8 +0,0 @@ -

New content

- -<% form_for :content, @content, :url => contents_path, :html => { :method => :post } do |f| %> - <%= render :partial => 'form', :object => f %> - <%= submit_tag "Create" %> -<% end %> - -<%= link_to 'Back', :action => 'list' %> diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/show.rhtml b/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/show.rhtml deleted file mode 100644 index 1a78009d..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/views/contents/show.rhtml +++ /dev/null @@ -1,8 +0,0 @@ -<% for column in Content.content_columns %> -

- <%= column.human_name %>: <%=h @content.send(column.name) %> -

-<% end %> - -<%= link_to 'Edit', :action => 'edit', :id => @content %> | -<%= link_to 'Back', :action => 'list' %> diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/views/layouts/application.html.erb b/vendor/plugins/acts_as_ferret/doc/demo/app/views/layouts/application.html.erb deleted file mode 100644 index ab0f2cdd..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/views/layouts/application.html.erb +++ /dev/null @@ -1,17 +0,0 @@ - - - acts_as_ferret demo application - <%= stylesheet_link_tag 'scaffold' %> - - -
    -
  • <%= link_to 'Contents', contents_path %>
  • -
  • <%= link_to 'Search', search_path %>
  • -
- -

<%= flash[:notice] %>

- -<%= yield %> - - - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/views/searches/_content.html.erb b/vendor/plugins/acts_as_ferret/doc/demo/app/views/searches/_content.html.erb deleted file mode 100644 index 14369154..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/views/searches/_content.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -
  • <%= link_to content.title, content_path(content.id) %>
  • - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/app/views/searches/search.html.erb b/vendor/plugins/acts_as_ferret/doc/demo/app/views/searches/search.html.erb deleted file mode 100644 index 3eb21dd4..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/app/views/searches/search.html.erb +++ /dev/null @@ -1,20 +0,0 @@ -

    Search

    -<% form_tag search_path do %> -
    - Search - <%= text_field_tag 'q', @search.query %> -
    - <%= submit_tag 'search' %> -<% end %> - -<% if @results -%> - -

    Your search for <%= h @search.query %> returned <%= @results.total_hits %> Results:

    - -

    <%= will_paginate @results %>

    -
      - <%= render :partial => 'content', :collection => @results -%> -
    -

    <%= will_paginate @results %>

    - -<% end -%> diff --git a/vendor/plugins/acts_as_ferret/doc/demo/config/boot.rb b/vendor/plugins/acts_as_ferret/doc/demo/config/boot.rb deleted file mode 100644 index 6a30b549..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/config/boot.rb +++ /dev/null @@ -1,109 +0,0 @@ -# Don't change this file! -# Configure your app in config/environment.rb and config/environments/*.rb - -RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) - -module Rails - class << self - def boot! - unless booted? - preinitialize - pick_boot.run - end - end - - def booted? - defined? Rails::Initializer - end - - def pick_boot - (vendor_rails? ? VendorBoot : GemBoot).new - end - - def vendor_rails? - File.exist?("#{RAILS_ROOT}/vendor/rails") - end - - def preinitialize - load(preinitializer_path) if File.exist?(preinitializer_path) - end - - def preinitializer_path - "#{RAILS_ROOT}/config/preinitializer.rb" - end - end - - class Boot - def run - load_initializer - Rails::Initializer.run(:set_load_path) - end - end - - class VendorBoot < Boot - def load_initializer - require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" - Rails::Initializer.run(:install_gem_spec_stubs) - end - end - - class GemBoot < Boot - def load_initializer - self.class.load_rubygems - load_rails_gem - require 'initializer' - end - - def load_rails_gem - if version = self.class.gem_version - gem 'rails', version - else - gem 'rails' - end - rescue Gem::LoadError => load_error - $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.) - exit 1 - end - - class << self - def rubygems_version - Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion - end - - def gem_version - if defined? RAILS_GEM_VERSION - RAILS_GEM_VERSION - elsif ENV.include?('RAILS_GEM_VERSION') - ENV['RAILS_GEM_VERSION'] - else - parse_gem_version(read_environment_rb) - end - end - - def load_rubygems - require 'rubygems' - min_version = '1.1.1' - unless rubygems_version >= min_version - $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) - exit 1 - end - - rescue LoadError - $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) - exit 1 - end - - def parse_gem_version(text) - $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ - end - - private - def read_environment_rb - File.read("#{RAILS_ROOT}/config/environment.rb") - end - end - end -end - -# All that for this: -Rails.boot! diff --git a/vendor/plugins/acts_as_ferret/doc/demo/config/database.yml b/vendor/plugins/acts_as_ferret/doc/demo/config/database.yml deleted file mode 100644 index 1b130479..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/config/database.yml +++ /dev/null @@ -1,38 +0,0 @@ -# MySQL (default setup). Versions 4.1 and 5.0 are recommended. -# -# Get the fast C bindings: -# gem install mysql -# (on OS X: gem install mysql -- --include=/usr/local/lib) -# And be sure to use new-style password hashing: -# http://dev.mysql.com/doc/refman/5.0/en/old-client.html -# -# mysql config -development: - adapter: mysql - database: aaf_dev - username: ferret - password: ferret - -test: - adapter: mysql - database: aaf_test - username: ferret - password: ferret - -# since this is a demo, we won't need this one -#production: -# adapter: mysql -# database: ferret_production -# username: root -# password: -# socket: /var/run/mysqld/mysqld.sock - -# SQLITE -#development: -# adapter: sqlite3 -# dbfile: db/dev.sqlite - -#test: -# adapter: sqlite3 -# dbfile: db/test.sqlite - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/config/environment.rb b/vendor/plugins/acts_as_ferret/doc/demo/config/environment.rb deleted file mode 100644 index 5d417db2..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/config/environment.rb +++ /dev/null @@ -1,69 +0,0 @@ -# Be sure to restart your web server when you modify this file. - -# Uncomment below to force Rails into production mode when -# you don't control web/app server and can't set it the proper way -# ENV['RAILS_ENV'] ||= 'production' - -# Bootstrap the Rails environment, frameworks, and default configuration -require File.join(File.dirname(__FILE__), 'boot') - -Rails::Initializer.run do |config| - # Settings in config/environments/* take precedence those specified here - - config.action_controller.session = { :session_key => "_demo_session", :secret => "aaaaaaaaaaaaaaaabbbbbbbbbbbbbbccccccccccccccsome secret phrase" } - - # Skip frameworks you're not going to use - # config.frameworks -= [ :action_web_service, :action_mailer ] - - # Add additional load paths for your own custom dirs - # config.load_paths += %W( #{RAILS_ROOT}/extras ) - - # Force all environments to use the same logger level - # (by default production uses :info, the others :debug) - # config.log_level = :debug - - # Use the database for sessions instead of the file system - # (create the session table with 'rake create_sessions_table') - # config.action_controller.session_store = :active_record_store - - # Enable page/fragment caching by setting a file-based store - # (remember to create the caching directory and make it readable to the application) - # config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache" - - # Activate observers that should always be running - # config.active_record.observers = :cacher, :garbage_collector - - # Make Active Record use UTC-base instead of local time - # config.active_record.default_timezone = :utc - - # Use Active Record's schema dumper instead of SQL when creating the test database - # (enables use of different database adapters for development and test environments) - # config.active_record.schema_format = :ruby - - # See Rails::Configuration for more options -end - -# Add new inflection rules using the following format -# (all these examples are active by default): -# Inflector.inflections do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' -# inflect.uncountable %w( fish sheep ) -# end - -# Include your application configuration below - -ActsAsFerret::remote = false if ENV['AAF_REMOTE'] != 'true' -ActsAsFerret::raise_drb_errors = ENV['RAISE_DRB_ERRORS'] == 'true' - -# define the index shared by the SharedIndex1 and SharedIndex2 classes -ActsAsFerret::define_index 'shared', :remote => ENV['AAF_REMOTE'] == 'true', - :raise_drb_errors => ENV['RAISE_DRB_ERRORS'] == 'true', - :fields => { - :name => { :store => :yes } - }, - :ferret => { - :default_field => [ :name ] - } - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/config/environments/development.rb b/vendor/plugins/acts_as_ferret/doc/demo/config/environments/development.rb deleted file mode 100644 index c816f03e..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/config/environments/development.rb +++ /dev/null @@ -1,16 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# In the development environment your application's code is reloaded on -# every request. This slows down response time but is perfect for development -# since you don't have to restart the webserver when you make code changes. -config.cache_classes = false - -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true - -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_controller.perform_caching = false - -# Don't care if the mailer can't send -config.action_mailer.raise_delivery_errors = false diff --git a/vendor/plugins/acts_as_ferret/doc/demo/config/environments/production.rb b/vendor/plugins/acts_as_ferret/doc/demo/config/environments/production.rb deleted file mode 100644 index c9a4396c..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/config/environments/production.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# The production environment is meant for finished, "live" apps. -# Code is not reloaded between requests -config.cache_classes = true - -# Use a different logger for distributed setups -# config.logger = SyslogLogger.new - - -# Full error reports are disabled and caching is turned on -config.action_controller.consider_all_requests_local = false -config.action_controller.perform_caching = true - -# Enable serving of images, stylesheets, and javascripts from an asset server -# config.action_controller.asset_host = "http://assets.example.com" - -# Disable delivery errors if you bad email addresses should just be ignored -# config.action_mailer.raise_delivery_errors = false diff --git a/vendor/plugins/acts_as_ferret/doc/demo/config/environments/test.rb b/vendor/plugins/acts_as_ferret/doc/demo/config/environments/test.rb deleted file mode 100644 index 545d371e..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/config/environments/test.rb +++ /dev/null @@ -1,21 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! -config.cache_classes = true - -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true - -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_controller.perform_caching = false - -# Tell ActionMailer not to deliver emails to the real world. -# The :test delivery method accumulates sent emails in the -# ActionMailer::Base.deliveries array. -config.action_mailer.delivery_method = :test - -#config.log_level = :info diff --git a/vendor/plugins/acts_as_ferret/doc/demo/config/ferret_server.yml b/vendor/plugins/acts_as_ferret/doc/demo/config/ferret_server.yml deleted file mode 100644 index 18ddb022..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/config/ferret_server.yml +++ /dev/null @@ -1,18 +0,0 @@ -production: - host: ferret.yourdomain.com - port: 9010 - pid_file: log/ferret.pid -development: - host: localhost - port: 9010 - pid_file: log/ferret.pid - log_file: log/ferret_server_dev.log - log_level: info -test: - socket: /tmp/ferret.sock -# host: localhost -# port: 9009 - pid_file: log/ferret.pid - log_file: log/ferret_server_test.log - log_level: debug - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/config/lighttpd.conf b/vendor/plugins/acts_as_ferret/doc/demo/config/lighttpd.conf deleted file mode 100644 index 20cb11d0..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/config/lighttpd.conf +++ /dev/null @@ -1,40 +0,0 @@ -# Default configuration file for the lighttpd web server -# Start using ./script/server lighttpd - -server.port = 3001 - -server.modules = ( "mod_rewrite", "mod_accesslog", "mod_fastcgi" ) -server.error-handler-404 = "/dispatch.fcgi" -server.document-root = CWD + "/public/" - -server.errorlog = CWD + "/log/lighttpd.error.log" -accesslog.filename = CWD + "/log/lighttpd.access.log" - -url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" ) - -# Change *-procs to 2 if you need to use Upload Progress or other tasks that -# *need* to execute a second request while the first is still pending. -fastcgi.server = ( ".fcgi" => - ( "localhost" => - ( - "min-procs" => 1, - "max-procs" => 1, - "socket" => CWD + "/tmp/sockets/fcgi.socket", - "bin-path" => CWD + "/public/dispatch.fcgi", - "bin-environment" => ( "RAILS_ENV" => "development" ) - ) - ) -) - -mimetype.assign = ( - ".css" => "text/css", - ".gif" => "image/gif", - ".htm" => "text/html", - ".html" => "text/html", - ".jpeg" => "image/jpeg", - ".jpg" => "image/jpeg", - ".js" => "text/javascript", - ".png" => "image/png", - ".swf" => "application/x-shockwave-flash", - ".txt" => "text/plain" -) diff --git a/vendor/plugins/acts_as_ferret/doc/demo/config/routes.rb b/vendor/plugins/acts_as_ferret/doc/demo/config/routes.rb deleted file mode 100644 index c01e4631..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/config/routes.rb +++ /dev/null @@ -1,9 +0,0 @@ -ActionController::Routing::Routes.draw do |map| - - map.resources :contents - map.search 'search', :controller => 'searches', :action => 'search' - - - # Install the default route as the lowest priority. - map.connect ':controller/:action/:id' -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/db/development_structure.sql b/vendor/plugins/acts_as_ferret/doc/demo/db/development_structure.sql deleted file mode 100644 index ff1b4bae..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/db/development_structure.sql +++ /dev/null @@ -1,15 +0,0 @@ -CREATE TABLE `comments` ( - `id` int(11) NOT NULL auto_increment, - `author` varchar(100) NOT NULL default '', - `content` text NOT NULL, - `content_id` int(11) default NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -CREATE TABLE `contents` ( - `id` int(11) NOT NULL auto_increment, - `title` varchar(100) NOT NULL default '', - `description` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/001_initial_migration.rb b/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/001_initial_migration.rb deleted file mode 100644 index c477e90f..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/001_initial_migration.rb +++ /dev/null @@ -1,18 +0,0 @@ -class InitialMigration < ActiveRecord::Migration - def self.up - create_table "comments" do |t| - t.column "author", :string, :limit => 100 - t.column "content", :text - t.column "content_id", :integer - end - create_table "contents" do |t| - t.column "title", :string, :limit => 100 - t.column "description", :text - end - end - - def self.down - drop_table "comments" - drop_table "contents" - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/002_add_type_to_contents.rb b/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/002_add_type_to_contents.rb deleted file mode 100644 index d2fb94a7..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/002_add_type_to_contents.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddTypeToContents < ActiveRecord::Migration - def self.up - add_column :contents, :type, :string - end - - def self.down - remove_column :contents, :type - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/003_create_shared_index1s.rb b/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/003_create_shared_index1s.rb deleted file mode 100644 index 200e1acd..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/003_create_shared_index1s.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateSharedIndex1s < ActiveRecord::Migration - def self.up - create_table :shared_index1s do |t| - t.column :name, :string - end - end - - def self.down - drop_table :shared_index1s - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/004_create_shared_index2s.rb b/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/004_create_shared_index2s.rb deleted file mode 100644 index 394885af..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/004_create_shared_index2s.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateSharedIndex2s < ActiveRecord::Migration - def self.up - create_table :shared_index2s do |t| - t.column :name, :string - end - end - - def self.down - drop_table :shared_index2s - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/005_special_field.rb b/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/005_special_field.rb deleted file mode 100644 index 137061fd..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/005_special_field.rb +++ /dev/null @@ -1,9 +0,0 @@ -class SpecialField < ActiveRecord::Migration - def self.up - add_column :contents, :special, :string - end - - def self.down - remove_column :contents, :special - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/006_create_stats.rb b/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/006_create_stats.rb deleted file mode 100644 index 0302837f..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/db/migrate/006_create_stats.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateStats < ActiveRecord::Migration - def self.up - create_table :stats do |t| - t.integer :process_id, :processing_time, :open_connections - t.string :kind, :info - t.datetime :created_at - end - add_index :stats, 'kind' - end - - def self.down - # remove_index :stats, 'kind' - drop_table :stats - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/db/schema.sql b/vendor/plugins/acts_as_ferret/doc/demo/db/schema.sql deleted file mode 100644 index 3c178c8a..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/db/schema.sql +++ /dev/null @@ -1,18 +0,0 @@ -drop table if exists contents; -create table contents ( - id int not null auto_increment, - type varchar(255) not null, - title varchar(100) not null, - description text not null, - special varchar(255) not null, - primary key (id) -) TYPE=InnoDB DEFAULT CHARSET=utf8; - -drop table if exists comments; -create table comments ( - id int not null auto_increment, - author varchar(100) not null, - content text not null, - content_id int, - primary key (id) -) TYPE=InnoDB DEFAULT CHARSET=utf8; diff --git a/vendor/plugins/acts_as_ferret/doc/demo/db/schema.sqlite b/vendor/plugins/acts_as_ferret/doc/demo/db/schema.sqlite deleted file mode 100644 index 8abdbb7b..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/db/schema.sqlite +++ /dev/null @@ -1,14 +0,0 @@ -drop table contents; -create table contents ( - id INTEGER PRIMARY KEY, - title varchar(100), - description text -); - -drop table comments; -create table comments ( - id INTEGER PRIMARY KEY, - author varchar(100), - content text, - content_id int -); diff --git a/vendor/plugins/acts_as_ferret/doc/demo/doc/README_FOR_APP b/vendor/plugins/acts_as_ferret/doc/demo/doc/README_FOR_APP deleted file mode 100644 index ac6c1491..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/doc/README_FOR_APP +++ /dev/null @@ -1,2 +0,0 @@ -Use this README file to introduce your application and point to useful places in the API for learning more. -Run "rake appdoc" to generate API documentation for your models and controllers. \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/doc/howto.txt b/vendor/plugins/acts_as_ferret/doc/demo/doc/howto.txt deleted file mode 100644 index 49332554..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/doc/howto.txt +++ /dev/null @@ -1,70 +0,0 @@ -This is a very minimalistic example of using ferret -to do full text searches in Rails model data. Tested with - Ruby 1.8.3, Rails 1.0 and Ferret 0.3.2. - -You can install the latter with - gem install ferret - - -The steps it took me to create this small demo project were: - -Rails project setup -=================== -These steps are pretty common and have nothing to do with ferret. - -Create rails project - rails ferret - cd ferret - -Create databases (if you don't use unix and/or sudo, use 'mysql -u root -p') - sudo mysql - - create database ferret_development; - create database ferret_test; - grant all on ferret_development.* to 'ferret'@'localhost' identified by 'ferret'; - grant all on ferret_test.* to 'ferret'@'localhost' identified by 'ferret'; - -Create database schema - mysql -u ferret -pferret ferret_development < db/schema.sql - -Edit config/database.yml (user names and passwords) - -Create content controller and model -script/generate scaffold Content - -Running rake at this point should yield no errors. -Otherwise check your database configuration. - - -Ferret integration -================== -Put acs_as_ferret plugin into vendor/plugin - -Add ferret to the content model class: - acts_as_ferret :fields => [ 'title', 'description' ] - -Add unit tests for the find_by_contents method to content_test.rb. - -running rake should succeed, and there should be an index in -RAILS_ROOT/index/test/Content. - -Extend the ContentController with a search method and create the search view -Add unit tests for the search method to content_controller_test.rb -Run rake again to see the tests pass. -Remember that, as a good programmer, you would've written the tests first, -before implementing the feature ;-) - - -Try it out -========== -Run the app with script/server and create some content objects. You should -see the index in RAILS_ROOT/index/development/Content. - -Try searching at http://localhost:3000/content/search - - -Please contact me if you find any bugs/problems within this howto or -in the code. - -Jens Kraemer -Feel free to use under the terms of the MIT license. diff --git a/vendor/plugins/acts_as_ferret/doc/demo/public/.htaccess b/vendor/plugins/acts_as_ferret/doc/demo/public/.htaccess deleted file mode 100644 index d3c99834..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/public/.htaccess +++ /dev/null @@ -1,40 +0,0 @@ -# General Apache options -AddHandler fastcgi-script .fcgi -AddHandler cgi-script .cgi -Options +FollowSymLinks +ExecCGI - -# If you don't want Rails to look in certain directories, -# use the following rewrite rules so that Apache won't rewrite certain requests -# -# Example: -# RewriteCond %{REQUEST_URI} ^/notrails.* -# RewriteRule .* - [L] - -# Redirect all requests not available on the filesystem to Rails -# By default the cgi dispatcher is used which is very slow -# -# For better performance replace the dispatcher with the fastcgi one -# -# Example: -# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] -RewriteEngine On - -# If your Rails application is accessed via an Alias directive, -# then you MUST also set the RewriteBase in this htaccess file. -# -# Example: -# Alias /myrailsapp /path/to/myrailsapp/public -# RewriteBase /myrailsapp - -RewriteRule ^$ index.html [QSA] -RewriteRule ^([^.]+)$ $1.html [QSA] -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.*)$ dispatch.cgi [QSA,L] - -# In case Rails experiences terminal errors -# Instead of displaying this message you can supply a file here which will be rendered instead -# -# Example: -# ErrorDocument 500 /500.html - -ErrorDocument 500 "

    Application error

    Rails application failed to start properly" \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/public/404.html b/vendor/plugins/acts_as_ferret/doc/demo/public/404.html deleted file mode 100644 index 0e184561..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/public/404.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -

    File not found

    -

    Change this error message for pages not found in public/404.html

    - - \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/public/500.html b/vendor/plugins/acts_as_ferret/doc/demo/public/500.html deleted file mode 100644 index a1001a00..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/public/500.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -

    Application error (Apache)

    -

    Change this error message for exceptions thrown outside of an action (like in Dispatcher setups or broken Ruby code) in public/500.html

    - - \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.cgi b/vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.cgi deleted file mode 100755 index 3848806d..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.cgi +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/ruby1.8 - -require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) - -# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: -# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired -require "dispatcher" - -ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) -Dispatcher.dispatch \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.fcgi b/vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.fcgi deleted file mode 100755 index 3169ba26..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.fcgi +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/ruby1.8 -# -# You may specify the path to the FastCGI crash log (a log of unhandled -# exceptions which forced the FastCGI instance to exit, great for debugging) -# and the number of requests to process before running garbage collection. -# -# By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log -# and the GC period is nil (turned off). A reasonable number of requests -# could range from 10-100 depending on the memory footprint of your app. -# -# Example: -# # Default log path, normal GC behavior. -# RailsFCGIHandler.process! -# -# # Default log path, 50 requests between GC. -# RailsFCGIHandler.process! nil, 50 -# -# # Custom log path, normal GC behavior. -# RailsFCGIHandler.process! '/var/log/myapp_fcgi_crash.log' -# -require File.dirname(__FILE__) + "/../config/environment" -require 'fcgi_handler' - -RailsFCGIHandler.process! diff --git a/vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.rb b/vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.rb deleted file mode 100755 index 3848806d..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/public/dispatch.rb +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/ruby1.8 - -require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) - -# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: -# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired -require "dispatcher" - -ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun) -Dispatcher.dispatch \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/public/favicon.ico b/vendor/plugins/acts_as_ferret/doc/demo/public/favicon.ico deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/plugins/acts_as_ferret/doc/demo/public/images/rails.png b/vendor/plugins/acts_as_ferret/doc/demo/public/images/rails.png deleted file mode 100644 index b8441f182e06974083cf08f0acaf0e2fd612bd40..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1787 zcmVCLdthj)A!BBmWB&y|X`RY;f`BJ<_ju%@N||NoLFD~mQl$aHGjq>;5dG_D{h(5s}0 z6&=HANU$m__3PuddU(lvR_xWj`}Oho@9EyQt-n!E*P(KhM@X_VFV2l&>deNZJT%y8iwA zoG>u1B`p2=_u9k4v1Mud`1+qvOZoHg#bITJ9U`qBAek?40RR96!AV3xRCwBy*IQ$v zN(=yC9IhRft9V64L`77pqF_Cx@c;kSNoGK)`?Ps*cP(EtGlYZ{D5cxspMQvjKH)Oh6X(pa|J{ zGy1J$Ej7=Z{uvmMfRRsE;v`p;45B~6*ep#hM^ji zl$+7qoWq~}ewG=61uFw0He{tJurMU&4Iv?=B^eR(wAHk!miA)O7p_+YR>lbmU3rmn ze?+ze(+sEd6foB&*l9+?zkr_a-5*v&p*?c}HOGtyHg6r{WFYpQ=#z0Hc7VWLx$>M3|b0|Gn z+5t#z6*ffSVc6DjpmB2?AAR@@vB!wCK?9Yl;33;Q7^%(401QW|k=R8b!OwtLJPjjm zO9Ia;qCq)rOq!1Ia*6#A%#xb}yDx1P*pWla>9j$bnMn3CBqe4`TRll_Iy29kmG?4fbKuF=XqU|?3b@B zA`&a?KIgZ|KJx5eND_c3Em=WZn@xW8hRJ^G&sY^b(FW?WC9W_sb;+lAPdLTdBaKIK;-f}*h4|1aTjw7qX_k~e{TWO7jqcekERN;Jyh%67)q4rKpL*CEYL;|#GY{B@5 zi52XoC?xsoorJKxsliugF#z38MJqrYCWV(t<=G&f;^Me13&AiI9{3jUZ$ zFM`*L(9qc^VMxkz1oaDH!1pcD^IXp>Z0Jb=_qs?Vsrs{mp<^{$N!EC9o+`CO-(o}E zJ`y{*;9s|wr22-QoJ87y^~;)Q@b%P4UgSSsx>2$o@Vd{%Pk0@4qZ^fhB(vt$c1TG> z*{Ad;foraENbld`=MCNm4?9kvlgK~&J>ialpJ7nua zx0oRzwG5;}Qne)Fg(N3kf?JVmB;}y&5(0+~r*aL$0Zof8fe!AtHWH>A^1Y)@G@GsA zup`R{Qg?{+MaxTq#2n{6w|)c&yaJ7{U4ngAH5v6I)*;@rEBE*ehIPBwKBQU)YKE8F0lR!Sm?sE4Xk-sj&E$|A-9n dP56HS1^^A-61FoN)nxzx002ovPDHLkV1kw_Sd9Px diff --git a/vendor/plugins/acts_as_ferret/doc/demo/public/index.html b/vendor/plugins/acts_as_ferret/doc/demo/public/index.html deleted file mode 100644 index 1f5e62bb..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/public/index.html +++ /dev/null @@ -1,277 +0,0 @@ - - - - - Ruby on Rails: Welcome aboard - - - - - - -
    - - -
    - - - - -
    -

    Getting started

    -

    Here’s how to get rolling:

    - -
      -
    1. -

      Create your databases and edit config/database.yml

      -

      Rails needs to know your login and password.

      -
    2. - -
    3. -

      Use script/generate to create your models and controllers

      -

      To see all available options, run it without parameters.

      -
    4. - -
    5. -

      Set up a default route and remove or rename this file

      -

      Routes are setup in config/routes.rb.

      -
    6. -
    -
    -
    - - -
    - - \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/public/robots.txt b/vendor/plugins/acts_as_ferret/doc/demo/public/robots.txt deleted file mode 100644 index 4ab9e89f..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/public/robots.txt +++ /dev/null @@ -1 +0,0 @@ -# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/public/stylesheets/scaffold.css b/vendor/plugins/acts_as_ferret/doc/demo/public/stylesheets/scaffold.css deleted file mode 100644 index de2ccc57..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/public/stylesheets/scaffold.css +++ /dev/null @@ -1,74 +0,0 @@ -body { background-color: #fff; color: #333; } - -body, p, ol, ul, td { - font-family: verdana, arial, helvetica, sans-serif; - font-size: 13px; - line-height: 18px; -} - -pre { - background-color: #eee; - padding: 10px; - font-size: 11px; -} - -a { color: #000; } -a:visited { color: #666; } -a:hover { color: #fff; background-color:#000; } - -.fieldWithErrors { - padding: 2px; - background-color: red; - display: table; -} - -#ErrorExplanation { - width: 400px; - border: 2px solid red; - padding: 7px; - padding-bottom: 12px; - margin-bottom: 20px; - background-color: #f0f0f0; -} - -#ErrorExplanation h2 { - text-align: left; - font-weight: bold; - padding: 5px 5px 5px 15px; - font-size: 12px; - margin: -7px; - background-color: #c00; - color: #fff; -} - -#ErrorExplanation p { - color: #333; - margin-bottom: 0; - padding: 5px; -} - -#ErrorExplanation ul li { - font-size: 12px; - list-style: square; -} - -div.uploadStatus { - margin: 5px; -} - -div.progressBar { - margin: 5px; -} - -div.progressBar div.border { - background-color: #fff; - border: 1px solid grey; - width: 100%; -} - -div.progressBar div.background { - background-color: #333; - height: 18px; - width: 0%; -} - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/about b/vendor/plugins/acts_as_ferret/doc/demo/script/about deleted file mode 100755 index 7b07d46a..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/about +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/about' \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/breakpointer b/vendor/plugins/acts_as_ferret/doc/demo/script/breakpointer deleted file mode 100755 index 64af76ed..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/breakpointer +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/breakpointer' \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/console b/vendor/plugins/acts_as_ferret/doc/demo/script/console deleted file mode 100755 index 42f28f7d..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/console +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/console' \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/destroy b/vendor/plugins/acts_as_ferret/doc/demo/script/destroy deleted file mode 100755 index fa0e6fcd..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/destroy +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/destroy' \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/ferret_server b/vendor/plugins/acts_as_ferret/doc/demo/script/ferret_server deleted file mode 100755 index f5dbf3a5..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/ferret_server +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby - -begin - require File.join(File.dirname(__FILE__), '../vendor/plugins/acts_as_ferret/lib/server_manager') -rescue LoadError - # try the gem - require 'rubygems' - gem 'acts_as_ferret' - require 'server_manager' -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/generate b/vendor/plugins/acts_as_ferret/doc/demo/script/generate deleted file mode 100755 index ef976e09..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/generate +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/generate' \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/performance/benchmarker b/vendor/plugins/acts_as_ferret/doc/demo/script/performance/benchmarker deleted file mode 100755 index c842d35d..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/performance/benchmarker +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/performance/benchmarker' diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/performance/profiler b/vendor/plugins/acts_as_ferret/doc/demo/script/performance/profiler deleted file mode 100755 index d855ac8b..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/performance/profiler +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/performance/profiler' diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/plugin b/vendor/plugins/acts_as_ferret/doc/demo/script/plugin deleted file mode 100755 index 26ca64c0..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/plugin +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/plugin' \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/process/inspector b/vendor/plugins/acts_as_ferret/doc/demo/script/process/inspector deleted file mode 100755 index bf25ad86..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/process/inspector +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/process/inspector' diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/process/reaper b/vendor/plugins/acts_as_ferret/doc/demo/script/process/reaper deleted file mode 100755 index c77f0453..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/process/reaper +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/process/reaper' diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/process/spawner b/vendor/plugins/acts_as_ferret/doc/demo/script/process/spawner deleted file mode 100755 index 7118f398..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/process/spawner +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/process/spawner' diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/process/spinner b/vendor/plugins/acts_as_ferret/doc/demo/script/process/spinner deleted file mode 100755 index 6816b32e..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/process/spinner +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../config/boot' -require 'commands/process/spinner' diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/runner b/vendor/plugins/acts_as_ferret/doc/demo/script/runner deleted file mode 100755 index ccc30f9d..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/runner +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/runner' \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/script/server b/vendor/plugins/acts_as_ferret/doc/demo/script/server deleted file mode 100755 index dfabcb88..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/script/server +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../config/boot' -require 'commands/server' \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/comments.yml b/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/comments.yml deleted file mode 100644 index c238e0ce..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/comments.yml +++ /dev/null @@ -1,12 +0,0 @@ -first: - id: 1 - content: comment from fixture - content_id: 1 -another: - id: 2 - content: second comment from fixture - content_id: 1 -comment_for_c2: - id: 3 - content: regarding content 2 - content_id: 2 diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/contents.yml b/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/contents.yml deleted file mode 100644 index 817cc496..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/contents.yml +++ /dev/null @@ -1,13 +0,0 @@ -first: - id: 1 - title: My Title - description: A useless description - type: Content -another: - id: 2 - type: Content -special: - id: 3 - title: single table inheritance - special: special field - type: SpecialContent diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/remote_contents.yml b/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/remote_contents.yml deleted file mode 100644 index 769217a6..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/remote_contents.yml +++ /dev/null @@ -1,9 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -first: - id: 1 - title: title of item one - content: content of item one -another: - id: 2 - title: title of item two - content: content of item two diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/shared_index1s.yml b/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/shared_index1s.yml deleted file mode 100644 index a2b119ad..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/shared_index1s.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -first: - id: 1 - name: first one -another: - id: 2 - name: another one diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/shared_index2s.yml b/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/shared_index2s.yml deleted file mode 100644 index 24493833..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/fixtures/shared_index2s.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html -first: - id: 1 - name: first two -another: - id: 2 - name: another two diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/functional/admin/backend_controller_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/functional/admin/backend_controller_test.rb deleted file mode 100644 index d4c21d97..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/functional/admin/backend_controller_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -require File.dirname(__FILE__) + '/../../test_helper' -require 'admin/backend_controller' - -# Re-raise errors caught by the controller. -class Admin::BackendController; def rescue_action(e) raise e end; end - -class Admin::BackendControllerTest < Test::Unit::TestCase - def setup - @controller = Admin::BackendController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - Content.destroy_all - Content.create(:title => 'my title', :description => 'a little bit of content') - end - - def teardown - Content.destroy_all - end - - def test_search - get :search - assert_response :success - assert_template 'search' - assert_nil assigns(:results) - - post :search, :query => 'title' - assert_template 'search' - assert_equal 1, assigns(:results).size - - post :search, :query => 'monkey' - assert_template 'search' - assert assigns(:results).empty? - - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/functional/contents_controller_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/functional/contents_controller_test.rb deleted file mode 100644 index 812d04ea..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/functional/contents_controller_test.rb +++ /dev/null @@ -1,81 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'contents_controller' - -# Re-raise errors caught by the controller. -class ContentsController; def rescue_action(e) raise e end; end - -class ContentsControllerTest < Test::Unit::TestCase - fixtures :contents - - def setup - @controller = ContentsController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - def test_index - get :index - assert_response :success - assert_template 'index' - assert_not_nil assigns(:contents) - end - - def test_show - get :show, :id => 1 - - assert_response :success - assert_template 'show' - - assert_not_nil assigns(:content) - assert assigns(:content).valid? - end - - def test_new - get :new - - assert_response :success - assert_template 'new' - - assert_not_nil assigns(:content) - end - - def test_create - num_contents = Content.count - - post :create, :content => {} - - assert_response :redirect - assert_redirected_to contents_url - - assert_equal num_contents + 1, Content.count - end - - def test_edit - get :edit, :id => 1 - - assert_response :success - assert_template 'edit' - - assert_not_nil assigns(:content) - assert assigns(:content).valid? - end - - def test_update - post :update, :id => 1 - assert_response :redirect - assert_redirected_to :action => 'show', :id => 1 - end - - def test_destroy - assert_not_nil Content.find(1) - - post :destroy, :id => 1 - assert_response :redirect - assert_redirected_to :action => 'list' - - assert_raise(ActiveRecord::RecordNotFound) { - Content.find(1) - } - end - -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/functional/searches_controller_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/functional/searches_controller_test.rb deleted file mode 100644 index b17962e9..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/functional/searches_controller_test.rb +++ /dev/null @@ -1,71 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'searches_controller' - -# Re-raise errors caught by the controller. -class SearchesController; def rescue_action(e) raise e end; end - -class SearchesControllerTest < Test::Unit::TestCase - fixtures :contents - - def setup - @controller = SearchesController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - ContentBase.rebuild_index - end - - def test_search - get :search - assert_template 'search' - assert_response :success - assert_nil assigns(:results) - end - - def test_search - get :search, :q => 'title' - assert_template 'search' - assert_equal 1, assigns(:results).total_hits - assert_equal 1, assigns(:results).size - - get :search, :q => 'monkey' - assert_template 'search' - assert assigns(:results).empty? - - # check that model changes are picked up by the searcher (searchers have to - # be reopened to reflect changes done to the index) - # wait for the searcher to age a bit (it seems fs timestamp resolution is - # only 1 sec) - sleep 1 - Content.create :title => 'another content object', :description => 'description goes hers' - get :search, :q => 'another' - assert_template 'search' - assert_equal 1, assigns(:results).total_hits - assert_equal 1, assigns(:results).size - - end - - def test_pagination - Content.destroy_all - 30.times do |i| - Content.create! :title => "title of Content #{i}", :description => "#{i}" - end - get :search, :q => 'title' - r = assigns(:results) - assert_equal 30, r.total_hits - assert_equal 10, r.size - assert_equal "title of Content 0", r.first.title - assert_equal "title of Content 9", r.last.title - assert_equal 1, r.current_page - assert_equal 3, r.page_count - - get :search, :q => 'title', :page => 2 - r = assigns(:results) - assert_equal 30, r.total_hits - assert_equal 10, r.size - assert_equal "title of Content 10", r.first.title - assert_equal "title of Content 19", r.last.title - assert_equal 2, r.current_page - assert_equal 3, r.page_count - end - -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/smoke/drb_smoke_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/smoke/drb_smoke_test.rb deleted file mode 100644 index 60ae7d8d..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/smoke/drb_smoke_test.rb +++ /dev/null @@ -1,321 +0,0 @@ -require 'rubygems' -require 'benchmark' -require 'gruff' - -# Simple smoke test for the DRb server -# usage: -# -# # start the DRb server -# script/ferret_server -e test start -# -# # run the script -# AAF_REMOTE=true script/runner -e test test/smoke/drb_smoke_test.rb - -module DrbSmokeTest - - RECORDS_PER_PROCESS = 100000 - NUM_PROCESSES = 10 # should be an even number - NUM_DOCS = 50 - NUM_TERMS = 600 - START_TIME = Time.now - - class Words - DICTIONARY = '/usr/share/dict/words' - def initialize - @words = [] - File.open(DICTIONARY) do |file| - file.each_line do |word| - @words << word.strip unless word =~ /'/ - end - end - end - - def to_s - "#{@words.size} words" - end - - def random_word - @words[rand(@words.size)] - end - end - - puts "compiling sample documents..." - WORDS = Words.new - puts WORDS - DOCUMENTS = [] - - NUM_DOCS.times do - doc = '' - NUM_TERMS.times { doc << WORDS.random_word << ' ' } - DOCUMENTS << doc - end - - def self.random_document - DOCUMENTS[rand(DOCUMENTS.size)] - end - - puts "built #{NUM_DOCS} documents with an avg. size of #{DOCUMENTS.join.size / NUM_DOCS} Bytes." - - class Monitor - class << self - def count_connections - res = Content.connection.execute("show status where variable_name = 'Threads_connected'") - if res - res.fetch_row.last - else - "error getting connection count" - end - end - def writers_running? - Dir['*.finished'].size < (NUM_PROCESSES/2) - end - def running? - Dir['*.finished'].size < NUM_PROCESSES - end - end - end - - class WorkerBase - def initialize(id) - @id = id - end - - # time since startup in msec - def get_time - ((Time.now - START_TIME)*1000).to_i - end - - def log(data) - data << get_time - @logfile << data.join(',') << "\n" - end - - def log_finished - File.open("#{@id}.finished", 'w') do |f| - f << "finished at #{Time.now}\n" - end - end - - def clear_logs - FileUtils.rm_f "#{@id}.*" - end - - def run - File.open("#{self.class.prefix}_#{@id}.log",'w') do |f| - clear_logs - sleep 1 # allow other processes to get ready - @logfile = f - do_run - log_finished - puts "#{@id} finished" - end - end - - end - - class Writer < WorkerBase - def self.prefix; 'writer' end - def do_run - log_interval = RECORDS_PER_PROCESS / 100 - RECORDS_PER_PROCESS.times do |i| - log create_record(i) - if i % log_interval == 0 - # log progress - puts "#{@id}: #{i} records indexed" - end - end - end - - def create_record(i) - time = Benchmark.realtime do - Content.create! :title => "record #{@id} / #{i}", :description => DrbSmokeTest::random_document - end - [ time ] - end - end - - class Searcher < WorkerBase - def self.prefix; 'searcher' end - def do_run - while Monitor::writers_running? - # search with concurrent writes - log do_search - end - t = Time.now - while (Time.now - t) < 2.minutes - # the writers have finished, now hammer the server with searches for another 5 minutes - log do_search - end - end - - # run a search and log it's results. - # Search is done with a query consisting of the term 'findme' - # (which is guaranteed to yield 20 results) and a random term from - # the word list, ORed together - def do_search - result = nil - query = "findme OR #{WORDS.random_word}" - time = Benchmark.realtime do - result = Content.find_id_by_contents query - end - # time, no of hits - [ time, result.first, query ] - end - end - - def self.run - @start = Time.now - - NUM_PROCESSES.times do |i| - unless fork - @id = i - break - end - end - - if @id - @id.even? ? Writer.new(@id).run : Searcher.new(@id).run - else - - # create some records to search for - 20.times do |i| - Content.create! :title => "to find #{i}", :description => ("findme #{i} " << random_document) - end - - while Monitor::running? - puts "open connections: #{Monitor::count_connections}; time elapsed: #{Time.now - @start} seconds" - sleep 10 - end - puts "doing the math now..." - DrbSmokeTest::Stats.new(DrbSmokeTest::Writer::prefix).run - DrbSmokeTest::Stats.new(DrbSmokeTest::Searcher::prefix).run - end - end - - module Statistics - def odd?(value) - value % 2 == 1 - end - - def median(population) - if odd?(population.size) - population[population.size/2] - else - mean [ population[population.size/2-1], population[population.size/2] ] - end - end - - def mean(population) - sum = population.inject(0) { |sum, v| sum + v } - sum / population.size.to_f - end - - # variance and standard_deviation methods from - # http://warrenseen.com/blog/2006/03/13/how-to-calculate-standard-deviation/ - def variance(population) - n = 0 - mean = 0.0 - s = 0.0 - population.each { |x| - n = n + 1 - delta = x - mean - mean = mean + (delta / n) - s = s + delta * (x - mean) - } - # if you want to calculate std deviation - # of a sample change this to "s / (n-1)" - return s / n - end - - # calculate the standard deviation of a population - # accepts: an array, the population - # returns: the standard deviation - def standard_deviation(population) - Math.sqrt(variance(population)) - rescue - puts "pop: #{population.inspect}" - end - end - - class Stats - include Statistics - - def initialize(prefix) - @prefix = prefix - @stats = [] - end - - def collect_stats - Dir["#{@prefix}_*.log"].each do |logfile| - puts logfile - File.open(logfile) do |f| - while line = f.gets - row = line.split(',') - row[row.size-1] = row.last.to_i - @stats << row - end - end - end - puts "#{@stats.size} lines read, now sorting..." - @stats.sort! { |row1, row2| row1.last <=> row2.last } - end - - def with_segments(segment_count) - t0 = @stats.first.last.to_i - t1 = @stats.last.last.to_i - timespan = t1 - t0 - puts "test run took: #{timespan/1000} seconds" - # we want to draw 1000 points, determine which timespan one point covers - segment_length = timespan / segment_count - t = 0 - i = 0 - while t <= t1 - t += segment_length - segment_stats = [] - while @stats.any? && @stats.first.last.to_i < t - segment_stats << @stats.shift - end - yield segment_stats unless segment_stats.empty? - end - end - - def run - collect_stats - segments = [] - with_segments(500) do |segment_stats| - segments << process_segment(segment_stats) - end - - chart("#{@prefix} mean", "#{@prefix.downcase}_mean") do |g| - g.data :mean, segments.map{ |row| row[0] } - g.data :stddev, segments.map{ |row| row[1] } - end - chart("#{@prefix} median", "#{@prefix.downcase}_median") do |g| - g.data :median, segments.map{ |row| row[2] } - end - end - - def process_segment(segment) - times = segment.map{|row|row.first.to_i * 1000} - [mean(times), standard_deviation(times), median(times), segment.size] - end - - def chart(title, fname) - g = Gruff::Line.new do |g| - g.title = title - g.theme = { - :background_colors => ["#e6e6e6", "#e6e6e6"], - :colors => ["#ff43a7", '#666666', 'black', 'white', 'grey'], - :marker_color => "white" - } - end - yield g - g.write "#{fname}.png" - end - end - -end - - -DrbSmokeTest::run - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/smoke/process_stats.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/smoke/process_stats.rb deleted file mode 100644 index eb95cbab..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/smoke/process_stats.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rubygems' -require 'gruff' - -search = Stats.compute :search -write = Stats.compute :write - - -g = chart "aaf DRb (write performance)" -g.data :avg, write.map{|r| r[:avg]} -g.data :stddev, write.map{|r| r[:stddev]} -g.write "write_averages.png" - -g = chart "aaf DRb (search performance)" -g.data :average, search.map{ |r| r[:avg] } -g.data :stddev, search.map{ |r| r[:stddev] } -g.write "search_averages.png" - -g = chart "aaf DRb (search performance (medians))" -g.data :search_median, search.map{ |r| r[:median] } -g.write "search_medians.png" - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/test_helper.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/test_helper.rb deleted file mode 100644 index b558e163..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/test_helper.rb +++ /dev/null @@ -1,30 +0,0 @@ -ENV["RAILS_ENV"] = "test" -require File.expand_path(File.dirname(__FILE__) + "/../config/environment") -require 'test_help' - -class Test::Unit::TestCase - # Transactional fixtures accelerate your tests by wrapping each test method - # in a transaction that's rolled back on completion. This ensures that the - # test database remains unchanged so your fixtures don't have to be reloaded - # between every test method. Fewer database queries means faster tests. - # - # Read Mike Clark's excellent walkthrough at - # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting - # - # Every Active Record database supports transactions except MyISAM tables - # in MySQL. Turn off transactional fixtures in this case; however, if you - # don't care one way or the other, switching from MyISAM to InnoDB tables - # is recommended. - #self.use_transactional_fixtures = true - self.use_transactional_fixtures = false - - # Instantiated fixtures are slow, but give you @david where otherwise you - # would need people(:david). If you don't want to migrate your existing - # test cases which use the @david style and don't mind the speed hit (each - # instantiated fixtures translates to a database query per test method), - # then set this back to true. - self.use_instantiated_fixtures = false - - # Add more helper methods to be used by all tests here... -end - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/comment_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/unit/comment_test.rb deleted file mode 100644 index 1f15bf29..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/comment_test.rb +++ /dev/null @@ -1,217 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class CommentTest < Test::Unit::TestCase - fixtures :comments - - def setup - Comment.rebuild_index - end - - # Replace this with your real tests. - def test_truth - assert_kind_of Comment, comments(:first) - end - - def test_issue_220_index_false_as_false - c = Comment.new :content => false - assert_equal false, c.content - assert_equal 'false', c.content_for_field_name(:content) - assert_equal 'false', c.to_doc[:content] - c.save - assert_equal c, Comment.find_with_ferret('content:false').first - end - - def test_if_option - c = Comment.new :content => 'do not index' - c.save - assert_equal 0, Comment.find_with_ferret('do not index').total_hits - end - - def test_analyzer - c = Comment.create! :content => 'a fax modem' - assert_equal 0, Comment.find_with_ferret('fax').size - assert_equal 1, Comment.find_with_ferret('modem').size - end - - def test_class_index_dir - assert Comment.aaf_configuration[:index_dir] =~ %r{^#{RAILS_ROOT}/index/test/comment} - end - - def test_aliased_field - res = Comment.find_with_ferret 'aliased:regarding' - assert_equal 1, res.total_hits - assert_equal comments(:comment_for_c2), res.first - end - - def test_search_for_id - # don't search the id field by default: - assert Comment.find_with_ferret('3').empty? - # explicit query for id field works: - assert_equal 3, Comment.find_with_ferret('id:3').first.id - end - - #def test_reloadable - # assert ! Comment.reloadable? - #end - - # tests the automatic building of an index when none exists - # delete index/test/* before running rake to make this useful - def test_automatic_index_build - # TODO: check why this fails, but querying for 'comment fixture' works. - # maybe different analyzers at index creation and searching time ? - #comments_from_ferret = Comment.find_with_ferret('"comment from fixture"') - comments_from_ferret = Comment.find_with_ferret('comment fixture') - assert_equal 2, comments_from_ferret.size - assert comments_from_ferret.include?(comments(:first)) - assert comments_from_ferret.include?(comments(:another)) - end - - def test_rebuild_index - Comment.aaf_index.ferret_index.query_delete('comment') - comments_from_ferret = Comment.find_with_ferret('comment AND fixture') - assert comments_from_ferret.empty? - Comment.rebuild_index - comments_from_ferret = Comment.find_with_ferret('comment AND fixture') - assert_equal 2, comments_from_ferret.size - end - - def test_total_hits - comments_from_ferret = Comment.find_with_ferret('comment AND fixture', :limit => 1) - assert_equal 1, comments_from_ferret.size - assert_equal 2, comments_from_ferret.total_hits - - comments_from_ferret = Comment.find_with_ferret('comment AND fixture', {}, :conditions => 'id != 1') - assert_equal 1, comments_from_ferret.size - assert_equal 1, comments_from_ferret.total_hits - end - - def test_score - comments_from_ferret = Comment.find_with_ferret('comment AND fixture', :limit => 1) - assert comments_from_ferret.first - assert comments_from_ferret.first.ferret_score > 0 - end - - def test_find_all - 20.times do |i| - Comment.create( :author => 'multi-commenter', :content => "This is multicomment no #{i}" ) - end - assert_equal 10, (res = Comment.find_with_ferret('multicomment')).size - assert_equal 20, res.total_hits - assert_equal 15, (res = Comment.find_with_ferret('multicomment', :limit => 15)).size - assert_equal 20, res.total_hits - assert_equal 20, (res = Comment.find_with_ferret('multicomment', :limit => :all)).size - assert_equal 20, res.total_hits - end - - # tests the custom to_doc method defined in comment.rb - def test_custom_to_doc - top_docs = Comment.aaf_index.ferret_index.search('"from fixture"') - #top_docs = Comment.ferret_index.search('"comment from fixture"') - assert_equal 2, top_docs.total_hits - doc = Comment.aaf_index.ferret_index.doc(top_docs.hits[0].doc) - # check for the special field added by the custom to_doc method - assert_not_nil doc[:added] - # still a valid int ? - assert doc[:added].to_i > 0 - end - - def test_find_with_ferret - comment = Comment.create( :author => 'john doe', :content => 'This is a useless comment' ) - comment2 = Comment.create( :author => 'another', :content => 'content' ) - - comments_from_ferret = Comment.find_with_ferret('anoth* OR jo*') - assert_equal 2, comments_from_ferret.size - assert comments_from_ferret.include?(comment) - assert comments_from_ferret.include?(comment2) - - # find options - comments_from_ferret = Comment.find_with_ferret('anoth* OR jo*', {}, :conditions => ["id=?",comment2.id]) - assert_equal 1, comments_from_ferret.size - assert comments_from_ferret.include?(comment2) - - comments_from_ferret = Comment.find_with_ferret('lorem ipsum not here') - assert comments_from_ferret.empty? - - comments_from_ferret = Comment.find_with_ferret('another') - assert_equal 1, comments_from_ferret.size - assert_equal comment2.id, comments_from_ferret.first.id - - comments_from_ferret = Comment.find_with_ferret('doe') - assert_equal 1, comments_from_ferret.size - assert_equal comment.id, comments_from_ferret.first.id - - comments_from_ferret = Comment.find_with_ferret('useless') - assert_equal 1, comments_from_ferret.size - assert_equal comment.id, comments_from_ferret.first.id - - # no monkeys here - comments_from_ferret = Comment.find_with_ferret('monkey') - assert comments_from_ferret.empty? - - # multiple terms are ANDed by default... - comments_from_ferret = Comment.find_with_ferret('monkey comment') - assert comments_from_ferret.empty? - # ...unless you connect them by OR - comments_from_ferret = Comment.find_with_ferret('monkey OR comment') - assert_equal 3, comments_from_ferret.size - assert comments_from_ferret.include?(comment) - assert comments_from_ferret.include?(comments(:first)) - assert comments_from_ferret.include?(comments(:another)) - - # multiple terms, each term has to occur in a document to be found, - # but they may occur in different fields - comments_from_ferret = Comment.find_with_ferret('useless john') - assert_equal 1, comments_from_ferret.size - assert_equal comment.id, comments_from_ferret.first.id - - - # search for an exact string by enclosing it in " - comments_from_ferret = Comment.find_with_ferret('"useless john"') - assert comments_from_ferret.empty? - comments_from_ferret = Comment.find_with_ferret('"useless comment"') - assert_equal 1, comments_from_ferret.size - assert_equal comment.id, comments_from_ferret.first.id - - comment.destroy - comment2.destroy - end - - # fixed with Ferret 0.9.6 - def test_stopwords_ferret_bug - i = Ferret::I.new(:or_default => false, :default_field => '*' ) - d = Ferret::Document.new - d[:id] = '1' - d[:content] = 'Move or shake' - i << d - hits = i.search 'move AND or AND shake' - assert_equal 1, hits.total_hits - hits = i.search 'move AND nothere AND shake' - assert_equal 0, hits.total_hits - hits = i.search 'move AND shake' - assert_equal 1, hits.total_hits - hits = i.search 'move OR shake' - assert_equal 1, hits.total_hits - hits = i.search '+move +the +shake' - assert_equal 1, hits.total_hits - - hits = i.search 'move nothere' - assert_equal 0, hits.total_hits - end - - def test_stopwords - comment = Comment.create( :author => 'john doe', :content => 'Move or shake' ) - ['move shake', 'Move shake', 'move Shake', 'move or shake', 'move the shake'].each do |q| - comments_from_ferret = Comment.find_with_ferret(q) - assert_equal comment, comments_from_ferret.first, "query #{q} failed" - end - comment.destroy - end - - def test_array_conditions_combining - comments_from_ferret = Comment.find_with_ferret('comment AND fixture', {}, :conditions => [ 'id IN (?)', [ 2, 3 ] ]) - assert_equal 1, comments_from_ferret.size - assert_equal 1, comments_from_ferret.total_hits - end - - -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/content_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/unit/content_test.rb deleted file mode 100644 index 80e109f7..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/content_test.rb +++ /dev/null @@ -1,705 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'pp' -require 'fileutils' - -class ContentTest < Test::Unit::TestCase - include Ferret::Index - include Ferret::Search - fixtures :contents, :comments - - def setup - #make sure the fixtures are in the index - FileUtils.rm_f 'index/test/' - Comment.rebuild_index - ContentBase.rebuild_index - raise "missing fixtures" unless ContentBase.count > 2 - - @another_content = Content.new( :title => 'Another Content item', - :description => 'this is not the title' ) - @another_content.save - @comment = @another_content.comments.create(:author => 'john doe', :content => 'This is a useless comment') - @comment2 = @another_content.comments.create(:author => 'another', :content => 'content') - @another_content.save # to update comment_count in ferret-index - end - - def teardown - ContentBase.find(:all).each { |c| c.destroy } - Comment.find(:all).each { |c| c.destroy } - end - - def test_limit_all - res = Content.find_with_ferret '*', { :limit => :all }, :conditions => ['lower(title) like ?', 'content'], :order => 'contents.description' - end - - def test_find_with_ferret_on_has_many_assoc - c = contents(:first) - comments = c.comments.find_with_ferret 'second' - assert_equal 1, comments.size - assert_equal comments(:another), comments.first - end - - def test_total_hits_on_has_many_assoc - c = contents(:first) - assert_equal 2, Comment.find_with_ferret('second OR regarding').total_hits - assert_equal 1, c.comments.find_with_ferret('second OR regarding').total_hits - end - - def test_include_option - assert_equal 1, Content.find_with_ferret('description', {}, :include => :comments).size - end - - def test_lazy_loading - results = Content.find_with_ferret 'description', :lazy => true - assert_equal 1, results.size - result = results.first - class << result - attr_accessor :ar_record # so we have a chance to check if it's been loaded... - end - assert ActsAsFerret::FerretResult === result - assert_equal 'A useless description', result.description - assert_nil result.instance_variable_get(:@ar_record) - assert_equal 'My Title', result.title - assert_not_nil result.ar_record - end - - def test_ticket_69 - content = Content.create(:title => 'aksjeselskap test', - :description => 'content about various norwegian companies. A.s. Haakon, Åmot Håndverksenter A/S, Øye Trelast AS') - - # these still fail: 'A\S', 'AS' - [ '"A.s. Haakon"', 'A.s. Haakon', 'Åmot A/S', 'A/S' ].each do |query| - assert_equal content, Content.find_with_ferret(query).first, query - end - end - - def test_highlight - highlight = @another_content.highlight('title') - assert_equal 1, highlight.size - assert_equal "this is not the title", highlight.first - - highlight = @another_content.highlight('title', :field => :description) - assert_equal 1, highlight.size - assert_equal "this is not the title", highlight.first - end - - def test_highlight_new_record - c = Content.create :title => 'the title', :description => 'the new description' - highlight = c.highlight('new') - assert_equal 1, highlight.size - assert_equal "the new description", highlight.first - - c1 = Content.find_with_ferret('new description').first - assert_equal c, c1 - highlight = c1.highlight('new') - assert_equal 1, highlight.size - assert_equal "the new description", highlight.first - end - - def test_disable_ferret_once - content = Content.new(:title => 'should not get saved', :description => 'do not find me') - assert_raises (ArgumentError) do - content.disable_ferret(:wrong) - end - assert content.ferret_enabled? - content.disable_ferret - assert !content.ferret_enabled? - content.save - assert content.ferret_enabled? - assert Content.find_with_ferret('"find me"').empty? - - content.save - assert content.ferret_enabled? - assert_equal content, Content.find_with_ferret('"find me"').first - end - - def test_ferret_disable_always - content = Content.new(:title => 'should not get saved', :description => 'do not find me') - assert content.ferret_enabled? - content.disable_ferret(:always) - assert !content.ferret_enabled? - 2.times do - content.save - assert Content.find_with_ferret('"find me"').empty? - assert !content.ferret_enabled? - end - content.ferret_enable - assert content.ferret_enabled? - content.save - assert content.ferret_enabled? - assert_equal content, Content.find_with_ferret('"find me"').first - end - - def test_disable_ferret_on_class_level - Content.disable_ferret - content = Content.new(:title => 'should not get saved', :description => 'do not find me') - assert !content.ferret_enabled? - assert !Content.ferret_enabled? - 2.times do - content.save - assert Content.find_with_ferret('"find me"').empty? - assert !Content.ferret_enabled? - assert !content.ferret_enabled? - end - content.enable_ferret # record level enabling should have no effect on class level - assert !Content.ferret_enabled? - assert !content.ferret_enabled? - Content.enable_ferret - assert Content.ferret_enabled? - assert content.ferret_enabled? - - content.save - assert content.ferret_enabled? - assert Content.ferret_enabled? - assert_equal content, Content.find_with_ferret('"find me"').first - end - - def test_disable_ferret_block - content = Content.new(:title => 'should not get saved', :description => 'do not find me') - content.disable_ferret do - 2.times do - content.save - assert Content.find_with_ferret('"find me"').empty? - assert !content.ferret_enabled? - end - end - assert content.ferret_enabled? - assert Content.find_with_ferret('"find me"').empty? - - content.disable_ferret(:index_when_finished) do - 2.times do - content.save - assert Content.find_with_ferret('"find me"').empty? - assert !content.ferret_enabled? - end - end - assert content.ferret_enabled? - assert_equal content, Content.find_with_ferret('"find me"').first - end - - def test_disable_ferret_on_class_level_block - content = Content.new(:title => 'should not get saved', :description => 'do not find me') - Content.disable_ferret do - 2.times do - content.save - assert Content.find_with_ferret('"find me"').empty? - assert !content.ferret_enabled? - assert !Content.ferret_enabled? - end - end - assert content.ferret_enabled? - assert Content.ferret_enabled? - assert Content.find_with_ferret('"find me"').empty? - content.save - assert_equal content, Content.find_with_ferret('"find me"').first - end - - # ticket 178 - def test_records_for_rebuild_works_with_includes - size = Content.count - Content.send( :with_scope, :find => { :include => :comments } ) do - Content.records_for_rebuild do |records, offset| - assert_equal size, records.size - end - end - end - - def test_records_for_bulk_index - Content.disable_ferret do - more_contents - end - min = Content.find(:all, :order => 'id asc').first.id - Content.records_for_bulk_index([min, min+1, min+2, min+3, min+4, min+6], 10) do |records, offset| - assert_equal 6, records.size - end - end - - def test_bulk_index_no_optimize - Content.disable_ferret do - more_contents - end - - assert Content.find_with_ferret('title').empty? - min = Content.find(:all, :order => 'id asc').first.id - Content.bulk_index(min, min+1, min+2, min+3, min+4, min+6, :optimize => false) - assert_equal 6, Content.find_with_ferret('title').size - end - - def test_bulk_index - Content.disable_ferret do - more_contents - end - - assert Content.find_with_ferret('title').empty? - min = Content.find(:all, :order => 'id asc').first.id - Content.bulk_index([min, min+1, min+2, min+3, min+4, min+6]) - assert_equal 6, Content.find_with_ferret('title').size - end - - - def test_unicode - content = Content.new(:title => 'Title with some Ümläuts - äöü', - :description => 'look - an ß') - content.save - result = Content.find_with_ferret('äöü') - assert_equal content, result.first - result = Content.find_with_ferret('üml*') - assert_equal content, result.first - result = Content.find_with_ferret('ß') - assert_equal content, result.first - end - - def test_content_for_field_name - c = 'lorem ipsum dolor sit amet. lorem.' - @c1 = Content.new( :title => 'Content item 1', - :description => c ) - assert_equal c, @c1.content_for_field_name(:description) - end - - def test_document_number - c = 'lorem ipsum dolor sit amet. lorem.' - c1 = Content.new( :title => 'Content item 1', - :description => c ) - c1.save - fi = Content.aaf_index.ferret_index - assert fi - hits = fi.search('title:"Content item 1"') - assert_equal 1, hits.total_hits - expected_doc_num = hits.hits.first.doc - assert_equal c, fi[expected_doc_num][:description] - doc_num = c1.document_number - assert_equal expected_doc_num, doc_num - assert_equal c, fi[doc_num][:description] - end - - def test_more_like_this - assert Content.find_with_ferret('lorem ipsum').empty? - @c1 = Content.new( :title => 'Content item 1', - :description => 'lorem ipsum dolor sit amet. lorem.' ) - @c1.save - @c2 = Content.new( :title => 'Content item 2', - :description => 'lorem ipsum dolor sit amet. lorem ipsum.' ) - @c2.save - assert_equal 2, Content.find_with_ferret('lorem ipsum').size - similar = @c1.more_like_this(:field_names => [:description], :min_doc_freq => 1, :min_term_freq => 1) - assert_equal 1, similar.size - assert_equal @c2, similar.first - end - - def test_more_like_this_new_record - assert Content.find_with_ferret('lorem ipsum').empty? - @c1 = Content.new( :title => 'Content item 1', - :description => 'lorem ipsum dolor sit amet. lorem.' ) - @c2 = Content.new( :title => 'Content item 2', - :description => 'lorem ipsum dolor sit amet. lorem ipsum.' ) - @c2.save - assert_equal 1, Content.find_with_ferret('lorem ipsum').size - similar = @c1.more_like_this(:field_names => [:description], :min_doc_freq => 1, :min_term_freq => 1) - assert_equal 1, similar.size - assert_equal @c2, similar.first - end - - def test_class_index_dir - assert Content.aaf_configuration[:index_dir] =~ %r{^#{RAILS_ROOT}/index/test/content_base} - end - - def test_update - contents_from_ferret = Content.find_with_ferret('useless') - assert_equal 1, contents_from_ferret.size - assert_equal contents(:first).id, contents_from_ferret.first.id - contents(:first).description = 'Updated description, still useless' - contents(:first).save - contents_from_ferret = Content.find_with_ferret('useless') - assert_equal 1, contents_from_ferret.size - assert_equal contents(:first).id, contents_from_ferret.first.id - contents_from_ferret = Content.find_with_ferret('updated AND description') - assert_equal 1, contents_from_ferret.size - assert_equal contents(:first).id, contents_from_ferret.first.id - contents_from_ferret = Content.find_with_ferret('updated OR description') - assert_equal 1, contents_from_ferret.size - assert_equal contents(:first).id, contents_from_ferret.first.id - end - - def test_indexed_method - assert_equal 2, @another_content.comment_count - assert_equal 2, contents(:first).comment_count - assert_equal 1, contents(:another).comment_count - # retrieve all content objects having 2 comments - result = Content.find_with_ferret('comment_count:2') - # TODO check why this range query returns 3 results - #result = Content.find_with_ferret('comment_count:[2 TO 1000]') - # p result - assert_equal 2, result.size - assert result.include?(@another_content) - assert result.include?(contents(:first)) - end - - def test_sorting - sorting = [ Ferret::Search::SortField.new(:id, :reverse => true) ] - result = Content.find_with_ferret('comment_count:2', :sort => sorting) - assert !result.empty? - assert result.first.id > result.last.id - - sorting = [ Ferret::Search::SortField.new(:id) ] - result = Content.find_with_ferret('comment_count:2', :sort => sorting) - assert result.first.id < result.last.id - - sorting = Ferret::Search::Sort.new([ Ferret::Search::SortField.new(:id), - Ferret::Search::SortField::SCORE ], - :reverse => true) - - - result = Content.find_with_ferret('comment_count:2', :sort => sorting) - assert result.first.id > result.last.id - end - - def test_sort_class - sorting = Ferret::Search::Sort.new(Ferret::Search::SortField.new(:id, :reverse => true)) - result = Content.find_with_ferret('comment_count:2 OR comment_count:1', :sort => sorting) - assert result.size > 2 - assert result.first.id > result.last.id - result = Content.find_with_ferret('comment_count:2 OR comment_count:1', :sort => sorting, :limit => 2) - assert_equal 2, result.size - assert result.first.id > result.last.id - end - - def test_sort_with_limit - sorting = [ Ferret::Search::SortField.new(:id) ] - result = Content.find_with_ferret('comment_count:2 OR comment_count:1', :sort => sorting) - assert result.size > 2 - assert result.first.id < result.last.id - result = Content.find_with_ferret('comment_count:2 OR comment_count:1', :sort => sorting, :limit => 2) - assert_equal 2, result.size - assert result.first.id < result.last.id - - sorting = [ Ferret::Search::SortField.new(:id, :reverse => true) ] - result = Content.find_with_ferret('comment_count:2 OR comment_count:1', :sort => sorting) - assert result.size > 2 - assert result.first.id > result.last.id - result = Content.find_with_ferret('comment_count:2 OR comment_count:1', :sort => sorting, :limit => 2) - assert_equal 2, result.size - assert result.first.id > result.last.id - end - - - def test_add_rebuilds_index - remove_index Content - Content.create(:title => 'another one', :description => 'description') - contents_from_ferret = Content.find_with_ferret('description:title') - assert_equal 1, contents_from_ferret.size - end - def test_find_rebuilds_index - remove_index Content - contents_from_ferret = Content.find_with_ferret('description:title') - assert_equal 1, contents_from_ferret.size - end - - def test_total_hits - assert_equal 2, Content.total_hits('title:title OR description:title') - assert_equal 2, Content.total_hits('title:title OR description:title', :limit => 1) - end - - def test_find_ids_with_ferret - total_hits, contents_from_ferret = Content.find_ids_with_ferret('title:title OR description:title') - assert_equal 2, contents_from_ferret.size - assert_equal 2, total_hits - #puts "first (id=#{contents_from_ferret.first[:id]}): #{contents_from_ferret.first[:score]}" - #puts "last (id=#{contents_from_ferret.last[:id]}): #{contents_from_ferret.last[:score]}" - assert_equal contents(:first).id, contents_from_ferret.first[:id].to_i - assert_equal @another_content.id, contents_from_ferret.last[:id].to_i - assert contents_from_ferret.first[:score] >= contents_from_ferret.last[:score] - - # give description field higher boost: - total_hits, contents_from_ferret = Content.find_ids_with_ferret('title:title OR description:title^200') - assert_equal 2, contents_from_ferret.size - assert_equal 2, total_hits - #puts "first (id=#{contents_from_ferret.first[:id]}): #{contents_from_ferret.first[:score]}" - #puts "last (id=#{contents_from_ferret.last[:id]}): #{contents_from_ferret.last[:score]}" - assert_equal @another_content.id, contents_from_ferret.first[:id].to_i - assert_equal contents(:first).id, contents_from_ferret.last[:id].to_i - assert contents_from_ferret.first[:score] > contents_from_ferret.last[:score] - - end - - def test_find_with_ferret_boost - # give description field higher boost: - contents_from_ferret = Content.find_with_ferret('title:title OR description:title^200') - assert_equal 2, contents_from_ferret.size - assert_equal @another_content.id, contents_from_ferret.first.id - assert_equal contents(:first).id, contents_from_ferret.last.id - end - - def test_default_and_queries - # multiple terms are ANDed by default... - contents_from_ferret = Content.find_with_ferret('monkey description') - assert contents_from_ferret.empty? - # ...unless you connect them by OR - contents_from_ferret = Content.find_with_ferret('monkey OR description') - assert_equal 1, contents_from_ferret.size - assert_equal contents(:first).id, contents_from_ferret.first.id - - # multiple terms, each term has to occur in a document to be found, - # but they may occur in different fields - contents_from_ferret = Content.find_with_ferret('useless title') - assert_equal 1, contents_from_ferret.size - assert_equal contents(:first).id, contents_from_ferret.first.id - end - - def test_find_with_ferret - - contents_from_ferret = Content.find_with_ferret('lorem ipsum not here') - assert contents_from_ferret.empty? - - contents_from_ferret = Content.find_with_ferret('title') - assert_equal 2, contents_from_ferret.size - # the title field has a higher boost value, so contents(:first) must be first in the list - assert_equal contents(:first).id, contents_from_ferret.first.id - assert_equal @another_content.id, contents_from_ferret.last.id - - - - contents_from_ferret = Content.find_with_ferret('useless') - assert_equal 1, contents_from_ferret.size - assert_equal contents(:first).id, contents_from_ferret.first.id - - # no monkeys here - contents_from_ferret = Content.find_with_ferret('monkey') - assert contents_from_ferret.empty? - - - - # search for an exact string by enclosing it in " - contents_from_ferret = Content.find_with_ferret('"useless title"') - assert contents_from_ferret.empty? - contents_from_ferret = Content.find_with_ferret('"useless description"') - assert_equal 1, contents_from_ferret.size - assert_equal contents(:first).id, contents_from_ferret.first.id - - # wildcard query - contents_from_ferret = Content.find_with_ferret('use*') - assert_equal 1, contents_from_ferret.size - - # ferret-bug ? wildcard queries don't seem to get lowercased even when - # using StandardAnalyzer: - # contents_from_ferret = Content.find_with_ferret('Ti*') - # we should find both 'Title' and 'title' - # assert_equal 2, contents_from_ferret.size - # theory: :wild_lower parser option isn't used - - contents_from_ferret = Content.find_with_ferret('ti*') - # this time we find both 'Title' and 'title' - assert_equal 2, contents_from_ferret.size - - contents(:first).destroy - contents_from_ferret = Content.find_with_ferret('ti*') - # should find only one now - assert_equal 1, contents_from_ferret.size - assert_equal @another_content.id, contents_from_ferret.first.id - end - - def test_find_with_ferret_options - # find options - contents_from_ferret = Content.find_with_ferret('title', {}, :conditions => ["id=?",contents(:first).id]) - assert_equal 1, contents_from_ferret.size - assert_equal contents(:first), contents_from_ferret.first - - # limit result set size to 1 - contents_from_ferret = Content.find_with_ferret('title', :limit => 1) - assert_equal 1, contents_from_ferret.size - assert_equal contents(:first), contents_from_ferret.first - - # limit result set size to 1, starting with the second result - contents_from_ferret = Content.find_with_ferret('title', :limit => 1, :offset => 1) - assert_equal 1, contents_from_ferret.size - assert_equal @another_content.id, contents_from_ferret.first.id - - end - - def test_pagination - more_contents - - r = Content.find_with_ferret 'title', :per_page => 10, :sort => 'title' - assert_equal 30, r.total_hits - assert_equal 10, r.size - assert_equal "0", r.first.description - assert_equal "9", r.last.description - assert_equal 1, r.current_page - assert_equal 3, r.page_count - - r = Content.find_with_ferret 'title', :page => '2', :per_page => 10, :sort => 'title' - assert_equal 30, r.total_hits - assert_equal 10, r.size - assert_equal "10", r.first.description - assert_equal "19", r.last.description - assert_equal 2, r.current_page - assert_equal 3, r.page_count - - r = Content.find_with_ferret 'title', :page => 4, :per_page => 10, :sort => 'title' - assert_equal 30, r.total_hits - assert_equal 0, r.size - end - - def test_limits_and_offsets - more_contents - r = Content.find_with_ferret 'title' - assert_equal 30, r.total_hits - assert_equal 10, r.size - - r = Content.find_with_ferret 'title', :limit => :all - assert_equal 30, r.total_hits - assert_equal 30, r.size - end - - def test_limits_and_offsets_with_ar_conditions - more_contents - - r = Content.find_with_ferret 'title', { :limit => 10, :offset => 0 }, - { :conditions => "description != '0'", :order => 'title ASC' } - assert_equal 29, r.total_hits - assert_equal 10, r.size - assert_equal "1", r.first.description - assert_equal "10", r.last.description - - r = Content.find_with_ferret 'title', { :limit => 10, :offset => 10 }, - { :conditions => "description != '0'", :order => 'title ASC' } - assert_equal 29, r.total_hits - assert_equal 10, r.size - assert_equal "11", r.first.description - assert_equal "20", r.last.description - - r = Content.find_with_ferret 'title', { }, - { :conditions => "description != '0'", :order => 'title ASC', - :limit => 10, :offset => 0 } - assert_equal 29, r.total_hits - assert_equal 10, r.size - assert_equal "1", r.first.description - assert_equal "10", r.last.description - - r = Content.find_with_ferret 'title', { }, - { :conditions => "description != '0'", :order => 'title ASC', - :limit => 10, :offset => 10 } - assert_equal 29, r.total_hits - assert_equal 10, r.size - assert_equal "11", r.first.description - assert_equal "20", r.last.description - end - - def test_pagination_with_ar_conditions - more_contents - - r = Content.find_with_ferret 'title', { :page => 1, :per_page => 10 }, - { :conditions => "description != '0'", :order => 'title ASC' } - assert_equal 29, r.total_hits - assert_equal 10, r.size - assert_equal "1", r.first.description - assert_equal "10", r.last.description - assert_equal 1, r.current_page - assert_equal 3, r.page_count - - r = Content.find_with_ferret 'title', { :page => 3, :per_page => 10 }, - { :conditions => "description != '0'", :order => 'title ASC' } - assert_equal 9, r.size - assert_equal 29, r.total_hits - assert_equal "21", r.first.description - assert_equal "29", r.last.description - assert_equal 3, r.current_page - assert_equal 3, r.page_count - end - - def test_pagination_with_ar_conditions_and_ferret_sort - more_contents - - # r = Content.find_with_ferret 'title', { :page => 1, :per_page => 10, - # :sort => Ferret::Search::SortField.new(:id, - # :type => :integer, - # :reverse => true ) }, - # { :conditions => "description != '0'" } - r = ActsAsFerret::find 'title', Content, { :page => 1, :per_page => 10, - :sort => Ferret::Search::SortField.new(:id, - :type => :integer, - :reverse => true ) }, - { :conditions => "description != '29'" } - assert_equal 29, r.total_hits - assert_equal 10, r.size - assert_equal "28", r.first.description - assert_equal "19", r.last.description - assert_equal 1, r.current_page - assert_equal 3, r.page_count - - r = Content.find_with_ferret 'title', { :page => 3, :per_page => 10 }, - { :conditions => "description != '0'", :order => 'title ASC' } - assert_equal 9, r.size - assert_equal 29, r.total_hits - assert_equal "21", r.first.description - assert_equal "29", r.last.description - assert_equal 3, r.current_page - assert_equal 3, r.page_count - end - - def test_pagination_with_more_conditions - more_contents - - r = Content.find_with_ferret 'title -description:0', { :page => 1, :per_page => 10 }, - { :conditions => "contents.description != '9'", :order => 'title ASC' } - assert_equal 28, r.total_hits - assert_equal 10, r.size - assert_equal "1", r.first.description - assert_equal "11", r.last.description - assert_equal 1, r.current_page - assert_equal 3, r.page_count - end - - def test_reconnect_in_drb_mode - if ENV['AAF_REMOTE'] && Content.connection.is_a?(ActiveRecord::ConnectionAdapters::MysqlAdapter) - puts "have DRb and MySQL - doing db reconnect test" - Content.aaf_index.send(:db_disconnect!) - c = Content.create! :title => 'another one', :description => 'description' - assert_equal c, Content.find_with_ferret('another').first - else - assert true - end - end - - def test_per_field_boost - Content.destroy_all - Content.create! :title => 'the title' - boosted = Content.new :title => 'the title' - boosted.title_boost = 100 - boosted.save! - Content.create! :title => 'the title' - results = Content.find_with_ferret 'title:title' - assert_equal 3, results.size - assert_equal boosted.id, results.first.id - end - - def test_per_document_boost - Content.destroy_all - Content.create! :title => 'the title' - boosted = Content.new :title => 'the title' - boosted.record_boost = 10 - boosted.save! - Content.create! :title => 'the title' - results = Content.find_with_ferret 'title' - assert_equal 3, results.size - assert_equal boosted.id, results.first.id - end - - - protected - - def more_contents(with_comments = false) - Comment.destroy_all if with_comments - Content.destroy_all - SpecialContent.destroy_all - 30.times do |i| - c = Content.create! :title => sprintf("title of Content %02d", i), :description => "#{i}" - c.comments.create! :content => sprintf("Comment for content %02d", i) if with_comments - end - end - - def remove_index(clazz) - clazz.aaf_index.close # avoid io error when deleting the open index - FileUtils.rm_rf clazz.aaf_configuration[:index_dir] - assert !File.exists?("#{clazz.aaf_configuration[:index_dir]}/segments") - end - -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/ferret_result_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/unit/ferret_result_test.rb deleted file mode 100644 index e2883e39..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/ferret_result_test.rb +++ /dev/null @@ -1,24 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'pp' -require 'fileutils' - -class FerretResultTest < Test::Unit::TestCase - fixtures :contents - - def teardown - end - - def test_get_prefetched_fields_from_hash - fr = ActsAsFerret::FerretResult.new 'Content', '1', 0.5, 1, :description => 'description from ferret index' - assert_equal 'description from ferret index', fr.description - assert_equal 0.5, fr.ferret_score - assert_equal 1, fr.ferret_rank - assert_equal 'My Title', fr.title # triggers auto-load of the record - assert_equal 'A useless description', fr.description # description now comes from DB - end - - def test_to_param - fr = ActsAsFerret::FerretResult.new 'Content', '1', 0.5, 1, :description => 'description from ferret index' - assert_equal '1', fr.to_param - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/multi_index_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/unit/multi_index_test.rb deleted file mode 100644 index 86d18eb7..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/multi_index_test.rb +++ /dev/null @@ -1,329 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'pp' -require 'fileutils' - -class MultiIndexTest < Test::Unit::TestCase - include Ferret::Index - include Ferret::Search - fixtures :contents, :comments - - def setup - #make sure the fixtures are in the index - FileUtils.rm_f 'index/test/' - Comment.rebuild_index - ContentBase.rebuild_index - raise "missing fixtures" unless ContentBase.count > 2 - - @another_content = Content.new( :title => 'Another Content item', - :description => 'this is not the title' ) - @another_content.save - @comment = @another_content.comments.create(:author => 'john doe', :content => 'This is a useless comment') - @comment2 = @another_content.comments.create(:author => 'another', :content => 'content') - @another_content.save # to update comment_count in ferret-index - end - - def teardown - ContentBase.find(:all).each { |c| c.destroy } - Comment.find(:all).each { |c| c.destroy } - end - - - # weiter: single index / multisearch lazy loading -# def test_lazy_loading -# results = Content.find_with_ferret 'description', :lazy => true -# assert_equal 1, results.size -# result = results.first -# class << result -# attr_accessor :ar_record # so we have a chance to check if it's been loaded... -# end -# assert ActsAsFerret::FerretResult === result -# assert_equal 'A useless description', result.description -# assert_nil result.instance_variable_get(:@ar_record) -# assert_equal 'My Title', result.title -# assert_not_nil result.ar_record -# end - - - def test_total_hits - q = '*:title OR *:comment' - assert_equal 3, Comment.total_hits(q) - assert_equal 2, Content.total_hits(q) - assert_equal 5, ActsAsFerret::total_hits(q, [ Comment, Content ]) - end - - def test_sorting - sorting = [ Ferret::Search::SortField.new(:id) ] - result = ActsAsFerret::find('*:title OR *:comment', [Content, Comment], :sort => sorting) - assert_equal result.map(&:id).sort, result.map(&:id) - - sorting = [ Ferret::Search::SortField.new(:title) ] - result = ActsAsFerret::find('*:title OR *:comment', [Content, Comment], :sort => sorting) - sorting = [ Ferret::Search::SortField.new(:title, :reverse => true) ] - result2 = ActsAsFerret::find('*:title OR *:comment', [Content, Comment], :sort => sorting) - assert result.any? - assert result.map(&:id) != result2.map(&:id) - - result = ActsAsFerret::find('*:title OR *:comment', [Content, Comment ]) - assert result.any? - assert_equal result.map(&:ferret_score).sort.reverse, result.map(&:ferret_score) - - sorting = [ Ferret::Search::SortField::SCORE ] - result = ActsAsFerret::find('*:title OR *:comment', [Content, Comment ], :sort => sorting) - assert result.any? - assert_equal result.map(&:ferret_score).sort.reverse, result.map(&:ferret_score) - - sorting = [ Ferret::Search::SortField::SCORE_REV ] - result2 = ActsAsFerret::find('*:title OR *:comment', [Content, Comment], :sort => sorting) - assert_equal result2.map(&:ferret_score).sort, result2.map(&:ferret_score) - assert_equal result.map(&:ferret_score), result2.map(&:ferret_score).reverse - end - - - # remote index rebuilds will create an index in a directory with a timestamped name. - # the local MultiIndex instance doesn't know about this (because it's running in - # another interpreter instance than the server) and therefore fails to use the - # correct index directories. - # TODO strange, still doesn't work but it should now... - unless Content.aaf_configuration[:remote] - def test_multi_index - i = ActsAsFerret::get_index_for Content, Comment - assert ActsAsFerret::MultiIndex === i - hits = i.search(TermQuery.new(:title,"title")) - assert_equal 1, hits.total_hits - - qp = Ferret::QueryParser.new(:default_field => "title", - :analyzer => Ferret::Analysis::WhiteSpaceAnalyzer.new) - hits = i.search(qp.parse("title")) - assert_equal 1, hits.total_hits - - qp = Ferret::QueryParser.new(:fields => ['title', 'content', 'description'], - :analyzer => Ferret::Analysis::WhiteSpaceAnalyzer.new) - hits = i.search(qp.parse("title")) - assert_equal 2, hits.total_hits - hits = i.search(qp.parse("title:title OR description:title")) - assert_equal 2, hits.total_hits - - hits = i.search("title:title OR description:title OR title:comment OR description:comment OR content:comment") - assert_equal 5, hits.total_hits - - hits = i.search("title OR comment") - assert_equal 5, hits.total_hits - - hits = i.search("title OR comment", :limit => 2) - count = 0 - hits.hits.each { |hit, score| count += 1 } - assert_equal 2, count - - hits = i.search("title OR comment", :offset => 2) - count = 0 - hits.hits.each { |hit, score| count += 1 } - assert_equal 3, count - end - end - - def test_search_rebuilds_index - remove_index Content - contents_from_ferret = ActsAsFerret::find('description:title', [Content, Comment]) - assert_equal 1, contents_from_ferret.size - end - - # remote index rebuilds will create an index in a directory with a timestamped name... - unless Content.aaf_configuration[:remote] - def test_rebuilds_index - remove_index Content - idx = ActsAsFerret.get_index_for( Content ) - i = ActsAsFerret::MultiIndex.new([idx]) - assert File.exists?("#{idx.index_definition[:index_dir]}/segments") - hits = i.search("description:title") - assert_equal 1, hits.total_hits, hits.inspect - end - end - - def test_find_options - contents_from_ferret = ActsAsFerret::find('title', [Content, Comment ], { }, :order => 'id desc') - assert_equal 2, contents_from_ferret.size - assert contents_from_ferret.first.id > contents_from_ferret.last.id - contents_from_ferret = ActsAsFerret::find('title', [Content, Comment ], { }, :order => 'id asc') - assert contents_from_ferret.first.id < contents_from_ferret.last.id - - contents_from_ferret = ActsAsFerret::find('title', [Content, Comment], :limit => 1) - assert_equal 1, contents_from_ferret.size - contents_from_ferret = ActsAsFerret::find('title', [Content, Comment ], { }, :limit => 1) - assert_equal 1, contents_from_ferret.size - - - more_contents(true) - r = ActsAsFerret::find('title OR comment', [Content, Comment], { :limit => :all } ) - assert_equal 60, r.size - assert_equal 60, r.total_hits - - id = Content.find_with_ferret('title').first.id - r = ActsAsFerret::find('title OR comment', [Content, Comment], { :limit => :all }, - { :conditions => { :content => ["id != ?", id] }}) - assert_equal 59, r.size - assert_equal 59, r.total_hits - - r = ActsAsFerret::find('title OR comment', [Content, Comment], { :limit => 20 }, - { :conditions => { :content => ["id != ?", id] }}) - assert_equal 20, r.size - assert_equal 59, r.total_hits - - r = ActsAsFerret::find('title OR comment', [Content, Comment], { :limit => 20 }, - { :conditions => { :comment => 'content is null', - :content => ["id != ?", id] }}) - assert_equal 20, r.size - assert_equal 29, r.total_hits - - r = ActsAsFerret::find('title OR comment', [Content, Comment ], { }, - { :conditions => { :content => ["id != ?", id] }, :limit => 20 }) - assert_equal 20, r.size - assert_equal 59, r.total_hits - end - - def test_multi_search - assert_equal 4, ContentBase.find(:all).size - - Content.aaf_index.ferret_index.flush - contents_from_ferret = ActsAsFerret::find('description:title', [Content]) - assert_equal 1, contents_from_ferret.size - contents_from_ferret = ActsAsFerret::find('title:title OR description:title', [Content]) - assert_equal 2, contents_from_ferret.size - contents_from_ferret = ActsAsFerret::find('title:title', [Content]) - assert_equal 1, contents_from_ferret.size - contents_from_ferret = ActsAsFerret::find('*:title', [Content]) - assert_equal 2, contents_from_ferret.size - contents_from_ferret = ActsAsFerret::find('title', [Content]) - assert_equal 2, contents_from_ferret.size - - assert_equal contents(:first).id, contents_from_ferret.first.id - assert_equal @another_content.id, contents_from_ferret.last.id - - contents_from_ferret = ActsAsFerret::find('title', [Content]) - assert_equal 2, contents_from_ferret.size - contents_from_ferret = ActsAsFerret::find('title', [Content], :limit => 1) - assert_equal 1, contents_from_ferret.size - contents_from_ferret = ActsAsFerret::find('title', [Content], :offset => 1) - assert_equal 1, contents_from_ferret.size - - contents_from_ferret = ActsAsFerret::find('title:title OR content:comment OR description:title', [Content, Comment]) - assert_equal 5, contents_from_ferret.size - contents_from_ferret = ActsAsFerret::find('title:title OR content:comment OR description:title', [Content, Comment], :limit => 2) - assert_equal 2, contents_from_ferret.size - - contents_from_ferret = ActsAsFerret::find('*:title OR *:comment', [Content, Comment]) - assert_equal 5, contents_from_ferret.size - contents_from_ferret = ActsAsFerret::find('*:title OR *:comment', [Content, Comment]) - assert_equal 5, contents_from_ferret.size - contents_from_ferret = ActsAsFerret::find('title:(title OR comment) OR description:(title OR comment) OR content:(title OR comment)', [Content, Comment]) - assert_equal 5, contents_from_ferret.size - end - - def test_lazy_search - contents_from_ferret = ActsAsFerret.find('title', [Content, Comment], :lazy => true) - assert_equal 2, contents_from_ferret.size - contents_from_ferret.each do |record| - assert ActsAsFerret::FerretResult === record, record.inspect - assert !record.description.blank? - assert_nil record.instance_variable_get(:"@ar_record") - end - end - - def test_find_ids - assert_equal 4, ContentBase.find(:all).size - - [ 'title:title OR description:title OR content:title', 'title', '*:title'].each do |query| - total_hits, contents_from_ferret = ActsAsFerret.find_ids(query, Content) - assert_equal 2, contents_from_ferret.size, query - assert_equal 2, total_hits, query - assert_equal contents(:first).id, contents_from_ferret.first[:id].to_i - assert_equal @another_content.id, contents_from_ferret.last[:id].to_i - end - - ContentBase.rebuild_index - Comment.rebuild_index - ['title OR comment', 'title:(title OR comment) OR description:(title OR comment) OR content:(title OR comment)'].each do |query| - total_hits, contents_from_ferret = ActsAsFerret.find_ids(query, [Comment, Content]) - assert_equal 5, contents_from_ferret.size, query - assert_equal 5, total_hits - end - end - - def test_find_ids_lazy - total_hits, contents_from_ferret = ActsAsFerret.find_ids('title', [Comment, Content], :lazy => true) - assert_equal 2, contents_from_ferret.size - assert_equal 2, total_hits - found = 0 - contents_from_ferret.each do |data| - next if data[:model] != 'Content' - found += 1 - assert !data[:data][:description].blank? - end - assert_equal 2, found - end - - def test_pagination - more_contents(true) - - r = ActsAsFerret.find 'title OR comment', [ Content, Comment ], :per_page => 10, :sort => 'title' - assert_equal 60, r.total_hits - assert_equal 10, r.size - assert_equal "0", r.first.description - assert_equal "9", r.last.description - assert_equal 1, r.current_page - assert_equal 6, r.page_count - - r = ActsAsFerret.find 'title OR comment', [ Content, Comment ], :page => '2', :per_page => 10, :sort => 'title' - assert_equal 60, r.total_hits - assert_equal 10, r.size - assert_equal "10", r.first.description - assert_equal "19", r.last.description - assert_equal 2, r.current_page - assert_equal 6, r.page_count - - r = ActsAsFerret.find 'title OR comment', [ Content, Comment ], :page => 7, :per_page => 10, :sort => 'title' - assert_equal 60, r.total_hits - assert_equal 0, r.size - end - - def test_pagination_with_ar_conditions - more_contents(true) - id = Content.find_with_ferret('title').first.id - r = ActsAsFerret.find 'title OR comment', [Content, Comment], { :page => 1, :per_page => 10 }, - { :conditions => { :content => ["id != ?", id] }, :order => 'id ASC' } - assert_equal 59, r.total_hits - assert_equal 10, r.size - assert_equal "Comment for content 00", r.first.content - assert_equal "Comment for content 09", r.last.content - assert_equal 1, r.current_page - assert_equal 6, r.page_count - - r = ActsAsFerret.find 'title OR comment', [Content, Comment], { :page => 6, :per_page => 10 }, - { :conditions => { :content => [ "id != ?", id ] }, :order => 'id ASC' } - assert_equal 59, r.total_hits - assert_equal 9, r.size - assert_equal "21", r.first.description - assert_equal "29", r.last.description - assert_equal 6, r.current_page - assert_equal 6, r.page_count - end - - protected - - def more_contents(with_comments = false) - Comment.destroy_all if with_comments - Content.destroy_all - SpecialContent.destroy_all - 30.times do |i| - c = Content.create! :title => sprintf("title of Content %02d", i), :description => "#{i}" - c.comments.create! :content => sprintf("Comment for content %02d", i) if with_comments - end - end - - def remove_index(clazz) - clazz.aaf_index.close # avoid io error when deleting the open index - FileUtils.rm_rf clazz.aaf_configuration[:index_dir] - assert !File.exists?("#{clazz.aaf_configuration[:index_dir]}/segments") - end - -end - diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/remote_index_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/unit/remote_index_test.rb deleted file mode 100644 index bdf530e8..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/remote_index_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class RemoteIndexTest < Test::Unit::TestCase - def setup - ActsAsFerret::remote = 'druby://localhost:9999' - end - - def test_raises_drb_errors - ActsAsFerret::raise_drb_errors = true - @srv = ActsAsFerret::RemoteIndex.new :name => 'idx' - assert_raise DRb::DRbConnError do - @srv.find_ids 'some query' - end - end - - def test_does_not_raise_drb_errors - ActsAsFerret::raise_drb_errors = false - @srv = ActsAsFerret::RemoteIndex.new :name => 'idx' - total_hits, results = @srv.find_ids( 'some query' ) - assert_equal 0, total_hits - assert results.empty? - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/shared_index1_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/unit/shared_index1_test.rb deleted file mode 100644 index 1cee1b40..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/shared_index1_test.rb +++ /dev/null @@ -1,108 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class SharedIndex1Test < Test::Unit::TestCase - fixtures :shared_index1s, :shared_index2s - - def setup - SharedIndex1.rebuild_index - end - - def test_lazy_loading - results = ActsAsFerret::find 'first', 'shared', :lazy => [ :name ] - assert_equal 2, results.size - found_lazy_result = false - results.each { |r| - assert ActsAsFerret::FerretResult === r - assert !r.name.blank? - assert_nil r.instance_variable_get(:@ar_record) # lazy, AR record has not been fetched - } - end - - def test_find - assert_equal shared_index1s(:first), SharedIndex1.find(1) - assert_equal shared_index2s(:first), SharedIndex2.find(1) - end - - def test_find_ids_with_ferret - result = SharedIndex1.find_ids_with_ferret("first") - assert_equal 2, result.size - end - - def test_find_with_ferret_one_class - result = SharedIndex1.find_with_ferret("first") - assert_equal 1, result.size, result.inspect - assert_equal shared_index1s(:first), result.first - end - - def test_custom_query - result = SharedIndex1.find_with_ferret("name:first class_name:SharedIndex1") - assert_equal 1, result.size - assert_equal shared_index1s(:first), result.first - end - - def test_find_with_index_name - result = ActsAsFerret::find("first", 'shared') - assert_equal 2, result.size - assert result.include?(shared_index1s(:first)) - assert result.include?(shared_index2s(:first)) - end - - def test_find_with_class_list - result = ActsAsFerret::find("name:first", [SharedIndex1, SharedIndex2]) - assert_equal 2, result.size - assert result.include?(shared_index1s(:first)) - assert result.include?(shared_index2s(:first)) - end - - def test_query_for_record - assert_match /SharedIndex1/, shared_index1s(:first).query_for_record.to_s - end - - def test_destroy - result = ActsAsFerret::find("first OR another", 'shared') - assert_equal 4, result.size - SharedIndex1.destroy(shared_index1s(:first)) - result = ActsAsFerret::find("first OR another", 'shared') - assert_equal 3, result.size - shared_index2s(:first).destroy - result = ActsAsFerret::find("first OR another", 'shared') - assert_equal 2, result.size - end - - def test_ferret_destroy - SharedIndex1.rebuild_index - result = SharedIndex1.find_ids_with_ferret("first OR another", :models => :all) - assert_equal 4, result.first - shared_index1s(:first).ferret_destroy - result = SharedIndex1.find_ids_with_ferret("first OR another", :models => :all) - assert_equal 3, result.first - end - - def test_ferret_destroy_ticket_88 - SharedIndex1.rebuild_index - result = SharedIndex1.find_ids_with_ferret("first OR another", :models => :all) - assert_equal 4, result.first - result = SharedIndex2.find_ids_with_ferret("first OR another", :models => :all) - assert_equal 4, result.first - SharedIndex1.destroy(shared_index1s(:first)) - result = SharedIndex1.find_ids_with_ferret("first OR another", :models => :all) - assert_equal 3, result.first - result = SharedIndex2.find_ids_with_ferret("first OR another", :models => :all) - assert_equal 3, result.first - shared_index2s(:first).destroy - result = SharedIndex1.find_ids_with_ferret("first OR another", :models => :all) - assert_equal 2, result.first - result = SharedIndex2.find_ids_with_ferret("first OR another", :models => :all) - assert_equal 2, result.first - end - - def test_update - assert SharedIndex1.find_with_ferret("new").empty? - shared_index1s(:first).name = "new name" - shared_index1s(:first).save - assert_equal 1, SharedIndex1.find_with_ferret("new").size - assert_equal 1, SharedIndex1.find_with_ferret("new").size - assert_equal 1, SharedIndex1.find_with_ferret("new", :models => [SharedIndex2]).size - assert_equal 0, SharedIndex2.find_with_ferret("new").size - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/shared_index2_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/unit/shared_index2_test.rb deleted file mode 100644 index 188b7b34..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/shared_index2_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class SharedIndex2Test < Test::Unit::TestCase - fixtures :shared_index2s, :shared_index1s - - def setup - SharedIndex1.rebuild_index - end - - def test_query_for_record - assert_match /SharedIndex2/, shared_index2s(:first).query_for_record.to_s - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/sort_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/unit/sort_test.rb deleted file mode 100644 index 6d27c054..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/sort_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class SortTest < Test::Unit::TestCase - include Ferret::Search - - def test_sort_marshalling - [ Sort.new, - Sort.new( [], :reverse => true) , - Sort.new([ Ferret::Search::SortField.new(:id, :reverse => true), - Ferret::Search::SortField::SCORE, - Ferret::Search::SortField::DOC_ID ], - :reverse => true), - Sort.new([ Ferret::Search::SortField.new(:id), - Ferret::Search::SortField::SCORE_REV, - Ferret::Search::SortField::DOC_ID_REV ]) - ].each do |sort| - assert_equal sort.to_s, Sort._load(sort._dump(0)).to_s - end - end - -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/special_content_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/test/unit/special_content_test.rb deleted file mode 100644 index f60d2ed2..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/test/unit/special_content_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' - -class SpecialContentTest < Test::Unit::TestCase - include Ferret::Index - include Ferret::Search - fixtures :contents, :comments - - def setup - ContentBase.rebuild_index - Comment.rebuild_index - end - - def test_class_index_dir - assert SpecialContent.aaf_configuration[:index_dir] =~ %r{^#{RAILS_ROOT}/index/test/content_base} - end - - def test_find_with_ferret - contents_from_ferret = SpecialContent.find_with_ferret('single table') - assert_equal 1, contents_from_ferret.size - assert_equal ContentBase.find(3), contents_from_ferret.first - contents_from_ferret = SpecialContent.find_with_ferret('title') - assert contents_from_ferret.empty? - - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/LICENSE b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/LICENSE deleted file mode 100644 index 96a48cb3..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/LICENSE +++ /dev/null @@ -1,18 +0,0 @@ -Copyright (c) 2007 PJ Hyett and Mislav Marohnić - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/README b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/README deleted file mode 100644 index b4b14ec3..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/README +++ /dev/null @@ -1,108 +0,0 @@ -= WillPaginate - -Quick quiz: Where does pagination logic belong? - - a) in the model; - b) in the controller; - c) in views; - d) all of the above. - -We think you know the answer (if you think hard enough). - -This plugin makes magic happen. You *will* paginate! - - -== Example usage: - -Use a paginate finder in the controller: - - @posts = Post.paginate_by_board_id @board.id, :page => params[:page] - -Yeah, +paginate+ works just like +find+ -- it just doesn't fetch all the records. -Just don't forget to tell it which page you want! - -Render the posts in your view like you would normally do. When you need to render -pagination, just stick this in: - - <%= will_paginate @posts %> - -You're done. (Copy and paste the example fancy CSS styles from the bottom.) - -How does it know how much items to fetch per page? It asks your model by calling -+Post.per_page+. You can define it like this: - - class Post < ActiveRecord::Base - cattr_reader :per_page - @@per_page = 50 - end - -... or like this: - - class Post < ActiveRecord::Base - def self.per_page - 50 - end - end - -... or don't worry about it at all. (WillPaginate defines it to be 30 if missing.) -You can also specify the count explicitly when calling +paginate+: - - @posts = Post.paginate :page => params[:page], :per_page => 50 - -The +paginate+ finder wraps the original finder and returns your resultset that now has -some new properties. You can use the collection as you would with any ActiveRecord -resultset, but WillPaginate view helpers also need that object to be able to render pagination: - -
      - <% for post in @posts -%> -
    1. Render `post` in some nice way.
    2. - <% end -%> -
    - -

    Now let's render us some pagination!

    - <%= will_paginate @posts %> - - -== Authors, credits - - Ruby port by: PJ Hyett, Mislav Marohnić (Sulien) - Contributors: K. Adam Christensen, Chris Wanstrath, Dr. Nic Williams - Original announcement: http://errtheblog.com/post/929 - Original PHP source: http://www.strangerstudios.com/sandbox/pagination/diggstyle.php - -REPORT BUGS on Lighthouse: http://err.lighthouseapp.com/projects/466-plugins/overview - - -== Want Digg style? - -Copy the following css into your stylesheet for a good start: - - .pagination { - padding: 3px; - margin: 3px; - } - .pagination a { - padding: 2px 5px 2px 5px; - margin: 2px; - border: 1px solid #aaaadd; - text-decoration: none; - color: #000099; - } - .pagination a:hover, .pagination a:active { - border: 1px solid #000099; - color: #000; - } - .pagination span.current { - padding: 2px 5px 2px 5px; - margin: 2px; - border: 1px solid #000099; - font-weight: bold; - background-color: #000099; - color: #FFF; - } - .pagination span.disabled { - padding: 2px 5px 2px 5px; - margin: 2px; - border: 1px solid #eee; - color: #ddd; - } diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/Rakefile b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/Rakefile deleted file mode 100644 index 10e0663a..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/Rakefile +++ /dev/null @@ -1,23 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the will_paginate plugin.' -Rake::TestTask.new(:test) do |t| - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate RDoc documentation for the will_paginate plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - files = ['README', 'LICENSE', 'lib/**/*.rb'] - rdoc.rdoc_files.add(files) - rdoc.main = "README" # page to start on - rdoc.title = "will_paginate" - rdoc.template = File.exists?(t="/Users/chris/ruby/projects/err/rock/template.rb") ? t : "/var/www/rock/template.rb" - rdoc.rdoc_dir = 'doc' # rdoc output folder - rdoc.options << '--inline-source' -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/init.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/init.rb deleted file mode 100644 index 49be6c99..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/init.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'will_paginate/core_ext' -require 'will_paginate/collection' -require 'will_paginate/finder' -require 'will_paginate/view_helpers' - -ActionView::Base.send :include, WillPaginate::ViewHelpers -ActiveRecord::Base.send :include, WillPaginate::Finder - -module ActiveRecord::Associations - # to support paginating finders on associations, we have to mix in the - # method_missing magic from WillPaginate::Finder::ClassMethods to AssociationProxy - # subclasses, but in a different way for Rails 1.2.x and 2.0 - (AssociationCollection.instance_methods.include?(:create!) ? - AssociationCollection : AssociationCollection.subclasses.map(&:constantize) - ).push(HasManyThroughAssociation).each do |klass| - klass.class_eval do - include WillPaginate::Finder::ClassMethods - alias_method_chain :method_missing, :paginate - end - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/collection.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/collection.rb deleted file mode 100644 index 50eba693..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/collection.rb +++ /dev/null @@ -1,45 +0,0 @@ -module WillPaginate - # Arrays returned from paginating finds are, in fact, instances of this. - # You may think of WillPaginate::Collection as an ordinary array with some - # extra properties. Those properites are used by view helpers to generate - # correct page links. - # - class Collection < Array - attr_reader :current_page, :per_page - attr_accessor :total_entries - - # These collection objects are instantiated by ActiveRecord paginating - # finders; there is no need to do it manually. - # - def initialize(page, per_page, total) - @current_page = page.to_i - @per_page = per_page.to_i - @total_entries = total.to_i - @total_pages = (@total_entries / @per_page.to_f).ceil - end - - # The total number of pages. - def page_count - @total_pages - end - - # Current offset of the paginated collection. If we're on the first page, - # it is always 0. If we're on the 2nd page and there are 30 entries per page, - # the offset is 30. This property is useful if you want to render ordinals - # besides your records: simply start with offset + 1. - # - def offset - (current_page - 1) * per_page - end - - # current_page - 1 or nil if there is no previous page - def previous_page - current_page > 1 ? (current_page - 1) : nil - end - - # current_page + 1 or nil if there is no next page - def next_page - current_page < page_count ? (current_page + 1) : nil - end - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb deleted file mode 100644 index 5a73b0f0..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'set' - -unless Hash.instance_methods.include? 'except' - Hash.class_eval do - # Returns a new hash without the given keys. - def except(*keys) - rejected = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys) - reject { |key,| rejected.include?(key) } - end - - # Replaces the hash without only the given keys. - def except!(*keys) - replace(except(*keys)) - end - end -end - -unless Hash.instance_methods.include? 'slice' - Hash.class_eval do - # Returns a new hash with only the given keys. - def slice(*keys) - allowed = Set.new(respond_to?(:convert_key) ? keys.map { |key| convert_key(key) } : keys) - reject { |key,| !allowed.include?(key) } - end - - # Replaces the hash with only the given keys. - def slice!(*keys) - replace(slice(*keys)) - end - end -end - -unless Array.instance_methods.include? 'paginate' - # http://www.desimcadam.com/archives/8 - Array.class_eval do - def paginate(page = 1, per_page = 15) - pagination_array = WillPaginate::Collection.new(page, per_page, size) - start_index = pagination_array.offset - end_index = start_index + (per_page - 1) - array_to_concat = self[start_index..end_index] - array_to_concat.nil? ? [] : pagination_array.concat(array_to_concat) - end - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/finder.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/finder.rb deleted file mode 100644 index 7bfcf4b3..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/finder.rb +++ /dev/null @@ -1,159 +0,0 @@ -module WillPaginate - # A mixin for ActiveRecord::Base. Provides `per_page` class method - # and makes `paginate` finders possible with some method_missing magic. - # - # Find out more in WillPaginate::Finder::ClassMethods - # - module Finder - def self.included(base) - base.extend ClassMethods - class << base - alias_method_chain :method_missing, :paginate - define_method(:per_page) { 30 } unless respond_to?(:per_page) - end - end - - # = Paginating finders for ActiveRecord models - # - # WillPaginate doesn't really add extra methods to your ActiveRecord models (except +per_page+ - # unless it's already available). It simply intercepts - # the calls to paginating finders such as +paginate+, +paginate_by_user_id+ (and so on) and - # translates them to ordinary finders: +find+, +find_by_user_id+, etc. It does so with some - # method_missing magic, but you don't need to care for that. You simply use paginating finders - # same way you used ordinary ones. You only need to tell them what page you want in options. - # - # @topics = Topic.paginate :all, :page => params[:page] - # - # In paginating finders, "all" is implicit. No sense in paginating a single record, right? So: - # - # Post.paginate => Post.find :all - # Post.paginate_all_by_something => Post.find_all_by_something - # Post.paginate_by_something => Post.find_all_by_something - # - # Knowing that, the above example can be written simply as: - # - # @topics = Topic.paginate :page => params[:page] - # - # Don't forget to pass the +page+ parameter! Without it, paginating finders will raise an error. - # - # == Options - # Options for paginating finders are: - # - # page REQUIRED, but defaults to 1 if false or nil - # per_page (default is read from the model, which is 30 if not overriden) - # total entries not needed unless you want to count the records yourself somehow - # count hash of options that are used only for the call to count - # - module ClassMethods - # This methods wraps +find_by_sql+ by simply adding LIMIT and OFFSET to your SQL string - # based on the params otherwise used by paginating finds: +page+ and +per_page+. - # - # Example: - # - # @developers = Developer.paginate_by_sql ['select * from developers where salary > ?', 80000], - # :page => params[:page], :per_page => 3 - # - def paginate_by_sql(sql, options) - options, page, per_page = wp_parse_options!(options) - sanitized_query = sanitize_sql(sql) - total_entries = options[:total_entries] || count_by_sql("SELECT COUNT(*) FROM (#{sanitized_query}) AS count_table") - - returning WillPaginate::Collection.new(page, per_page, total_entries) do |pager| - options.update :offset => pager.offset, :limit => pager.per_page - add_limit! sanitized_query, options - pager.replace find_by_sql(sanitized_query) - end - end - - def respond_to?(method, include_priv = false) - case method.to_sym - when :paginate, :paginate_by_sql - true - else - super(method.to_s.sub(/^paginate/, 'find'), include_priv) - end - end - - protected - - def method_missing_with_paginate(method, *args, &block) - # did somebody tried to paginate? if not, let them be - unless method.to_s.index('paginate') == 0 - return method_missing_without_paginate(method, *args, &block) - end - - options, page, per_page = wp_parse_options!(args.pop) - # paginate finders are really just find_* with limit and offset - finder = method.to_s.sub /^paginate/, 'find' - # magic counting for user convenience - total_entries = wp_count!(options, args, finder) - - # :all is implicit - if finder == 'find' - args.unshift(:all) if args.empty? - elsif finder.index('find_by_') == 0 - finder.sub! /^find/, 'find_all' - end - - ::Object.returning WillPaginate::Collection.new(page, per_page, total_entries) do |pager| - args << options.update(:offset => pager.offset, :limit => pager.per_page) - pager.replace send(finder, *args) - end - end - - def wp_count!(options, args, finder) - # :total_entries and :count are mutually exclusive! - unless options[:total_entries] - unless args.first.is_a? Array - # count expects (almost) the same options as find - count_options = options.except :count, :order, :select - - # merge the hash found in :count - # this allows you to specify :select, :order, or anything else just for the count query - count_options.update(options.delete(:count)) if options.key? :count - # extract the conditions from calls like "paginate_by_foo_and_bar" - conditions = wp_extract_finder_conditions(finder, args, count_options) - - # scope_out adds a 'with_finder' method which acts like with_scope, if it's present - # then execute the count with the scoping provided by the with_finder - count = nil - counter = Proc.new { count = count(count_options) } - - if respond_to?(scoper = finder.sub(/^find/, 'with')) - send(scoper, &counter) - else - with_scope(:find => { :conditions => conditions }, &counter) - end - - count.respond_to?(:length) ? count.length : count - else - # array of IDs was passed, so its size is the total number - args.first.size - end - else - options.delete(:total_entries) - end - end - - def wp_parse_options!(options) - raise ArgumentError, 'hash parameters expected' unless options.respond_to? :symbolize_keys! - options.symbolize_keys! - raise ArgumentError, ':page parameter required' unless options.key? :page - page = options.delete(:page) || 1 - per_page = options.delete(:per_page) || self.per_page - [options, page, per_page] - end - - private - - # thanks to active record for making us duplicate this code - def wp_extract_finder_conditions(finder, arguments, count_options) - return unless match = /^find_(all_by|by)_([_a-zA-Z]\w*)$/.match(finder.to_s) - - attribute_names = extract_attribute_names_from_match(match) - raise "I can't make sense of #{finder}" unless all_attributes_exists?(attribute_names) - construct_attributes_from_arguments(attribute_names, arguments) - end - end - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb deleted file mode 100644 index ca903408..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb +++ /dev/null @@ -1,95 +0,0 @@ -module WillPaginate - # = Global options for pagination helpers - # - # Options for pagination helpers are optional and get their default values from the - # WillPaginate::ViewHelpers.pagination_options hash. You can write to this hash to - # override default options on the global level: - # - # WillPaginate::ViewHelpers.pagination_options[:prev_label] = 'Previous page' - # - # By putting this into your environment.rb you can easily localize link texts to previous - # and next pages, as well as override some other defaults to your liking. - module ViewHelpers - # default options that can be overriden on the global level - @@pagination_options = { :class => 'pagination', - :prev_label => '« Previous', - :next_label => 'Next »', - :inner_window => 4, # links around the current page - :outer_window => 1, # links around beginning and end - :separator => ' ', # single space is friendly to spiders and non-graphic browsers - :param_name => :page - } - mattr_reader :pagination_options - - # Renders Digg-style pagination. (We know you wanna!) - # Returns nil if there is only one page in total (can't paginate that). - # - # Options for will_paginate view helper: - # - # class: CSS class name for the generated DIV (default "pagination") - # prev_label: default '« Previous', - # next_label: default 'Next »', - # inner_window: how many links are shown around the current page, defaults to 4 - # outer_window: how many links are around the first and the last page, defaults to 1 - # separator: string separator for page HTML elements, default " " (single space) - # param_name: parameter name for page number in URLs, defaults to "page" - # - # All extra options are passed to the generated container DIV, so eventually - # they become its HTML attributes. - # - def will_paginate(entries = @entries, options = {}) - total_pages = entries.page_count - - if total_pages > 1 - options = options.symbolize_keys.reverse_merge(pagination_options) - page, param = entries.current_page, options.delete(:param_name) - - inner_window, outer_window = options.delete(:inner_window).to_i, options.delete(:outer_window).to_i - min = page - inner_window - max = page + inner_window - # adjust lower or upper limit if other is out of bounds - if max > total_pages then min -= max - total_pages - elsif min < 1 then max += 1 - min - end - - current = min..max - beginning = 1..(1 + outer_window) - tail = (total_pages - outer_window)..total_pages - visible = [beginning, current, tail].map(&:to_a).flatten.sort.uniq - links, prev = [], 0 - - visible.each do |n| - next if n < 1 - break if n > total_pages - - unless n - prev > 1 - prev = n - links << page_link_or_span((n != page ? n : nil), 'current', n, param) - else - # ellipsis represents the gap between windows - prev = n - 1 - links << '...' - redo - end - end - - # next and previous buttons - links.unshift page_link_or_span(entries.previous_page, 'disabled', options.delete(:prev_label), param) - links.push page_link_or_span(entries.next_page, 'disabled', options.delete(:next_label), param) - - content_tag :div, links.join(options.delete(:separator)), options - end - end - - protected - - def page_link_or_span(page, span_class, text, param) - unless page - content_tag :span, text, :class => span_class - else - # page links should preserve GET parameters, so we merge params - link_to text, params.merge(param.to_sym => (page !=1 ? page : nil)) - end - end - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb deleted file mode 100644 index c932f235..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/array_pagination_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -require File.dirname(__FILE__) + '/helper' -require File.dirname(__FILE__) + '/../init' - -class ArrayPaginationTest < ActiveRecordTestCase - def setup - @array = ('a'..'e').to_a - end - - cases = [ - { :current => 1, :per_page => 3, :expected => %w( a b c ) }, - { :current => 2, :per_page => 3, :expected => %w( d e ) }, - { :current => 1, :per_page => 5, :expected => %w( a b c d e ) }, - { :current => 3, :per_page => 5, :expected => [] }, - { :current => -1, :per_page => 5, :expected => [] }, - { :current => 1, :per_page => -5, :expected => [] } - ] - - cases.each_with_index do |conditions, index| - define_method("test_case_#{index}") do - assert_equal conditions[:expected], @array.paginate(conditions[:current], conditions[:per_page]) - end - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/boot.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/boot.rb deleted file mode 100644 index d142f3c3..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/boot.rb +++ /dev/null @@ -1,27 +0,0 @@ -plugin_root = File.join(File.dirname(__FILE__), '..') - -# first look for a symlink to a copy of the framework -if framework_root = ["#{plugin_root}/rails", "#{plugin_root}/../../rails"].find { |p| File.directory? p } - print "found framework root: #{framework_root}" - # this allows for a plugin to be tested outside an app - $:.unshift "#{framework_root}/activesupport/lib", "#{framework_root}/activerecord/lib", "#{framework_root}/actionpack/lib" -else - # is the plugin installed in an application? - app_root = plugin_root + '/../../..' - - if File.directory? app_root + '/config' - print 'using config/boot.rb' - ENV['RAILS_ENV'] = 'test' - require File.expand_path(app_root + '/config/boot') - else - # simply use installed gems if available - print 'using rubygems' - require 'rubygems' - gem 'actionpack'; gem 'activerecord' - end -end - -%w(action_pack active_record active_record/version action_controller active_record/fixtures).each {|f| require f} -puts " (ActiveRecord v#{ActiveRecord::VERSION::STRING})" - -$:.unshift "#{plugin_root}/lib" diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/console b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/console deleted file mode 100755 index e12034e9..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/console +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby -irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' -libs = [] -dirname = File.dirname(__FILE__) - -libs << 'irb/completion' -libs << File.join(dirname, 'lib', 'load_fixtures') -libs << File.join(dirname, '..', 'init') - -exec "#{irb} #{libs.map{|l| " -r #{l}" }.join} --simple-prompt" diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/finder_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/finder_test.rb deleted file mode 100644 index b69c4429..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/finder_test.rb +++ /dev/null @@ -1,219 +0,0 @@ -require File.dirname(__FILE__) + '/helper' -require File.dirname(__FILE__) + '/../init' - -class FinderTest < ActiveRecordTestCase - fixtures :topics, :replies, :users, :projects, :developers_projects, :companies - - def test_new_methods_presence - assert_respond_to_all Topic, %w(per_page paginate paginate_by_sql) - end - - def test_paginated_collection - entries = %w(a b c) - collection = WillPaginate::Collection.new 2, 3, 10 - collection.replace entries - - assert_equal entries, collection - assert_respond_to_all collection, %w(page_count each offset size current_page per_page total_entries) - assert_equal Array, collection.entries.class - assert_equal 3, collection.offset - end - - def test_simple_paginate - entries = Topic.paginate :page => nil - assert_equal 1, entries.current_page - assert_nil entries.previous_page - assert_nil entries.next_page - assert_equal 1, entries.page_count - assert_equal 4, entries.size - - entries = Topic.paginate :page => 2 - assert_equal 2, entries.current_page - assert_equal 1, entries.previous_page - assert_equal 1, entries.page_count - assert entries.empty? - - # :page parameter in options is required! - assert_raise(ArgumentError){ Topic.paginate } - assert_raise(ArgumentError){ Topic.paginate({}) } - end - - def test_paginate_with_per_page - entries = Topic.paginate :page => 1, :per_page => 1 - assert_equal 1, entries.size - assert_equal 4, entries.page_count - - # Developer class has explicit per_page at 10 - entries = Developer.paginate :page => 1 - assert_equal 10, entries.size - assert_equal 2, entries.page_count - - entries = Developer.paginate :page => 1, :per_page => 5 - assert_equal 11, entries.total_entries - assert_equal 5, entries.size - assert_equal 3, entries.page_count - end - - def test_paginate_with_order - entries = Topic.paginate :page => 1, :order => 'created_at desc' - expected = [topics(:futurama), topics(:harvey_birdman), topics(:rails), topics(:ar)].reverse - assert_equal expected, entries.to_a - assert_equal 1, entries.page_count - end - - def test_paginate_with_conditions - entries = Topic.paginate :page => 1, :conditions => ["created_at > ?", 30.minutes.ago] - expected = [topics(:rails), topics(:ar)] - assert_equal expected, entries.to_a - assert_equal 1, entries.page_count - end - - def test_paginate_associations - dhh = users :david - expected_name_ordered = [projects(:action_controller), projects(:active_record)] - expected_id_ordered = [projects(:active_record), projects(:action_controller)] - - # with association-specified order - entries = dhh.projects.paginate(:page => 1) - assert_equal expected_name_ordered, entries - assert_equal 2, entries.total_entries - - # with explicit order - entries = dhh.projects.paginate(:page => 1, :order => 'projects.id') - assert_equal expected_id_ordered, entries - assert_equal 2, entries.total_entries - - assert_nothing_raised { dhh.projects.find(:all, :order => 'projects.id', :limit => 4) } - entries = dhh.projects.paginate(:page => 1, :order => 'projects.id', :per_page => 4) - assert_equal expected_id_ordered, entries - - # has_many with implicit order - topic = Topic.find(1) - expected = [replies(:spam), replies(:witty_retort)] - assert_equal expected.map(&:id).sort, topic.replies.paginate(:page => 1).map(&:id).sort - assert_equal expected.reverse, topic.replies.paginate(:page => 1, :order => 'replies.id ASC') - end - - def test_paginate_with_joins - entries = Developer.paginate :page => 1, - :joins => 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id', - :conditions => 'project_id = 1' - assert_equal 2, entries.size - developer_names = entries.map { |d| d.name } - assert developer_names.include?('David') - assert developer_names.include?('Jamis') - - expected = entries.to_a - entries = Developer.paginate :page => 1, - :joins => 'LEFT JOIN developers_projects ON users.id = developers_projects.developer_id', - :conditions => 'project_id = 1', :count => { :select => "users.id" } - assert_equal expected, entries.to_a - end - - def test_paginate_with_include_and_order - entries = Topic.paginate \ - :page => 1, - :include => :replies, - :order => 'replies.created_at asc, topics.created_at asc', - :per_page => 10 - - expected = Topic.find :all, - :include => 'replies', - :order => 'replies.created_at asc, topics.created_at asc', - :limit => 10 - - assert_equal expected, entries.to_a - end - - def test_paginate_with_group - entries = Developer.paginate :page => 1, :per_page => 10, :group => 'salary' - expected = [ users(:david), users(:jamis), users(:dev_10), users(:poor_jamis) ].map(&:salary).sort - assert_equal expected, entries.map(&:salary).sort - end - - def test_paginate_with_dynamic_finder - expected = [replies(:witty_retort), replies(:spam)] - assert_equal expected, Reply.paginate_all_by_topic_id(1, :page => 1) - assert_equal expected, Reply.paginate_by_topic_id(1, :page => 1) - - entries = Developer.paginate :conditions => { :salary => 100000 }, :page => 1, :per_page => 5 - assert_equal 8, entries.total_entries - assert_equal entries, Developer.paginate_by_salary(100000, :page => 1, :per_page => 5) - - # dynamic finder + conditions - entries = Developer.paginate_by_salary(100000, :page => 1, - :conditions => ['id > ?', 6]) - assert_equal 4, entries.total_entries - assert_equal (7..10).to_a, entries.map(&:id) - - assert_raises RuntimeError do - Developer.paginate_by_inexistent_attribute 100000, :page => 1 - end - end - - def test_paginate_by_sql - assert_respond_to Developer, :paginate_by_sql - entries = Developer.paginate_by_sql ['select * from users where salary > ?', 80000], - :page => 2, :per_page => 3, :total_entries => 9 - - assert_equal (5..7).to_a, entries.map(&:id) - assert_equal 9, entries.total_entries - end - - def test_count_by_sql - entries = Developer.paginate_by_sql ['select * from users where salary > ?', 60000], - :page => 2, :per_page => 3 - - assert_equal 12, entries.total_entries - end - - def test_scoped_paginate - entries = - Developer.with_poor_ones do - Developer.paginate :page => 1 - end - - assert_equal 2, entries.size - assert_equal 2, entries.total_entries - end - - def test_edge_case_api_madness - # explicit :all should not break anything - assert_equal Topic.paginate(:page => nil), Topic.paginate(:all, :page => 1) - - # this is a little weird test for issue #37 - # the Topic model find and count methods accept an extra option, :foo - # this checks if that extra option was intact by our paginating finder - entries = Topic.paginate(:foo => 'bar', :page => 1) - assert_equal 'bar', entries.first - assert_equal 100, entries.total_entries - - # Are we on edge? Find out by testing find_all which was removed in [6998] - unless Developer.respond_to? :find_all - # AR finders also accept arrays of IDs - # (this was broken in Rails before [6912]) - entries = Developer.paginate((1..8).to_a, :per_page => 3, :page => 2) - assert_equal (4..6).to_a, entries.map(&:id) - assert_equal 8, entries.total_entries - end - end - - def test_count_doesnt_use_select_options - assert_nothing_raised do - Developer.paginate :select => 'users.*', :page => 1 - end - end - - def test_should_use_scoped_finders_if_present - companies = Company.paginate_best :all, :page => 1 - assert_equal 3, companies.total_entries - end - -protected - - def assert_respond_to_all object, methods - methods.each do |method| - [method.to_s, method.to_sym].each {|m| assert_respond_to object, m } - end - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/admin.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/admin.rb deleted file mode 100644 index 1d5e7f36..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/admin.rb +++ /dev/null @@ -1,3 +0,0 @@ -class Admin < User - has_many :companies, :finder_sql => 'SELECT * FROM companies' -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/companies.yml b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/companies.yml deleted file mode 100644 index 8f62fcbe..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/companies.yml +++ /dev/null @@ -1,24 +0,0 @@ -thirty_seven_signals: - id: 1 - name: 37Signals - rating: 4 - -TextDrive: - id: 2 - name: TextDrive - rating: 3 - -PlanetArgon: - id: 3 - name: Planet Argon - rating: 3 - -Google: - id: 4 - name: Google - rating: 5 - -Ionist: - id: 5 - name: Ioni.st - rating: 4 diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/company.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/company.rb deleted file mode 100644 index 8027e156..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/company.rb +++ /dev/null @@ -1,23 +0,0 @@ -class Company < ActiveRecord::Base - attr_protected :rating - set_sequence_name :companies_nonstd_seq - - validates_presence_of :name - def validate - errors.add('rating', 'rating should not be 2') if rating == 2 - end - - def self.with_best - with_scope :find => { :conditions => ['companies.rating > ?', 3] } do - yield - end - end - - def self.find_best(*args) - with_best { find(*args) } - end - - def self.calculate_best(*args) - with_best { calculate(*args) } - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/developer.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/developer.rb deleted file mode 100644 index 6650a980..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/developer.rb +++ /dev/null @@ -1,11 +0,0 @@ -class Developer < User - has_and_belongs_to_many :projects, :include => :topics, :order => 'projects.name' - - def self.with_poor_ones(&block) - with_scope :find => { :conditions => ['salary <= ?', 80000], :order => 'salary' } do - yield - end - end - - def self.per_page() 10 end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml deleted file mode 100644 index cee359c7..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/developers_projects.yml +++ /dev/null @@ -1,13 +0,0 @@ -david_action_controller: - developer_id: 1 - project_id: 2 - joined_on: 2004-10-10 - -david_active_record: - developer_id: 1 - project_id: 1 - joined_on: 2004-10-10 - -jamis_active_record: - developer_id: 2 - project_id: 1 \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/project.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/project.rb deleted file mode 100644 index 50949df6..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/project.rb +++ /dev/null @@ -1,4 +0,0 @@ -class Project < ActiveRecord::Base - has_and_belongs_to_many :developers, :uniq => true - has_many :topics -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/projects.yml b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/projects.yml deleted file mode 100644 index 02800c78..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/projects.yml +++ /dev/null @@ -1,7 +0,0 @@ -action_controller: - id: 2 - name: Active Controller - -active_record: - id: 1 - name: Active Record diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/replies.yml b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/replies.yml deleted file mode 100644 index 1330e53d..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/replies.yml +++ /dev/null @@ -1,20 +0,0 @@ -witty_retort: - id: 1 - topic_id: 1 - content: Birdman is better! - created_at: <%= 6.hours.ago.to_s(:db) %> - updated_at: nil - -another: - id: 2 - topic_id: 2 - content: Nuh uh! - created_at: <%= 1.hour.ago.to_s(:db) %> - updated_at: nil - -spam: - id: 3 - topic_id: 1 - content: Nice site! - created_at: <%= 1.hour.ago.to_s(:db) %> - updated_at: nil diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/reply.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/reply.rb deleted file mode 100644 index ea84042b..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/reply.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Reply < ActiveRecord::Base - belongs_to :topic, :include => [:replies] - - validates_presence_of :content -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/schema.sql b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/schema.sql deleted file mode 100644 index b025cb4b..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/schema.sql +++ /dev/null @@ -1,44 +0,0 @@ -CREATE TABLE 'companies' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'name' TEXT DEFAULT NULL, - 'rating' INTEGER DEFAULT 1 -); - -CREATE TABLE 'replies' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'content' text, - 'created_at' datetime, - 'updated_at' datetime, - 'topic_id' integer -); - -CREATE TABLE 'topics' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'project_id' INTEGER DEFAULT NULL, - 'title' varchar(255), - 'subtitle' varchar(255), - 'content' text, - 'created_at' datetime, - 'updated_at' datetime -); - -CREATE TABLE 'users' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'name' TEXT DEFAULT NULL, - 'salary' INTEGER DEFAULT 70000, - 'created_at' DATETIME DEFAULT NULL, - 'updated_at' DATETIME DEFAULT NULL, - 'type' TEXT DEFAULT NULL -); - -CREATE TABLE 'projects' ( - 'id' INTEGER PRIMARY KEY NOT NULL, - 'name' TEXT DEFAULT NULL -); - -CREATE TABLE 'developers_projects' ( - 'developer_id' INTEGER NOT NULL, - 'project_id' INTEGER NOT NULL, - 'joined_on' DATE DEFAULT NULL, - 'access_level' INTEGER DEFAULT 1 -); diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/topic.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/topic.rb deleted file mode 100644 index b95659cd..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/topic.rb +++ /dev/null @@ -1,19 +0,0 @@ -class Topic < ActiveRecord::Base - has_many :replies, :dependent => :destroy, :order => 'replies.created_at DESC' - belongs_to :project - - # pretend find and count were extended and accept an extra option - # if there is a :foo option, prepend its value to collection - def self.find(*args) - more = [] - more << args.last.delete(:foo) if args.last.is_a?(Hash) and args.last[:foo] - res = super - more.empty?? res : more + res - end - - # if there is a :foo option, always return 100 - def self.count(*args) - return 100 if args.last.is_a?(Hash) and args.last[:foo] - super - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/topics.yml b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/topics.yml deleted file mode 100644 index 0a269047..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/topics.yml +++ /dev/null @@ -1,30 +0,0 @@ -futurama: - id: 1 - title: Isnt futurama awesome? - subtitle: It really is, isnt it. - content: I like futurama - created_at: <%= 1.day.ago.to_s(:db) %> - updated_at: - -harvey_birdman: - id: 2 - title: Harvey Birdman is the king of all men - subtitle: yup - content: He really is - created_at: <%= 2.hours.ago.to_s(:db) %> - updated_at: - -rails: - id: 3 - project_id: 1 - title: Rails is nice - subtitle: It makes me happy - content: except when I have to hack internals to fix pagination. even then really. - created_at: <%= 20.minutes.ago.to_s(:db) %> - -ar: - id: 4 - project_id: 1 - title: ActiveRecord sometimes freaks me out - content: "I mean, what's the deal with eager loading?" - created_at: <%= 15.minutes.ago.to_s(:db) %> diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/user.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/user.rb deleted file mode 100644 index 4a57cf07..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/user.rb +++ /dev/null @@ -1,2 +0,0 @@ -class User < ActiveRecord::Base -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/users.yml b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/users.yml deleted file mode 100644 index ed2c03ae..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/fixtures/users.yml +++ /dev/null @@ -1,35 +0,0 @@ -david: - id: 1 - name: David - salary: 80000 - type: Developer - -jamis: - id: 2 - name: Jamis - salary: 150000 - type: Developer - -<% for digit in 3..10 %> -dev_<%= digit %>: - id: <%= digit %> - name: fixture_<%= digit %> - salary: 100000 - type: Developer -<% end %> - -poor_jamis: - id: 11 - name: Jamis - salary: 9000 - type: Developer - -admin: - id: 12 - name: admin - type: Admin - -goofy: - id: 13 - name: Goofy - type: Admin diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/helper.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/helper.rb deleted file mode 100644 index d64cd967..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/helper.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'test/unit' -require 'rubygems' - -# gem install redgreen for colored test output -begin require 'redgreen'; rescue LoadError; end - -dirname = File.dirname(__FILE__) -require File.join(dirname, 'boot') unless defined?(ActiveRecord) -require 'action_controller/test_process' -require File.join(dirname, 'lib', 'activerecord_test_connector') - -# add plugin's main lib dir to load paths -$:.unshift(File.join(dirname, '..', 'lib')).uniq! - -# Test case for inheritance -class ActiveRecordTestCase < Test::Unit::TestCase - # Set our fixture path - if ActiveRecordTestConnector.able_to_connect - self.fixture_path = File.join(File.dirname(__FILE__), 'fixtures') - self.use_transactional_fixtures = false - end - - def self.fixtures(*args) - super if ActiveRecordTestConnector.connected - end - - def run(*args) - super if ActiveRecordTestConnector.connected - end - - # Default so Test::Unit::TestCase doesn't complain - def test_truth - end -end - -ActiveRecordTestConnector.setup -ActionController::Routing::Routes.reload rescue nil -ActionController::Routing::Routes.draw do |map| - map.connect ':controller/:action/:id' -end - -ActionController::Base.perform_caching = false diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb deleted file mode 100644 index b8178f9a..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/lib/activerecord_test_connector.rb +++ /dev/null @@ -1,64 +0,0 @@ -class ActiveRecordTestConnector - cattr_accessor :able_to_connect - cattr_accessor :connected - - # Set our defaults - self.connected = false - self.able_to_connect = true - - def self.setup - unless self.connected || !self.able_to_connect - setup_connection - load_schema - require_fixture_models - self.connected = true - end - rescue Exception => e # errors from ActiveRecord setup - $stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}" - #$stderr.puts " #{e.backtrace.join("\n ")}\n" - self.able_to_connect = false - end - - private - - def self.setup_connection - if Object.const_defined?(:ActiveRecord) - defaults = { :database => ':memory:' } - # ActiveRecord::Base.logger = Logger.new STDOUT - - begin - options = defaults.merge :adapter => 'sqlite3', :timeout => 500 - ActiveRecord::Base.establish_connection(options) - ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options } - ActiveRecord::Base.connection - rescue Exception # errors from establishing a connection - $stderr.puts 'SQLite 3 unavailable; trying SQLite 2.' - options = defaults.merge :adapter => 'sqlite' - ActiveRecord::Base.establish_connection(options) - ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options } - ActiveRecord::Base.connection - end - - unless Object.const_defined?(:QUOTED_TYPE) - Object.send :const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type') - end - else - raise "Can't setup connection since ActiveRecord isn't loaded." - end - end - - # Load actionpack sqlite tables - def self.load_schema - ActiveRecord::Base.silence do - File.read(File.dirname(__FILE__) + "/../fixtures/schema.sql").split(';').each do |sql| - ActiveRecord::Base.connection.execute(sql) unless sql.blank? - end - end - end - - def self.require_fixture_models - models = Dir.glob(File.dirname(__FILE__) + "/../fixtures/*.rb") - models = (models.grep(/user.rb/) + models).uniq - models.each {|f| require f} - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/lib/load_fixtures.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/lib/load_fixtures.rb deleted file mode 100644 index 094bfd81..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/lib/load_fixtures.rb +++ /dev/null @@ -1,10 +0,0 @@ -dirname = File.dirname(__FILE__) -require File.join(dirname, '..', 'boot') -require File.join(dirname, 'activerecord_test_connector') - -# setup the connection -ActiveRecordTestConnector.setup - -# load all fixtures -fixture_path = File.join(dirname, '..', 'fixtures') -Fixtures.create_fixtures(fixture_path, ActiveRecord::Base.connection.tables) diff --git a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/pagination_test.rb b/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/pagination_test.rb deleted file mode 100644 index 8659f480..00000000 --- a/vendor/plugins/acts_as_ferret/doc/demo/vendor/plugins/will_paginate/test/pagination_test.rb +++ /dev/null @@ -1,136 +0,0 @@ -require File.dirname(__FILE__) + '/helper' -require File.dirname(__FILE__) + '/../init' - -class PaginationTest < ActiveRecordTestCase - fixtures :users - - class PaginationController < ActionController::Base - def list_developers - @developers = Developer.paginate :page => params[params[:param_name] || :page], - :per_page => (params[:per_page] || 4).to_i - - @options = params.except(:count, :order) - WillPaginate::ViewHelpers.pagination_options.keys.each { |key| params.delete key } - - render :inline => '<%= will_paginate @developers, @options %>' - end - - def no_pagination - @developers = Developer.paginate :page => params[:page], :per_page => 15 - render :inline => '<%= will_paginate @developers %>' - end - - protected - def rescue_errors(e) raise e end - def rescue_action(e) raise e end - end - - def setup - @controller = PaginationController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - super - end - - def test_will_paginate - get :list_developers - - entries = assigns :developers - assert entries - assert_equal 4, entries.size - - assert_select 'div.pagination', 1, 'no main DIV' do |el| - assert_select 'a[href]', 3 do |elements| - validate_page_numbers [2,3,2], elements - assert_select elements.last, ':last-child', "Next »" - end - assert_select 'span', 2 - assert_select 'span.disabled:first-child', "« Previous" - assert_select 'span.current', entries.current_page.to_s - end - end - - def test_will_paginate_with_options - get :list_developers, :page => 2, :class => 'will_paginate', :prev_label => 'Prev', :next_label => 'Next' - assert_response :success - - entries = assigns :developers - assert entries - assert_equal 4, entries.size - - assert_select 'div.will_paginate', 1, 'no main DIV' do - assert_select 'a[href]', 4 do |elements| - validate_page_numbers [nil,nil,3,3], elements - assert_select elements.first, 'a', "Prev" - assert_select elements.last, 'a', "Next" - end - assert_select 'span.current', entries.current_page.to_s - end - end - - def test_will_paginate_preserves_parameters - get :list_developers, :foo => { :bar => 'baz' } - assert_response :success - - assert_select 'div.pagination', 1, 'no main DIV' do - assert_select 'a[href]', 3 do |elements| - elements.each do |el| - assert_match /foo%5Bbar%5D=baz/, el['href'] - end - end - end - end - - def test_will_paginate_with_custom_page_param - get :list_developers, :developers_page => 2, :param_name => :developers_page - assert_response :success - - entries = assigns :developers - assert entries - assert_equal 4, entries.size - - assert_select 'div.pagination', 1, 'no main DIV' do - assert_select 'a[href]', 4 do |elements| - validate_page_numbers [nil,nil,3,3], elements, :developers_page - end - assert_select 'span.current', entries.current_page.to_s - end - end - - def test_will_paginate_windows - get :list_developers, :page => 6, :per_page => 1, :inner_window => 2 - assert_response :success - - entries = assigns :developers - assert entries - assert_equal 1, entries.size - - assert_select 'div.pagination', 1, 'no main DIV' do - assert_select 'a[href]', 10 do |elements| - validate_page_numbers [5,nil,2,4,5,7,8,10,11,7], elements - assert_select elements.first, 'a', "« Previous" - assert_select elements.last, 'a', "Next »" - end - assert_select 'span.current', entries.current_page.to_s - end - end - - def test_no_pagination - get :no_pagination - entries = assigns :developers - assert_equal 1, entries.page_count - assert_equal Developer.count, entries.size - - assert_select 'div', false - assert_equal '', @response.body - end - -protected - - def validate_page_numbers expected, links, param_name = :page - assert_equal(expected, links.map { |e| - e['href'] =~ /\W#{param_name}=([^&]*)/ - $1 ? $1.to_i : $1 - }) - end -end diff --git a/vendor/plugins/acts_as_ferret/doc/monit-example b/vendor/plugins/acts_as_ferret/doc/monit-example deleted file mode 100644 index a37c5ebe..00000000 --- a/vendor/plugins/acts_as_ferret/doc/monit-example +++ /dev/null @@ -1,22 +0,0 @@ -# monit configuration snippet to watch the Ferret DRb server shipped with -# acts_as_ferret -check process ferret with pidfile /path/to/ferret.pid - - # username is the user the drb server should be running as (It's good practice - # to run such services as a non-privileged user) - start program = "/bin/su -c 'cd /path/to/your/app/current/ && script/ferret_server -e production start' username" - stop program = "/bin/su -c 'cd /path/to/your/app/current/ && script/ferret_server -e production stop' username" - - # cpu usage boundaries - if cpu > 60% for 2 cycles then alert - if cpu > 90% for 5 cycles then restart - - # memory usage varies with index size and usage scenarios, so check how - # much memory your DRb server uses up usually and add some spare to that - # before enabling this rule: - # if totalmem > 50.0 MB for 5 cycles then restart - - # adjust port numbers according to your setup: - if failed port 9010 then alert - if failed port 9010 for 2 cycles then restart - group ferret diff --git a/vendor/plugins/acts_as_ferret/init.rb b/vendor/plugins/acts_as_ferret/init.rb deleted file mode 100644 index bc0deaec..00000000 --- a/vendor/plugins/acts_as_ferret/init.rb +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2006 Kasper Weibel Nielsen-Refs, Thomas Lockney, Jens Krämer -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require 'acts_as_ferret' - -config.after_initialize { ActsAsFerret::load_config } -config.to_prepare { ActsAsFerret::load_config } \ No newline at end of file diff --git a/vendor/plugins/acts_as_ferret/install.rb b/vendor/plugins/acts_as_ferret/install.rb deleted file mode 100644 index 2a28aa69..00000000 --- a/vendor/plugins/acts_as_ferret/install.rb +++ /dev/null @@ -1,18 +0,0 @@ -# acts_as_ferret install script -require 'fileutils' - -def install(file) - puts "Installing: #{file}" - target = File.join(File.dirname(__FILE__), '..', '..', '..', file) - if File.exists?(target) - puts "target #{target} already exists, skipping" - else - FileUtils.cp File.join(File.dirname(__FILE__), file), target - end -end - -install File.join( 'script', 'ferret_server' ) -install File.join( 'config', 'ferret_server.yml' ) - -puts IO.read(File.join(File.dirname(__FILE__), 'README')) - diff --git a/vendor/plugins/acts_as_ferret/lib/act_methods.rb b/vendor/plugins/acts_as_ferret/lib/act_methods.rb deleted file mode 100644 index 4a683fd5..00000000 --- a/vendor/plugins/acts_as_ferret/lib/act_methods.rb +++ /dev/null @@ -1,147 +0,0 @@ -module ActsAsFerret #:nodoc: - - # This module defines the acts_as_ferret method and is included into - # ActiveRecord::Base - module ActMethods - - - def reloadable?; false end - - # declares a class as ferret-searchable. - # - # ====options: - # fields:: names all fields to include in the index. If not given, - # all attributes of the class will be indexed. You may also give - # symbols pointing to instance methods of your model here, i.e. - # to retrieve and index data from a related model. - # - # additional_fields:: names fields to include in the index, in addition - # to those derived from the db scheme. use if you want - # to add custom fields derived from methods to the db - # fields (which will be picked by aaf). This option will - # be ignored when the fields option is given, in that - # case additional fields get specified there. - # - # if:: Can be set to a block that will be called with the record in question - # to determine if it should be indexed or not. - # - # index_dir:: declares the directory where to put the index for this class. - # The default is RAILS_ROOT/index/RAILS_ENV/CLASSNAME. - # The index directory will be created if it doesn't exist. - # - # reindex_batch_size:: reindexing is done in batches of this size, default is 1000 - # mysql_fast_batches:: set this to false to disable the faster mysql batching - # algorithm if this model uses a non-integer primary key named - # 'id' on MySQL. - # - # ferret:: Hash of Options that directly influence the way the Ferret engine works. You - # can use most of the options the Ferret::I class accepts here, too. Among the - # more useful are: - # - # or_default:: whether query terms are required by - # default (the default, false), or not (true) - # - # analyzer:: the analyzer to use for query parsing (default: nil, - # which means the ferret StandardAnalyzer gets used) - # - # default_field:: use to set one or more fields that are searched for query terms - # that don't have an explicit field list. This list should *not* - # contain any untokenized fields. If it does, you're asking - # for trouble (i.e. not getting results for queries having - # stop words in them). Aaf by default initializes the default field - # list to contain all tokenized fields. If you use :single_index => true, - # you really should set this option specifying your default field - # list (which should be equal in all your classes sharing the index). - # Otherwise you might get incorrect search results and you won't get - # any lazy loading of stored field data. - # - # For downwards compatibility reasons you can also specify the Ferret options in the - # last Hash argument. - def acts_as_ferret(options={}) - - extend ClassMethods - - include InstanceMethods - include MoreLikeThis::InstanceMethods - - if options[:rdig] - cattr_accessor :rdig_configuration - self.rdig_configuration = options[:rdig] - require 'rdig_adapter' - include ActsAsFerret::RdigAdapter - end - - unless included_modules.include?(ActsAsFerret::WithoutAR) - # set up AR hooks - after_create :ferret_create - after_update :ferret_update - after_destroy :ferret_destroy - end - - cattr_accessor :aaf_configuration - - # apply default config for rdig based models - if options[:rdig] - options[:fields] ||= { :title => { :boost => 3, :store => :yes }, - :content => { :store => :yes } } - end - - # name of this index - index_name = options.delete(:index) || self.name.underscore - - index = ActsAsFerret::register_class_with_index(self, index_name, options) - self.aaf_configuration = index.index_definition.dup - # logger.debug "configured index for class #{self.name}:\n#{aaf_configuration.inspect}" - - # update our copy of the global index config with options local to this class - aaf_configuration[:class_name] ||= self.name - aaf_configuration[:if] ||= options[:if] - - # add methods for retrieving field values - add_fields options[:fields] - add_fields options[:additional_fields] - add_fields aaf_configuration[:fields] - add_fields aaf_configuration[:additional_fields] - - end - - - protected - - - # helper to defines a method which adds the given field to a ferret - # document instance - def define_to_field_method(field, options = {}) - method_name = "#{field}_to_ferret" - return if instance_methods.include?(method_name) # already defined - aaf_configuration[:defined_fields] ||= {} - aaf_configuration[:defined_fields][field] = options - dynamic_boost = options[:boost] if options[:boost].is_a?(Symbol) - via = options[:via] || field - define_method(method_name.to_sym) do - val = begin - content_for_field_name(field, via, dynamic_boost) - rescue - logger.warn("Error retrieving value for field #{field}: #{$!}") - '' - end - logger.debug("Adding field #{field} with value '#{val}' to index") - val - end - end - - def add_fields(field_config) - if field_config.is_a? Hash - field_config.each_pair do |field, options| - define_to_field_method field, options - end - elsif field_config.respond_to?(:each) - field_config.each do |field| - define_to_field_method field - end - end - end - - end - -end diff --git a/vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb b/vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb deleted file mode 100644 index 94625fcb..00000000 --- a/vendor/plugins/acts_as_ferret/lib/acts_as_ferret.rb +++ /dev/null @@ -1,633 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright (c) 2006 Kasper Weibel Nielsen-Refs, Thomas Lockney, Jens Krämer -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require 'active_support' -require 'active_record' -require 'set' -require 'enumerator' -require 'ferret' - -require 'ferret_find_methods' -require 'remote_functions' -require 'blank_slate' -require 'bulk_indexer' -require 'ferret_extensions' -require 'act_methods' -require 'search_results' -require 'class_methods' -require 'ferret_result' -require 'instance_methods' -require 'without_ar' - -require 'multi_index' -require 'remote_multi_index' -require 'more_like_this' - -require 'index' -require 'local_index' -require 'remote_index' - -require 'ferret_server' - -require 'rdig_adapter' - -# The Rails ActiveRecord Ferret Mixin. -# -# This mixin adds full text search capabilities to any Rails model. -# -# The current version emerged from on the original acts_as_ferret plugin done by -# Kasper Weibel and a modified version done by Thomas Lockney, which both can be -# found on the Ferret Wiki: http://ferret.davebalmain.com/trac/wiki/FerretOnRails. -# -# basic usage: -# include the following in your model class (specifiying the fields you want to get indexed): -# acts_as_ferret :fields => [ :title, :description ] -# -# now you can use ModelClass.find_with_ferret(query) to find instances of your model -# whose indexed fields match a given query. All query terms are required by default, but -# explicit OR queries are possible. This differs from the ferret default, but imho is the more -# often needed/expected behaviour (more query terms result in less results). -# -# Released under the MIT license. -# -# Authors: -# Kasper Weibel Nielsen-Refs (original author) -# Jens Kraemer (active maintainer since 2006) -# -# -# == Global properties -# -# raise_drb_errors:: Set this to true if you want aaf to raise Exceptions -# in case the DRb server cannot be reached (in other word - behave like -# versions up to 0.4.3). Defaults to false so DRb exceptions -# are logged but not raised. Be sure to set up some -# monitoring so you still detect when your DRb server died for -# whatever reason. -# -# remote:: Set this to false to force acts_as_ferret into local (non-DRb) mode even if -# config/ferret_server.yml contains a section for the current RAILS_ENV -# Usually you won't need to touch this option - just configure DRb for -# production mode in ferret_server.yml. -# -module ActsAsFerret - - class ActsAsFerretError < StandardError; end - class IndexNotDefined < ActsAsFerretError; end - class IndexAlreadyDefined < ActsAsFerretError; end - - # global Hash containing all multi indexes created by all classes using the plugin - # key is the concatenation of alphabetically sorted names of the classes the - # searcher searches. - @@multi_indexes = Hash.new - def self.multi_indexes; @@multi_indexes end - - # global Hash containing the ferret indexes of all classes using the plugin - # key is the index name. - @@ferret_indexes = Hash.new - def self.ferret_indexes; @@ferret_indexes end - - # mapping from class name to index name - @@index_using_classes = {} - def self.index_using_classes; @@index_using_classes end - - @@logger = Logger.new "#{RAILS_ROOT}/log/acts_as_ferret.log" - @@logger.level = ActiveRecord::Base.logger.level rescue Logger::DEBUG - mattr_accessor :logger - - - # Default ferret configuration for index fields - DEFAULT_FIELD_OPTIONS = { - :store => :no, - :highlight => :yes, - :index => :yes, - :term_vector => :with_positions_offsets, - :boost => 1.0 - } - - @@raise_drb_errors = false - mattr_writer :raise_drb_errors - def self.raise_drb_errors?; @@raise_drb_errors end - - @@remote = nil - mattr_accessor :remote - def self.remote? - if @@remote.nil? - if ENV["FERRET_USE_LOCAL_INDEX"] || ActsAsFerret::Remote::Server.running - @@remote = false - else - @@remote = ActsAsFerret::Remote::Config.new.uri rescue false - end - if @@remote - logger.info "Will use remote index server which should be available at #{@@remote}" - else - logger.info "Will use local index." - end - end - @@remote - end - remote? - - - # Declares an index. - # - # Use this method to define your indexes in a global initializer (i.e. config/initializers/aaf.rb). - # This is especially useful if you want to have multiple classes share the same index for cross-model - # searching as you only need a single call to declare the index for all models. - # - # This method is also used internally to declare an index when you use the - # acts_as_ferret call inside your class (which in turn can be omitted if the initializer is used). - # Returns the created index instance. - # - # === Options are: - # - # +models+:: Hash of model classes and their per-class option hashes which should - # use this index. Any models mentioned here will automatically use - # the index, there is no need to explicitly call +acts_as_ferret+ in the - # model class definition. - def self.define_index(name, options = {}) - name = name.to_sym - pending_classes = nil - if ferret_indexes.has_key?(name) - # seems models have been already loaded. remove that index for now, - # re-register any already loaded classes later on. - idx = get_index(name) - pending_classes = idx.index_definition[:registered_models] - pending_classes_configs = idx.registered_models_config - idx.close - ferret_indexes.delete(name) - end - - index_definition = { - :index_dir => "#{ActsAsFerret::index_dir}/#{name}", - :name => name, - :single_index => false, - :reindex_batch_size => 1000, - :ferret => {}, - :ferret_fields => {}, # list of indexed fields that will be filled later - :enabled => true, # used for class-wide disabling of Ferret - :mysql_fast_batches => true, # turn off to disable the faster, id based batching mechanism for MySQL - :raise_drb_errors => false # handle DRb connection errors by default - }.update( options ) - - index_definition[:registered_models] = [] - - # build ferret configuration - index_definition[:ferret] = { - :or_default => false, - :handle_parse_errors => true, - :default_field => nil, # will be set later on - #:max_clauses => 512, - #:analyzer => Ferret::Analysis::StandardAnalyzer.new, - # :wild_card_downcase => true - }.update( options[:ferret] || {} ) - - index_definition[:user_default_field] = index_definition[:ferret][:default_field] - - unless remote? - ActsAsFerret::ensure_directory index_definition[:index_dir] - index_definition[:index_base_dir] = index_definition[:index_dir] - index_definition[:index_dir] = find_last_index_version(index_definition[:index_dir]) - logger.debug "using index in #{index_definition[:index_dir]}" - end - - # these properties are somewhat vital to the plugin and shouldn't - # be overwritten by the user: - index_definition[:ferret].update( - :key => :key, - :path => index_definition[:index_dir], - :auto_flush => true, # slower but more secure in terms of locking problems TODO disable when running in drb mode? - :create_if_missing => true - ) - - # field config - index_definition[:ferret_fields] = build_field_config( options[:fields] ) - index_definition[:ferret_fields].update build_field_config( options[:additional_fields] ) - - idx = ferret_indexes[name] = create_index_instance( index_definition ) - - # re-register early loaded classes - if pending_classes - pending_classes.each { |clazz| idx.register_class clazz, { :force_re_registration => true }.merge(pending_classes_configs[clazz]) } - end - - if models = options[:models] - models.each do |clazz, config| - clazz.send :include, ActsAsFerret::WithoutAR unless clazz.respond_to?(:acts_as_ferret) - clazz.acts_as_ferret config.merge(:index => name) - end - end - - return idx - end - - # called internally by the acts_as_ferret method - # - # returns the index - def self.register_class_with_index(clazz, index_name, options = {}) - index_name = index_name.to_sym - @@index_using_classes[clazz.name] = index_name - unless index = ferret_indexes[index_name] - # index definition on the fly - # default to all attributes of this class - options[:fields] ||= clazz.new.attributes.keys.map { |k| k.to_sym } - index = define_index index_name, options - end - index.register_class(clazz, options) - return index - end - - def self.load_config - # using require_dependency to make the reloading in dev mode work. - require_dependency "#{RAILS_ROOT}/config/aaf.rb" - ActsAsFerret::logger.info "loaded configuration file aaf.rb" - rescue LoadError - ensure - @aaf_config_loaded = true - end - - # returns the index with the given name. - def self.get_index(name) - name = name.to_sym rescue nil - unless ferret_indexes.has_key?(name) - if @aaf_config_loaded - raise IndexNotDefined.new(name.to_s) - else - load_config and return get_index name - end - end - ferret_indexes[name] - end - - # count hits for a query - def self.total_hits(query, models_or_index_name, options = {}) - options = add_models_to_options_if_necessary options, models_or_index_name - find_index(models_or_index_name).total_hits query, options - end - - # find ids of records - def self.find_ids(query, models_or_index_name, options = {}, &block) - options = add_models_to_options_if_necessary options, models_or_index_name - find_index(models_or_index_name).find_ids query, options, &block - end - - # returns an index instance suitable for searching/updating the named index. Will - # return a read only MultiIndex when multiple model classes are given that do not - # share the same physical index. - def self.find_index(models_or_index_name) - case models_or_index_name - when Symbol - get_index models_or_index_name - when String - get_index models_or_index_name.to_sym - else - get_index_for models_or_index_name - end - end - - # models_or_index_name may be an index name as declared in config/aaf.rb, - # a single class or an array of classes to limit search to these classes. - def self.find(query, models_or_index_name, options = {}, ar_options = {}) - models = case models_or_index_name - when Array - models_or_index_name - when Class - [ models_or_index_name ] - else - nil - end - index = find_index(models_or_index_name) - multi = (MultiIndexBase === index or index.shared?) - unless options[:per_page] - options[:limit] ||= ar_options.delete :limit - options[:offset] ||= ar_options.delete :offset - end - if options[:limit] || options[:per_page] - # need pagination - options[:page] = if options[:per_page] - options[:page] ? options[:page].to_i : 1 - else - nil - end - limit = options[:limit] || options[:per_page] - offset = options[:offset] || (options[:page] ? (options[:page] - 1) * limit : 0) - options.delete :offset - options[:limit] = :all - - if multi or ((ar_options[:conditions] || ar_options[:order]) && options[:sort]) - # do pagination as the last step after everything has been fetched - options[:late_pagination] = { :limit => limit, :offset => offset } - elsif ar_options[:conditions] or ar_options[:order] - # late limiting in AR call - unless limit == :all - ar_options[:limit] = limit - ar_options[:offset] = offset - end - else - options[:limit] = limit - options[:offset] = offset - end - end - ActsAsFerret::logger.debug "options: #{options.inspect}\nar_options: #{ar_options.inspect}" - total_hits, result = index.find_records query, options.merge(:models => models), ar_options - ActsAsFerret::logger.debug "Query: #{query}\ntotal hits: #{total_hits}, results delivered: #{result.size}" - SearchResults.new(result, total_hits, options[:page], options[:per_page]) - end - - def self.filter_include_list_for_model(model, include_options) - filtered_include_options = [] - include_options = Array(include_options) - include_options.each do |include_option| - filtered_include_options << include_option if model.reflections.has_key?(include_option.is_a?(Hash) ? include_option.keys[0].to_sym : include_option.to_sym) - end - return filtered_include_options - end - - # returns the index used by the given class. - # - # If multiple classes are given, either the single index shared by these - # classes, or a multi index (to be used for search only) across the indexes - # of all models, is returned. - def self.get_index_for(*classes) - classes.flatten! - raise ArgumentError.new("no class specified") unless classes.any? - classes.map!(&:constantize) unless Class === classes.first - logger.debug "index_for #{classes.inspect}" - index = if classes.size > 1 - indexes = classes.map { |c| get_index_for c }.uniq - indexes.size > 1 ? multi_index(indexes) : indexes.first - else - clazz = classes.first - clazz = clazz.superclass while clazz && !@@index_using_classes.has_key?(clazz.name) - get_index @@index_using_classes[clazz.name] - end - raise IndexNotDefined.new("no index found for class: #{classes.map(&:name).join(',')}") if index.nil? - return index - end - - - # creates a new Index instance. - def self.create_index_instance(definition) - (remote? ? RemoteIndex : LocalIndex).new(definition) - end - - def self.rebuild_index(name) - get_index(name).rebuild_index - end - - def self.change_index_dir(name, new_dir) - get_index(name).change_index_dir new_dir - end - - # find the most recent version of an index - def self.find_last_index_version(basedir) - # check for versioned index - versions = Dir.entries(basedir).select do |f| - dir = File.join(basedir, f) - File.directory?(dir) && File.file?(File.join(dir, 'segments')) && f =~ /^\d+(_\d+)?$/ - end - if versions.any? - # select latest version - versions.sort! - File.join basedir, versions.last - else - basedir - end - end - - # returns a MultiIndex instance operating on a MultiReader - def self.multi_index(indexes) - index_names = indexes.dup - index_names = index_names.map(&:to_s) if Symbol === index_names.first - if String === index_names.first - indexes = index_names.map{ |name| get_index name } - else - index_names = index_names.map{ |i| i.index_name.to_s } - end - key = index_names.sort.join(",") - ActsAsFerret::multi_indexes[key] ||= (remote? ? ActsAsFerret::RemoteMultiIndex : ActsAsFerret::MultiIndex).new(indexes) - end - - # check for per-model conditions and return these if provided - def self.conditions_for_model(model, conditions = {}) - if Hash === conditions - key = model.name.underscore.to_sym - conditions = conditions[key] - end - return conditions - end - - # check for per-model joins and return these if provided - def self.joins_for_model(model, joins = {}) - if Hash === joins - key = model.name.underscore.to_sym - joins = joins[key] - end - return joins - end - - # check for per-model select and return these if provided - def self.select_for_model(model, select = {}) - if Hash === select - key = model.name.underscore.to_sym - select = select[key] - end - return select - end - - # check for per-model order and return these if provided - def self.order_for_model(model, order = {}) - if Hash === order - key = model.name.underscore.to_sym - order = order[key] - end - return order - end - - # retrieves search result records from a data structure like this: - # { 'Model1' => { '1' => [ rank, score ], '2' => [ rank, score ] } - # - # TODO: in case of STI AR will filter out hits from other - # classes for us, but this - # will lead to less results retrieved --> scoping of ferret query - # to self.class is still needed. - # from the ferret ML (thanks Curtis Hatter) - # > I created a method in my base STI class so I can scope my query. For scoping - # > I used something like the following line: - # > - # > query << " role:#{self.class.eql?(Contents) '*' : self.class}" - # > - # > Though you could make it more generic by simply asking - # > "self.descends_from_active_record?" which is how rails decides if it should - # > scope your "find" query for STI models. You can check out "base.rb" in - # > activerecord to see that. - # but maybe better do the scoping in find_ids_with_ferret... - def self.retrieve_records(id_arrays, find_options = {}) - result = [] - # get objects for each model - id_arrays.each do |model, id_array| - next if id_array.empty? - # logger.debug "id array from index: #{id_array.inspect}" - - model_class = model.constantize - - # merge conditions - conditions = conditions_for_model model_class, find_options[:conditions] - conditions = combine_conditions([ "#{model_class.table_name}.#{model_class.primary_key} in (?)", - id_array.keys ], - conditions) - - # get joins - joins = joins_for_model model_class, find_options[:joins] - - # get select - select = select_for_model model_class, find_options[:select] - - # get order - order = order_for_model model_class, find_options[:order] - - # check for include association that might only exist on some models in case of multi_search - filtered_include_options = nil - if include_options = find_options[:include] - filtered_include_options = filter_include_list_for_model(model_class, include_options) - end - - # fetch - tmp_result = model_class.find(:all, find_options.merge(:conditions => conditions, - :joins => joins, - :select => select, - :order => order, - :include => filtered_include_options)) - - # set scores and rank - tmp_result.each do |record| - record.ferret_rank, record.ferret_score = id_array[record.id.to_s] - end - # merge with result array - result += tmp_result - end - - # order results as they were found by ferret, unless an AR :order - # option was given - # logger.debug "unsorted result: #{result.map{|a| "#{a.id} / #{a.title} / #{a.ferret_rank}"}.inspect}" - result.sort! { |a, b| a.ferret_rank <=> b.ferret_rank } unless find_options[:order] - # logger.debug "sorted result: #{result.map{|a| "#{a.id} / #{a.ferret_rank}"}.inspect}" - return result - end - - # combine our conditions with those given by user, if any - def self.combine_conditions(conditions, additional_conditions = []) - if additional_conditions && additional_conditions.any? - cust_opts = (Array === additional_conditions) ? additional_conditions.dup : [ additional_conditions ] - logger.debug "cust_opts: #{cust_opts.inspect}" - conditions.first << " and " << cust_opts.shift - conditions.concat(cust_opts) - end - return conditions - end - - def self.build_field_config(fields) - field_config = {} - case fields - when Array - fields.each { |name| field_config[name] = field_config_for name } - when Hash - fields.each { |name, options| field_config[name] = field_config_for name, options } - else raise InvalidArgumentError.new(":fields option must be Hash or Array") - end if fields - return field_config - end - - def self.ensure_directory(dir) - FileUtils.mkdir_p dir unless (File.directory?(dir) || File.symlink?(dir)) - end - - - # make sure the default index base dir exists. by default, all indexes are created - # under RAILS_ROOT/index/RAILS_ENV - def self.init_index_basedir - index_base = "#{RAILS_ROOT}/index" - @@index_dir = "#{index_base}/#{RAILS_ENV}" - end - - mattr_accessor :index_dir - init_index_basedir - - def self.append_features(base) - super - base.extend(ClassMethods) - end - - # builds a FieldInfos instance for creation of an index - def self.field_infos(index_definition) - # default attributes for fields - fi = Ferret::Index::FieldInfos.new(:store => :no, - :index => :yes, - :term_vector => :no, - :boost => 1.0) - # unique key composed of classname and id - fi.add_field(:key, :store => :no, :index => :untokenized) - # primary key - fi.add_field(:id, :store => :yes, :index => :untokenized) - # class_name - fi.add_field(:class_name, :store => :yes, :index => :untokenized) - - # other fields - index_definition[:ferret_fields].each_pair do |field, options| - options = options.dup - options.delete :via - options.delete :boost if options[:boost].is_a?(Symbol) # dynamic boost - fi.add_field(field, options) - end - return fi - end - - def self.close_multi_indexes - # close combined index readers, just in case - # this seems to fix a strange test failure that seems to relate to a - # multi_index looking at an old version of the content_base index. - multi_indexes.each_pair do |key, index| - # puts "#{key} -- #{self.name}" - # TODO only close those where necessary (watch inheritance, where - # self.name is base class of a class where key is made from) - index.close #if key =~ /#{self.name}/ - end - multi_indexes.clear - end - - protected - - def self.add_models_to_options_if_necessary(options, models_or_index_name) - return options if String === models_or_index_name or Symbol === models_or_index_name - options.merge(:models => models_or_index_name) - end - - def self.field_config_for(fieldname, options = {}) - config = DEFAULT_FIELD_OPTIONS.merge options - config[:via] ||= fieldname - config[:term_vector] = :no if config[:index] == :no - return config - end - -end - -# include acts_as_ferret method into ActiveRecord::Base -ActiveRecord::Base.extend ActsAsFerret::ActMethods - diff --git a/vendor/plugins/acts_as_ferret/lib/ar_mysql_auto_reconnect_patch.rb b/vendor/plugins/acts_as_ferret/lib/ar_mysql_auto_reconnect_patch.rb deleted file mode 100644 index 9f5de4ae..00000000 --- a/vendor/plugins/acts_as_ferret/lib/ar_mysql_auto_reconnect_patch.rb +++ /dev/null @@ -1,41 +0,0 @@ -# Source: http://pastie.caboo.se/154842 -# -# in /etc/my.cnf on the MySQL server, you can set the interactive-timeout parameter, -# for example, 12 hours = 28800 sec -# interactive-timeout=28800 - -# in ActiveRecord, setting the verification_timeout to something less than -# the interactive-timeout parameter; 14400 sec = 6 hours -ActiveRecord::Base.verification_timeout = 14400 -ActiveRecord::Base.establish_connection - -# Below is a monkey patch for keeping ActiveRecord connections alive. -# http://www.sparecycles.org/2007/7/2/saying-goodbye-to-lost-connections-in-rails - -module ActiveRecord - module ConnectionAdapters - class MysqlAdapter - def execute(sql, name = nil) #:nodoc: - reconnect_lost_connections = true - begin - log(sql, name) { @connection.query(sql) } - rescue ActiveRecord::StatementInvalid => exception - if reconnect_lost_connections and exception.message =~ /(Lost connection to MySQL server during query -|MySQL server has gone away)/ - reconnect_lost_connections = false - reconnect! - retry - elsif exception.message.split(":").first =~ /Packets out of order/ - raise ActiveRecord::StatementInvalid, "'Packets out of order' error was received from the database. - Please update your mysql bindings (gem install mysql) and read http://dev.mysql.com/doc/mysql/en/password-hash -ing.html for more information. If you're on Windows, use the Instant Rails installer to get the updated mysql -bindings." - else - raise - end - end - end - end - end -end - diff --git a/vendor/plugins/acts_as_ferret/lib/blank_slate.rb b/vendor/plugins/acts_as_ferret/lib/blank_slate.rb deleted file mode 100644 index 93e7be9a..00000000 --- a/vendor/plugins/acts_as_ferret/lib/blank_slate.rb +++ /dev/null @@ -1,54 +0,0 @@ -module ActsAsFerret - if defined?(BasicObject) - # Ruby 1.9.x - class BlankSlate < BasicObject - end - elsif defined?(BlankSlate) - # Rails 2.x has it already - class BlankSlate < ::BlankSlate - end - else - # 'backported' for Rails pre 2.0 - # - #-- - # Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org). - # All rights reserved. - - # Permission is granted for use, copying, modification, distribution, - # and distribution of modified versions of this work as long as the - # above copyright notice is included. - #++ - - ###################################################################### - # BlankSlate provides an abstract base class with no predefined - # methods (except for \_\_send__ and \_\_id__). - # BlankSlate is useful as a base class when writing classes that - # depend upon method_missing (e.g. dynamic proxies). - # - class BlankSlate - class << self - # Hide the method named +name+ in the BlankSlate class. Don't - # hide +instance_eval+ or any method beginning with "__". - def hide(name) - if instance_methods.include?(name.to_s) and name !~ /^(__|instance_eval|methods)/ - @hidden_methods ||= {} - @hidden_methods[name.to_sym] = instance_method(name) - undef_method name - end - end - - # Redefine a previously hidden method so that it may be called on a blank - # slate object. - # - # no-op here since we don't hide the methods we reveal where this is - # used in this implementation - def reveal(name) - end - end - - instance_methods.each { |m| hide(m) } - - end - - end -end diff --git a/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb b/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb deleted file mode 100644 index 282fa6be..00000000 --- a/vendor/plugins/acts_as_ferret/lib/bulk_indexer.rb +++ /dev/null @@ -1,56 +0,0 @@ -module ActsAsFerret - class BulkIndexer - def initialize(args = {}) - @batch_size = args[:batch_size] || 1000 - @logger = args[:logger] - @model = args[:model] - @work_done = 0 - @indexed_records = 0 - @total_time = 0.0 - @index = args[:index] - if args[:reindex] - @reindex = true - @model_count = @model.count.to_f - else - @model_count = args[:total] - end - end - - def index_records(records, offset) - batch_time = measure_time { - docs = [] - records.each { |rec| docs << [rec.to_doc, rec.ferret_analyzer] if rec.ferret_enabled?(true) } - @index.update_batch(docs) - }.to_f - rec_count = records.size - @indexed_records += rec_count - @total_time += batch_time - @work_done = @indexed_records.to_f / @model_count * 100.0 if @model_count > 0 - @logger.debug "took #{batch_time} to index last #{rec_count} records. #{records_waiting} records to go. Avg time per record: #{avg_time_per_record}" - remaining_time = avg_time_per_record * records_waiting - @logger.info "#{@reindex ? 're' : 'bulk '}index model #{@model.name} : #{'%.2f' % @work_done}% complete : #{'%.2f' % remaining_time} secs to finish" - end - - def measure_time - t1 = Time.now - yield - Time.now - t1 - end - - protected - - def avg_time_per_record - if @indexed_records > 0 - @total_time / @indexed_records - else - 0 - end - end - - def records_waiting - @model_count - @indexed_records - end - - end - -end diff --git a/vendor/plugins/acts_as_ferret/lib/class_methods.rb b/vendor/plugins/acts_as_ferret/lib/class_methods.rb deleted file mode 100644 index 0d9080cd..00000000 --- a/vendor/plugins/acts_as_ferret/lib/class_methods.rb +++ /dev/null @@ -1,267 +0,0 @@ -module ActsAsFerret - - module ClassMethods - - # Disables ferret index updates for this model. When a block is given, - # Ferret will be re-enabled again after executing the block. - def disable_ferret - aaf_configuration[:enabled] = false - if block_given? - yield - enable_ferret - end - end - - def enable_ferret - aaf_configuration[:enabled] = true - end - - def ferret_enabled? - aaf_configuration[:enabled] - end - - # rebuild the index from all data stored for this model, and any other - # model classes associated with the same index. - # This is called automatically when no index exists yet. - # - def rebuild_index - aaf_index.rebuild_index - end - - # re-index a number records specified by the given ids. Use for large - # indexing jobs i.e. after modifying a lot of records with Ferret disabled. - # Please note that the state of Ferret (enabled or disabled at class or - # record level) is not checked by this method, so if you need to do so - # (e.g. because of a custom ferret_enabled? implementation), you have to do - # so yourself. - def bulk_index(*ids) - options = Hash === ids.last ? ids.pop : {} - ids = ids.first if ids.size == 1 && ids.first.is_a?(Enumerable) - aaf_index.bulk_index(self.name, ids, options) - end - - # true if our db and table appear to be suitable for the mysql fast batch - # hack (see - # http://weblog.jamisbuck.org/2007/4/6/faking-cursors-in-activerecord) - def use_fast_batches? - if connection.class.name =~ /Mysql/ && primary_key == 'id' && aaf_configuration[:mysql_fast_batches] - logger.info "using mysql specific batched find :all. Turn off with :mysql_fast_batches => false if you encounter problems (i.e. because of non-integer UUIDs in the id column)" - true - end - end - - # Returns all records modified or created after the specified time. - # Used by the rake rebuild task to find models that need to be updated in - # the index after the rebuild finished because they changed while the - # rebuild was running. - # Override if your models don't stick to the created_at/updated_at - # convention. - def records_modified_since(time) - condition = [] - %w(updated_at created_at).each do |col| - condition << "#{col} >= ?" if column_names.include? col - end - if condition.empty? - logger.warn "#{self.name}: Override records_modified_since(time) to keep the index up to date with records changed during rebuild." - [] - else - find :all, :conditions => [ condition.join(' AND '), *([time]*condition.size) ] - end - end - - # runs across all records yielding those to be indexed when the index is rebuilt - def records_for_rebuild(batch_size = 1000) - transaction do - if use_fast_batches? - offset = 0 - while (rows = find :all, :conditions => [ "#{table_name}.id > ?", offset ], :limit => batch_size).any? - offset = rows.last.id - yield rows, offset - end - else - order = "#{primary_key} ASC" # fixes #212 - 0.step(self.count, batch_size) do |offset| - yield find( :all, :limit => batch_size, :offset => offset, :order => order ), offset - end - end - end - end - - # yields the records with the given ids, in batches of batch_size - def records_for_bulk_index(ids, batch_size = 1000) - transaction do - offset = 0 - ids.each_slice(batch_size) do |id_slice| - records = find( :all, :conditions => ["id in (?)", id_slice] ) - #yield records, offset - yield find( :all, :conditions => ["id in (?)", id_slice] ), offset - offset += batch_size - end - end - end - - # Retrieve the index instance for this model class. This can either be a - # LocalIndex, or a RemoteIndex instance. - # - def aaf_index - @index ||= ActsAsFerret::get_index(aaf_configuration[:name]) - end - - # Finds instances by searching the Ferret index. Terms are ANDed by default, use - # OR between terms for ORed queries. Or specify +:or_default => true+ in the - # +:ferret+ options hash of acts_as_ferret. - # - # You may either use the +offset+ and +limit+ options to implement your own - # pagination logic, or use the +page+ and +per_page+ options to use the - # built in pagination support which is compatible with will_paginate's view - # helpers. If +page+ and +per_page+ are given, +offset+ and +limit+ will be - # ignored. - # - # == options: - # page:: page of search results to retrieve - # per_page:: number of search results that are displayed per page - # offset:: first hit to retrieve (useful for paging) - # limit:: number of hits to retrieve, or :all to retrieve - # all results - # lazy:: Array of field names whose contents should be read directly - # from the index. Those fields have to be marked - # +:store => :yes+ in their field options. Give true to get all - # stored fields. Note that if you have a shared index, you have - # to explicitly state the fields you want to fetch, true won't - # work here) - # - # +find_options+ is a hash passed on to active_record's find when - # retrieving the data from db, useful to i.e. prefetch relationships with - # :include or to specify additional filter criteria with :conditions (only string and array syntax supported). - # You can also call find_with_ferret inside named or dynamic scopes, if you like the conditions hash syntax more. - # - # This method returns a +SearchResults+ instance, which really is an Array that has - # been decorated with a total_hits attribute holding the total number of hits. - # Additionally, SearchResults is compatible with the pagination helper - # methods of the will_paginate plugin. - # - # Please keep in mind that the number of results delivered might be less than - # +limit+ if you specify any active record conditions that further limit - # the result. Use +limit+ and +offset+ as AR find_options instead. - # +page+ and +per_page+ are supposed to work regardless of any - # +conditions+ present in +find_options+. - def find_with_ferret(q, options = {}, find_options = {}) - if respond_to?(:scope) && scope(:find, :conditions) - find_options[:conditions] ||= '1=1' # treat external scope the same as if :conditions present (i.e. when it comes to counting results) - end - return ActsAsFerret::find q, self, options, find_options - end - - - # Returns the total number of hits for the given query - # - # Note that since we don't query the database here, this method won't deliver - # the expected results when used on an AR association. - # - def total_hits(q, options={}) - aaf_index.total_hits(q, options) - end - - # Finds instance model name, ids and scores by contents. - # Useful e.g. if you want to search across models or do not want to fetch - # all result records (yet). - # - # Options are the same as for find_with_ferret - # - # A block can be given too, it will be executed with every result: - # find_ids_with_ferret(q, options) do |model, id, score| - # id_array << id - # scores_by_id[id] = score - # end - # NOTE: in case a block is given, only the total_hits value will be returned - # instead of the [total_hits, results] array! - # - def find_ids_with_ferret(q, options = {}, &block) - aaf_index.find_ids(q, options, &block) - end - - - protected - -# def find_records_lazy_or_not(q, options = {}, find_options = {}) -# if options[:lazy] -# logger.warn "find_options #{find_options} are ignored because :lazy => true" unless find_options.empty? -# lazy_find_by_contents q, options -# else -# ar_find_by_contents q, options, find_options -# end -# end -# -# def ar_find_by_contents(q, options = {}, find_options = {}) -# result_ids = {} -# total_hits = find_ids_with_ferret(q, options) do |model, id, score, data| -# # stores ids, index and score of each hit for later ordering of -# # results -# result_ids[id] = [ result_ids.size + 1, score ] -# end -# -# result = ActsAsFerret::retrieve_records( { self.name => result_ids }, find_options ) -# -# # count total_hits via sql when using conditions or when we're called -# # from an ActiveRecord association. -# if find_options[:conditions] or caller.find{ |call| call =~ %r{active_record/associations} } -# # chances are the ferret result count is not our total_hits value, so -# # we correct this here. -# if options[:limit] != :all || options[:page] || options[:offset] || find_options[:limit] || find_options[:offset] -# # our ferret result has been limited, so we need to re-run that -# # search to get the full result set from ferret. -# result_ids = {} -# find_ids_with_ferret(q, options.update(:limit => :all, :offset => 0)) do |model, id, score, data| -# result_ids[id] = [ result_ids.size + 1, score ] -# end -# # Now ask the database for the total size of the final result set. -# total_hits = count_records( { self.name => result_ids }, find_options ) -# else -# # what we got from the database is our full result set, so take -# # it's size -# total_hits = result.length -# end -# end -# -# [ total_hits, result ] -# end -# -# def lazy_find_by_contents(q, options = {}) -# logger.debug "lazy_find_by_contents: #{q}" -# result = [] -# rank = 0 -# total_hits = find_ids_with_ferret(q, options) do |model, id, score, data| -# logger.debug "model: #{model}, id: #{id}, data: #{data}" -# result << FerretResult.new(model, id, score, rank += 1, data) -# end -# [ total_hits, result ] -# end - - - def model_find(model, id, find_options = {}) - model.constantize.find(id, find_options) - end - - -# def count_records(id_arrays, find_options = {}) -# count_options = find_options.dup -# count_options.delete :limit -# count_options.delete :offset -# count = 0 -# id_arrays.each do |model, id_array| -# next if id_array.empty? -# model = model.constantize -# # merge conditions -# conditions = ActsAsFerret::combine_conditions([ "#{model.table_name}.#{model.primary_key} in (?)", id_array.keys ], -# find_options[:conditions]) -# opts = find_options.merge :conditions => conditions -# opts.delete :limit; opts.delete :offset -# count += model.count opts -# end -# count -# end - - end - -end - diff --git a/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb b/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb deleted file mode 100644 index 6d2c6963..00000000 --- a/vendor/plugins/acts_as_ferret/lib/ferret_extensions.rb +++ /dev/null @@ -1,192 +0,0 @@ -module Ferret - - module Analysis - - # = PerFieldAnalyzer - # - # This PerFieldAnalyzer is a workaround to a memory leak in - # ferret 0.11.4. It does basically do the same as the original - # Ferret::Analysis::PerFieldAnalyzer, but without the leak :) - # - # http://ferret.davebalmain.com/api/classes/Ferret/Analysis/PerFieldAnalyzer.html - # - # Thanks to Ben from omdb.org for tracking this down and creating this - # workaround. - # You can read more about the issue there: - # http://blog.omdb-beta.org/2007/7/29/tracking-down-a-memory-leak-in-ferret-0-11-4 - class PerFieldAnalyzer < ::Ferret::Analysis::Analyzer - def initialize( default_analyzer = StandardAnalyzer.new ) - @analyzers = {} - @default_analyzer = default_analyzer - end - - def add_field( field, analyzer ) - @analyzers[field] = analyzer - end - alias []= add_field - - def token_stream(field, string) - @analyzers.has_key?(field) ? @analyzers[field].token_stream(field, string) : - @default_analyzer.token_stream(field, string) - end - end - end - - class Index::Index - attr_accessor :batch_size, :logger - - def index_models(models) - models.each { |model| index_model model } - flush - optimize - close - ActsAsFerret::close_multi_indexes - end - - def index_model(model) - bulk_indexer = ActsAsFerret::BulkIndexer.new(:batch_size => @batch_size, :logger => logger, - :model => model, :index => self, :reindex => true) - logger.info "reindexing model #{model.name}" - - model.records_for_rebuild(@batch_size) do |records, offset| - bulk_indexer.index_records(records, offset) - end - end - - def bulk_index(model, ids, options = {}) - options.reverse_merge! :optimize => true - orig_flush = @auto_flush - @auto_flush = false - bulk_indexer = ActsAsFerret::BulkIndexer.new(:batch_size => @batch_size, :logger => logger, - :model => model, :index => self, :total => ids.size) - model.records_for_bulk_index(ids, @batch_size) do |records, offset| - logger.debug "#{model} bulk indexing #{records.size} at #{offset}" - bulk_indexer.index_records(records, offset) - end - logger.info 'finishing bulk index...' - flush - if options[:optimize] - logger.info 'optimizing...' - optimize - end - @auto_flush = orig_flush - end - - - # bulk-inserts a number of ferret documents. - # The argument has to be an array of two-element arrays each holding the document data and the analyzer to - # use for this document (which may be nil). - def update_batch(document_analyzer_pairs) - ids = document_analyzer_pairs.collect {|da| da.first[@id_field] } - @dir.synchronize do - batch_delete(ids) - ensure_writer_open() - document_analyzer_pairs.each do |doc, analyzer| - if analyzer - old_analyzer = @writer.analyzer - @writer.analyzer = analyzer - @writer.add_document(doc) - @writer.analyzer = old_analyzer - else - @writer.add_document(doc) - end - end - flush() - end - end - - # search for the first document with +arg+ in the +id+ field and return it's internal document number. - # The +id+ field is either :id or whatever you set - # :id_field parameter to when you create the Index object. - def doc_number(id) - @dir.synchronize do - ensure_reader_open() - term_doc_enum = @reader.term_docs_for(@id_field, id.to_s) - return term_doc_enum.next? ? term_doc_enum.doc : nil - end - end - - private - - - # If +docs+ is a Hash or an Array then a batch delete will be performed. - # If +docs+ is an Array then it will be considered an array of +id+'s. If - # it is a Hash, then its keys will be used instead as the Array of - # document +id+'s. If the +id+ is an Integers then it is considered a - # Ferret document number and the corresponding document will be deleted. - # If the +id+ is a String or a Symbol then the +id+ will be considered a - # term and the documents that contain that term in the +:id_field+ will - # be deleted. - # - # docs:: An Array of docs to be deleted, or a Hash (in which case the keys - # are used) - # - # ripped from Ferret trunk. - def batch_delete(docs) - docs = docs.keys if docs.is_a?(Hash) - raise ArgumentError, "must pass Array or Hash" unless docs.is_a? Array - ids = [] - terms = [] - docs.each do |doc| - case doc - when String then terms << doc - when Symbol then terms << doc.to_s - when Integer then ids << doc - else - raise ArgumentError, "Cannot delete for arg of type #{id.class}" - end - end - if ids.size > 0 - ensure_reader_open - ids.each {|id| @reader.delete(id)} - end - if terms.size > 0 - ensure_writer_open() - terms.each { |t| @writer.delete(@id_field, t) } - # TODO with Ferret trunk this would work: - # @writer.delete(@id_field, terms) - end - return self - end - - end - - # add marshalling support to SortFields - class Search::SortField - def _dump(depth) - to_s - end - - def self._load(string) - case string - when /!/ then Ferret::Search::SortField::DOC_ID_REV - when // then Ferret::Search::SortField::DOC_ID - when '!' then Ferret::Search::SortField::SCORE_REV - when '' then Ferret::Search::SortField::SCORE - when /^(\w+):<(\w+)>(!)?$/ then new($1.to_sym, :type => $2.to_sym, :reverse => !$3.nil?) - else raise "invalid value: #{string}" - end - end - end - - # add marshalling support to Sort - class Search::Sort - def _dump(depth) - to_s - end - - def self._load(string) - # we exclude the last sorting as it is appended by new anyway - if string =~ /^Sort\[(.*?)((!)?)?\]$/ - sort_fields = $1.split(',').map do |value| - value.strip! - Ferret::Search::SortField._load value unless value.blank? - end - new sort_fields.compact - else - raise "invalid value: #{string}" - end - end - end - -end diff --git a/vendor/plugins/acts_as_ferret/lib/ferret_find_methods.rb b/vendor/plugins/acts_as_ferret/lib/ferret_find_methods.rb deleted file mode 100644 index 26acaa33..00000000 --- a/vendor/plugins/acts_as_ferret/lib/ferret_find_methods.rb +++ /dev/null @@ -1,144 +0,0 @@ -module ActsAsFerret - # Ferret search logic common to single-class indexes, shared indexes and - # multi indexes. - module FerretFindMethods - - def find_records(q, options = {}, ar_options = {}) - late_pagination = options.delete :late_pagination - total_hits, result = if options[:lazy] - logger.warn "find_options #{ar_options} are ignored because :lazy => true" unless ar_options.empty? - lazy_find q, options - else - ar_find q, options, ar_options - end - if late_pagination - limit = late_pagination[:limit] - offset = late_pagination[:offset] || 0 - end_index = limit == :all ? -1 : limit+offset-1 - # puts "late pagination: #{offset} : #{end_index}" - result = result[offset..end_index] - end - return [total_hits, result] - end - - def lazy_find(q, options = {}) - logger.debug "lazy_find: #{q}" - result = [] - rank = 0 - total_hits = find_ids(q, options) do |model, id, score, data| - logger.debug "model: #{model}, id: #{id}, data: #{data}" - result << FerretResult.new(model, id, score, rank += 1, data) - end - [ total_hits, result ] - end - - def ar_find(q, options = {}, ar_options = {}) - ferret_options = options.dup - if ar_options[:conditions] or ar_options[:order] - ferret_options[:limit] = :all - ferret_options.delete :offset - end - total_hits, id_arrays = find_id_model_arrays q, ferret_options - logger.debug "now retrieving records from AR with options: #{ar_options.inspect}" - result = ActsAsFerret::retrieve_records(id_arrays, ar_options) - logger.debug "#{result.size} results from AR: #{result.inspect}" - - # count total_hits via sql when using conditions, multiple models, or when we're called - # from an ActiveRecord association. - if id_arrays.size > 1 or ar_options[:conditions] - # chances are the ferret result count is not our total_hits value, so - # we correct this here. - if options[:limit] != :all || options[:page] || options[:offset] || ar_options[:limit] || ar_options[:offset] - # our ferret result has been limited, so we need to re-run that - # search to get the full result set from ferret. - new_th, id_arrays = find_id_model_arrays( q, options.merge(:limit => :all, :offset => 0) ) - # Now ask the database for the total size of the final result set. - total_hits = count_records( id_arrays, ar_options ) - else - # what we got from the database is our full result set, so take - # it's size - total_hits = result.length - end - end - [ total_hits, result ] - end - - def count_records(id_arrays, ar_options = {}) - count_options = ar_options.dup - count_options.delete :limit - count_options.delete :offset - count_options.delete :order - count_options.delete :select - count = 0 - id_arrays.each do |model, id_array| - next if id_array.empty? - model = model.constantize - # merge conditions - conditions = ActsAsFerret::conditions_for_model model, ar_options[:conditions] - count_options[:conditions] = ActsAsFerret::combine_conditions([ "#{model.table_name}.#{model.primary_key} in (?)", id_array.keys ], conditions) - count_options[:joins] = ActsAsFerret::joins_for_model model, ar_options[:joins] - # count_options[:select] = ActsAsFerret::select_for_model model, ar_options[:select] - count_options[:include] = ActsAsFerret::filter_include_list_for_model(model, ar_options[:include]) if ar_options[:include] - cnt = model.count count_options - if cnt.is_a?(ActiveSupport::OrderedHash) # fixes #227 - count += cnt.size - else - count += cnt - end - end - count - end - - def find_id_model_arrays(q, options) - id_arrays = {} - rank = 0 - total_hits = find_ids(q, options) do |model, id, score, data| - id_arrays[model] ||= {} - id_arrays[model][id] = [ rank += 1, score ] - end - [total_hits, id_arrays] - end - - # Queries the Ferret index to retrieve model class, id, score and the - # values of any fields stored in the index for each hit. - # If a block is given, these are yielded and the number of total hits is - # returned. Otherwise [total_hits, result_array] is returned. - def find_ids(query, options = {}) - - result = [] - stored_fields = determine_stored_fields options - - q = process_query(query, options) - q = scope_query_to_models q, options[:models] #if shared? - logger.debug "query: #{query}\n-->#{q}" - s = searcher - total_hits = s.search_each(q, options) do |hit, score| - doc = s[hit] - model = doc[:class_name] - # fetch stored fields if lazy loading - data = extract_stored_fields(doc, stored_fields) - if block_given? - yield model, doc[:id], score, data - else - result << { :model => model, :id => doc[:id], :score => score, :data => data } - end - end - #logger.debug "id_score_model array: #{result.inspect}" - return block_given? ? total_hits : [total_hits, result] - end - - def scope_query_to_models(query, models) - return query if models.nil? or models == :all - models = [ models ] if Class === models - q = Ferret::Search::BooleanQuery.new - q.add_query(query, :must) - model_query = Ferret::Search::BooleanQuery.new - models.each do |model| - model_query.add_query(Ferret::Search::TermQuery.new(:class_name, model.name), :should) - end - q.add_query(model_query, :must) - return q - end - - end -end diff --git a/vendor/plugins/acts_as_ferret/lib/ferret_result.rb b/vendor/plugins/acts_as_ferret/lib/ferret_result.rb deleted file mode 100644 index 76ab4211..00000000 --- a/vendor/plugins/acts_as_ferret/lib/ferret_result.rb +++ /dev/null @@ -1,53 +0,0 @@ -module ActsAsFerret - - # mixed into the FerretResult and AR classes calling acts_as_ferret - module ResultAttributes - # holds the score this record had when it was found via - # acts_as_ferret - attr_accessor :ferret_score - - attr_accessor :ferret_rank - end - - class FerretResult < ActsAsFerret::BlankSlate - include ResultAttributes - attr_accessor :id - reveal :methods - - def initialize(model, id, score, rank, data = {}) - @model = model.constantize - @id = id - @ferret_score = score - @ferret_rank = rank - @data = data - @use_record = false - end - - def inspect - "# 'localhost', - 'port' => '9009', - 'cf' => "#{RAILS_ROOT}/config/ferret_server.yml", - 'pid_file' => "#{RAILS_ROOT}/log/ferret_server.pid", - 'log_file' => "#{RAILS_ROOT}/log/ferret_server.log", - 'log_level' => 'debug', - 'socket' => nil, - 'script' => nil - } - - ################################################################################ - # load the configuration file and apply default settings - def initialize (file=DEFAULTS['cf']) - @everything = YAML.load(ERB.new(IO.read(file)).result) - raise "malformed ferret server config" unless @everything.is_a?(Hash) - @config = DEFAULTS.merge(@everything[RAILS_ENV] || {}) - if @everything[RAILS_ENV] - @config['uri'] = socket.nil? ? "druby://#{host}:#{port}" : "drbunix:#{socket}" - end - end - - ################################################################################ - # treat the keys of the config data as methods - def method_missing (name, *args) - @config.has_key?(name.to_s) ? @config[name.to_s] : super - end - - end - - ################################################################################# - # This class acts as a drb server listening for indexing and - # search requests from models declared to 'acts_as_ferret :remote => true' - # - # Usage: - # - modify RAILS_ROOT/config/ferret_server.yml to suit your needs. - # - environments for which no section in the config file exists will use - # the index locally (good for unit tests/development mode) - # - run script/ferret_server to start the server: - # script/ferret_server -e production start - # - to stop the server run - # script/ferret_server -e production stop - # - class Server - - ################################################################################# - # FIXME include detection of OS and include the correct file - require 'unix_daemon' - include(ActsAsFerret::Remote::UnixDaemon) - - - ################################################################################ - cattr_accessor :running - - ################################################################################ - def initialize - ActiveRecord::Base.allow_concurrency = true - require 'ar_mysql_auto_reconnect_patch' - @cfg = ActsAsFerret::Remote::Config.new - ActiveRecord::Base.logger = @logger = Logger.new(@cfg.log_file) - ActiveRecord::Base.logger.level = Logger.const_get(@cfg.log_level.upcase) rescue Logger::DEBUG - if @cfg.script - path = File.join(RAILS_ROOT, @cfg.script) - load path - @logger.info "loaded custom startup script from #{path}" - end - end - - ################################################################################ - # start the server as a daemon process - def start - raise "ferret_server not configured for #{RAILS_ENV}" unless (@cfg.uri rescue nil) - platform_daemon { run_drb_service } - end - - ################################################################################ - # run the server and block until it exits - def run - raise "ferret_server not configured for #{RAILS_ENV}" unless (@cfg.uri rescue nil) - run_drb_service - end - - def run_drb_service - $stdout.puts("starting ferret server...") - self.class.running = true - DRb.start_service(@cfg.uri, self) - DRb.thread.join - rescue Exception => e - @logger.error(e.to_s) - raise - end - - ################################################################################# - # handles all incoming method calls, and sends them on to the correct local index - # instance. - # - # Calls are not queued, so this will block until the call returned. - # - def method_missing(name, *args) - @logger.debug "\#method_missing(#{name.inspect}, #{args.inspect})" - - - index_name = args.shift - index = if name.to_s =~ /^multi_(.+)/ - name = $1 - ActsAsFerret::multi_index(index_name) - else - ActsAsFerret::get_index(index_name) - end - - if index.nil? - @logger.error "\#index with name #{index_name} not found in call to #{name} with args #{args.inspect}" - raise ActsAsFerret::IndexNotDefined.new(index_name) - end - - - # TODO find another way to implement the reconnection logic (maybe in - # local_index or class_methods) - # reconnect_when_needed(clazz) do - - # using respond_to? here so we not have to catch NoMethodError - # which would silently catch those from deep inside the indexing - # code, too... - - if index.respond_to?(name) - index.send name, *args - # TODO check where we need this: - #elsif clazz.respond_to?(name) - # @logger.debug "no luck, trying to call class method instead" - # clazz.send name, *args - else - raise NoMethodError.new("method #{name} not supported by DRb server") - end - rescue => e - @logger.error "ferret server error #{$!}\n#{$!.backtrace.join "\n"}" - raise e - end - - def register_class(class_name) - @logger.debug "############ registerclass #{class_name}" - class_name.constantize - @logger.debug "index for class #{class_name}: #{ActsAsFerret::ferret_indexes[class_name.underscore.to_sym]}" - - end - - # make sure we have a versioned index in place, building one if necessary - def ensure_index_exists(index_name) - @logger.debug "DRb server: ensure_index_exists for index #{index_name}" - definition = ActsAsFerret::get_index(index_name).index_definition - dir = definition[:index_dir] - unless File.directory?(dir) && File.file?(File.join(dir, 'segments')) && dir =~ %r{/\d+(_\d+)?$} - rebuild_index(index_name) - end - end - - # disconnects the db connection for the class specified by class_name - # used only in unit tests to check the automatic reconnection feature - def db_disconnect!(class_name) - with_class class_name do |clazz| - clazz.connection.disconnect! - end - end - - # hides LocalIndex#rebuild_index to implement index versioning - def rebuild_index(index_name) - definition = ActsAsFerret::get_index(index_name).index_definition.dup - models = definition[:registered_models] - index = new_index_for(definition) - # TODO fix reconnection stuff - # reconnect_when_needed(clazz) do - # @logger.debug "DRb server: rebuild index for class(es) #{models.inspect} in #{index.options[:path]}" - index.index_models models - # end - new_version = File.join definition[:index_base_dir], Time.now.utc.strftime('%Y%m%d%H%M%S') - # create a unique directory name (needed for unit tests where - # multiple rebuilds per second may occur) - if File.exists?(new_version) - i = 0 - i+=1 while File.exists?("#{new_version}_#{i}") - new_version << "_#{i}" - end - - File.rename index.options[:path], new_version - ActsAsFerret::change_index_dir index_name, new_version - end - - - protected - - def reconnect_when_needed(clazz) - retried = false - begin - yield - rescue ActiveRecord::StatementInvalid => e - if e.message =~ /MySQL server has gone away/ - if retried - raise e - else - @logger.info "StatementInvalid caught, trying to reconnect..." - clazz.connection.reconnect! - retried = true - retry - end - else - @logger.error "StatementInvalid caught, but unsure what to do with it: #{e}" - raise e - end - end - end - - def new_index_for(index_definition) - ferret_cfg = index_definition[:ferret].dup - ferret_cfg.update :auto_flush => false, - :create => true, - :field_infos => ActsAsFerret::field_infos(index_definition), - :path => File.join(index_definition[:index_base_dir], 'rebuild') - Ferret::Index::Index.new(ferret_cfg).tap do |i| - i.batch_size = index_definition[:reindex_batch_size] - i.logger = @logger - end - end - - end - end -end diff --git a/vendor/plugins/acts_as_ferret/lib/index.rb b/vendor/plugins/acts_as_ferret/lib/index.rb deleted file mode 100644 index a779bf12..00000000 --- a/vendor/plugins/acts_as_ferret/lib/index.rb +++ /dev/null @@ -1,99 +0,0 @@ -module ActsAsFerret - - class IndexLogger - def initialize(logger, name) - @logger = logger - @index_name = name - end - %w(debug info warn error).each do |m| - define_method(m) do |message| - @logger.send m, "[#{@index_name}] #{message}" - end - question = :"#{m}?" - define_method(question) do - @logger.send question - end - end - end - - # base class for local and remote indexes - class AbstractIndex - include FerretFindMethods - - attr_reader :logger, :index_name, :index_definition, :registered_models_config - def initialize(index_definition) - @index_definition = index_definition - @registered_models_config = {} - @index_name = index_definition[:name] - @logger = IndexLogger.new(ActsAsFerret::logger, @index_name) - end - - # TODO allow for per-class field configuration (i.e. different via, boosts - # for the same field among different models) - def register_class(clazz, options = {}) - logger.info "register class #{clazz} with index #{index_name}" - - if force = options.delete(:force_re_registration) - index_definition[:registered_models].delete(clazz) - end - - if index_definition[:registered_models].map(&:name).include?(clazz.name) - logger.info("refusing re-registration of class #{clazz}") - else - index_definition[:registered_models] << clazz - @registered_models_config[clazz] = options - - # merge fields from this acts_as_ferret call with predefined fields - already_defined_fields = index_definition[:ferret_fields] - field_config = ActsAsFerret::build_field_config options[:fields] - field_config.update ActsAsFerret::build_field_config( options[:additional_fields] ) - field_config.each do |field, config| - if already_defined_fields.has_key?(field) - logger.info "ignoring redefinition of ferret field #{field}" if shared? - else - already_defined_fields[field] = config - logger.info "adding new field #{field} from class #{clazz.name} to index #{index_name}" - end - end - - # update default field list to be used by the query parser, unless it - # was explicitly given by user. - # - # It will include all content fields *not* marked as :untokenized. - # This fixes the otherwise failing CommentTest#test_stopwords. Basically - # this means that by default only tokenized fields (which all fields are - # by default) will be searched. If you want to search inside the contents - # of an untokenized field, you'll have to explicitly specify it in your - # query. - unless index_definition[:user_default_field] - # grab all tokenized fields - ferret_fields = index_definition[:ferret_fields] - index_definition[:ferret][:default_field] = ferret_fields.keys.select do |field| - ferret_fields[field][:index] != :untokenized - end - logger.info "default field list for index #{index_name}: #{index_definition[:ferret][:default_field].inspect}" - end - end - - return index_definition - end - - # true if this index is used by more than one model class - def shared? - index_definition[:registered_models].size > 1 - end - - # Switches the index to a new index directory. - # Used by the DRb server when switching to a new index version. - def change_index_dir(new_dir) - logger.debug "[#{index_name}] changing index dir to #{new_dir}" - index_definition[:index_dir] = index_definition[:ferret][:path] = new_dir - reopen! - logger.debug "[#{index_name}] index dir is now #{new_dir}" - end - - protected - - end - -end diff --git a/vendor/plugins/acts_as_ferret/lib/instance_methods.rb b/vendor/plugins/acts_as_ferret/lib/instance_methods.rb deleted file mode 100644 index 876e7880..00000000 --- a/vendor/plugins/acts_as_ferret/lib/instance_methods.rb +++ /dev/null @@ -1,172 +0,0 @@ -module ActsAsFerret #:nodoc: - - module InstanceMethods - include ResultAttributes - - # Returns an array of strings with the matches highlighted. The +query+ can - # either be a String or a Ferret::Search::Query object. - # - # === Options - # - # field:: field to take the content from. This field has - # to have it's content stored in the index - # (:store => :yes in your call to aaf). If not - # given, all stored fields are searched, and the - # highlighted content found in all of them is returned. - # set :highlight => :no in the field options to - # avoid highlighting of contents from a :stored field. - # excerpt_length:: Default: 150. Length of excerpt to show. Highlighted - # terms will be in the centre of the excerpt. - # num_excerpts:: Default: 2. Number of excerpts to return. - # pre_tag:: Default: "". Tag to place to the left of the - # match. - # post_tag:: Default: "". This tag should close the - # +:pre_tag+. - # ellipsis:: Default: "...". This is the string that is appended - # at the beginning and end of excerpts (unless the - # excerpt hits the start or end of the field. You'll - # probably want to change this to a Unicode elipsis - # character. - def highlight(query, options = {}) - self.class.aaf_index.highlight(self.ferret_key, query, options) - end - - # re-eneable ferret indexing for this instance after a call to #disable_ferret - def enable_ferret - @ferret_disabled = nil - end - alias ferret_enable enable_ferret # compatibility - - # returns true if ferret indexing is enabled for this record. - # - # The optional is_bulk_index parameter will be true if the method is called - # by rebuild_index or bulk_index, and false otherwise. - # - # If is_bulk_index is true, the class level ferret_enabled state will be - # ignored by this method (per-instance ferret_enabled checks however will - # take place, so if you override this method to forbid indexing of certain - # records you're still safe). - def ferret_enabled?(is_bulk_index = false) - @ferret_disabled.nil? && (is_bulk_index || self.class.ferret_enabled?) && (aaf_configuration[:if].nil? || aaf_configuration[:if].call(self)) - end - - # Returns the analyzer to use when adding this record to the index. - # - # Override to return a specific analyzer for any record that is to be - # indexed, i.e. specify a different analyzer based on language. Returns nil - # by default so the global analyzer (specified with the acts_as_ferret - # call) is used. - def ferret_analyzer - nil - end - - # Disable Ferret for this record for a specified amount of time. ::once will - # disable Ferret for the next call to #save (this is the default), ::always - # will do so for all subsequent calls. - # - # Note that this will turn off only the create and update hooks, but not the - # destroy hook. I think that's reasonable, if you think the opposite, please - # tell me. - # - # To manually trigger reindexing of a record after you're finished modifying - # it, you can call #ferret_update directly instead of #save (remember to - # enable ferret again before). - # - # When given a block, this will be executed without any ferret indexing of - # this object taking place. The optional argument in this case can be used - # to indicate if the object should be indexed after executing the block - # (::index_when_finished). Automatic Ferret indexing of this object will be - # turned on after the block has been executed. If passed ::index_when_true, - # the index will only be updated if the block evaluated not to false or nil. - # - def disable_ferret(option = :once) - if block_given? - @ferret_disabled = :always - result = yield - ferret_enable - ferret_update if option == :index_when_finished || (option == :index_when_true && result) - result - elsif [:once, :always].include?(option) - @ferret_disabled = option - else - raise ArgumentError.new("Invalid Argument #{option}") - end - end - - # add to index - def ferret_create - if ferret_enabled? - logger.debug "ferret_create/update: #{self.ferret_key}" - self.class.aaf_index << self - else - ferret_enable if @ferret_disabled == :once - end - true # signal success to AR - end - alias :ferret_update :ferret_create - - - # remove from index - def ferret_destroy - logger.debug "ferret_destroy: #{self.ferret_key}" - begin - self.class.aaf_index.remove self.ferret_key - rescue - logger.warn("Could not find indexed value for this object: #{$!}\n#{$!.backtrace}") - end - true # signal success to AR - end - - def ferret_key - "#{self.class.name}-#{self.send self.class.primary_key}" unless new_record? - end - - # turn this instance into a ferret document (which basically is a hash of - # fieldname => value pairs) - def to_doc - logger.debug "creating doc for class: #{self.ferret_key}" - Ferret::Document.new.tap do |doc| - # store the id and class name of each item, and the unique key used for identifying the record - # even in multi-class indexes. - doc[:key] = self.ferret_key - doc[:id] = self.id.to_s - doc[:class_name] = self.class.name - - # iterate through the fields and add them to the document - aaf_configuration[:defined_fields].each_pair do |field, config| - doc[field] = self.send("#{field}_to_ferret") unless config[:ignore] - end - if aaf_configuration[:boost] - if self.respond_to?(aaf_configuration[:boost]) - boost = self.send aaf_configuration[:boost] - doc.boost = boost.to_i if boost - else - logger.error "boost option should point to an instance method: #{aaf_configuration[:boost]}" - end - end - end - end - - def document_number - self.class.aaf_index.document_number(self.ferret_key) - end - - def query_for_record - self.class.aaf_index.query_for_record(self.ferret_key) - end - - def content_for_field_name(field, via = field, dynamic_boost = nil) - field_data = (respond_to?(via) ? send(via) : instance_variable_get("@#{via}")) - field_data = (field_data.is_a?(Array) ? field_data.map{|d| d.to_s} : field_data.to_s) - # field_data = self.send(via) || self.instance_variable_get("@#{via}") - if (dynamic_boost && boost_value = self.send(dynamic_boost)) - field_data = Ferret::Field.new(field_data) - field_data.boost = boost_value.to_i - end - field_data - end - - - end - -end diff --git a/vendor/plugins/acts_as_ferret/lib/local_index.rb b/vendor/plugins/acts_as_ferret/lib/local_index.rb deleted file mode 100644 index 1fc253ac..00000000 --- a/vendor/plugins/acts_as_ferret/lib/local_index.rb +++ /dev/null @@ -1,202 +0,0 @@ -module ActsAsFerret - class LocalIndex < AbstractIndex - include MoreLikeThis::IndexMethods - - def initialize(index_name) - super - ensure_index_exists - end - - def reopen! - logger.debug "reopening index at #{index_definition[:ferret][:path]}" - close - ferret_index - end - - # The 'real' Ferret Index instance - def ferret_index - ensure_index_exists - (@ferret_index ||= Ferret::Index::Index.new(index_definition[:ferret])).tap do |idx| - idx.batch_size = index_definition[:reindex_batch_size] - idx.logger = logger - end - end - - # Checks for the presence of a segments file in the index directory - # Rebuilds the index if none exists. - def ensure_index_exists - #logger.debug "LocalIndex: ensure_index_exists at #{index_definition[:index_dir]}" - unless File.file? "#{index_definition[:index_dir]}/segments" - ActsAsFerret::ensure_directory(index_definition[:index_dir]) - rebuild_index - end - end - - # Closes the underlying index instance - def close - @ferret_index.close if @ferret_index - rescue StandardError - # is raised when index already closed - ensure - @ferret_index = nil - end - - # rebuilds the index from all records of the model classes associated with this index - def rebuild_index - models = index_definition[:registered_models] - logger.debug "rebuild index with models: #{models.inspect}" - close - index = Ferret::Index::Index.new(index_definition[:ferret].dup.update(:auto_flush => false, - :field_infos => ActsAsFerret::field_infos(index_definition), - :create => true)) - index.batch_size = index_definition[:reindex_batch_size] - index.logger = logger - index.index_models models - reopen! - end - - def bulk_index(class_name, ids, options) - ferret_index.bulk_index(class_name.constantize, ids, options) - end - - # Parses the given query string into a Ferret Query object. - def process_query(query, options = {}) - return query unless String === query - ferret_index.synchronize do - if options[:analyzer] - # use per-query analyzer if present - qp = Ferret::QueryParser.new ferret_index.instance_variable_get('@options').merge(options) - reader = ferret_index.reader - qp.fields = - reader.fields unless options[:all_fields] || options[:fields] - qp.tokenized_fields = - reader.tokenized_fields unless options[:tokenized_fields] - return qp.parse query - else - return ferret_index.process_query(query) - end - end - end - - # Total number of hits for the given query. - def total_hits(query, options = {}) - ferret_index.search(process_query(query, options), options).total_hits - end - - def searcher - ferret_index - end - - - ###################################### - # methods working on a single record - # called from instance_methods, here to simplify interfacing with the - # remote ferret server - # TODO having to pass id and class_name around like this isn't nice - ###################################### - - # add record to index - # record may be the full AR object, a Ferret document instance or a Hash - def add(record, analyzer = nil) - unless Hash === record || Ferret::Document === record - analyzer = record.ferret_analyzer - record = record.to_doc - end - ferret_index.add_document(record, analyzer) - end - alias << add - - # delete record from index - def remove(key) - ferret_index.delete key - end - - # highlight search terms for the record with the given id. - def highlight(key, query, options = {}) - logger.debug("highlight: #{key} query: #{query}") - options.reverse_merge! :num_excerpts => 2, :pre_tag => '', :post_tag => '' - highlights = [] - ferret_index.synchronize do - doc_num = document_number(key) - - if options[:field] - highlights << ferret_index.highlight(query, doc_num, options) - else - query = process_query(query) # process only once - index_definition[:ferret_fields].each_pair do |field, config| - next if config[:store] == :no || config[:highlight] == :no - options[:field] = field - highlights << ferret_index.highlight(query, doc_num, options) - end - end - end - return highlights.compact.flatten[0..options[:num_excerpts]-1] - end - - # retrieves the ferret document number of the record with the given key. - def document_number(key) - docnum = ferret_index.doc_number(key) - # hits = ferret_index.search query_for_record(key) - # return hits.hits.first.doc if hits.total_hits == 1 - raise "cannot determine document number for record #{key}" if docnum.nil? - docnum - end - - # build a ferret query matching only the record with the given id - # the class name only needs to be given in case of a shared index configuration - def query_for_record(key) - return Ferret::Search::TermQuery.new(:key, key.to_s) - # if shared? - # raise InvalidArgumentError.new("shared index needs class_name argument") if class_name.nil? - # Ferret::Search::BooleanQuery.new.tap do |bq| - # bq.add_query(Ferret::Search::TermQuery.new(:id, id.to_s), :must) - # bq.add_query(Ferret::Search::TermQuery.new(:class_name, class_name), :must) - # end - # else - # Ferret::Search::TermQuery.new(:id, id.to_s) - # end - end - - - # retrieves stored fields from index definition in case the fields to retrieve - # haven't been specified with the :lazy option - def determine_stored_fields(options = {}) - stored_fields = options[:lazy] - if stored_fields && !(Array === stored_fields) - stored_fields = index_definition[:ferret_fields].select { |field, config| config[:store] == :yes }.map(&:first) - end - logger.debug "stored_fields: #{stored_fields.inspect}" - return stored_fields - end - - # loads data for fields declared as :lazy from the Ferret document - def extract_stored_fields(doc, stored_fields) - data = {} - unless stored_fields.nil? - logger.debug "extracting stored fields #{stored_fields.inspect} from document #{doc[:class_name]} / #{doc[:id]}" - fields = index_definition[:ferret_fields] - stored_fields.each do |field| - if field_cfg = fields[field] - data[field_cfg[:via]] = doc[field] - end - end - logger.debug "done: #{data.inspect}" - end - return data - end - - protected - - # returns a MultiIndex instance operating on a MultiReader - #def multi_index(model_classes) - # model_classes.map!(&:constantize) if String === model_classes.first - # model_classes.sort! { |a, b| a.name <=> b.name } - # key = model_classes.inject("") { |s, clazz| s + clazz.name } - # multi_config = index_definition[:ferret].dup - # multi_config.delete :default_field # we don't want the default field list of *this* class for multi_searching - # ActsAsFerret::multi_indexes[key] ||= MultiIndex.new(model_classes, multi_config) - #end - - end - -end diff --git a/vendor/plugins/acts_as_ferret/lib/more_like_this.rb b/vendor/plugins/acts_as_ferret/lib/more_like_this.rb deleted file mode 100644 index 28ff3130..00000000 --- a/vendor/plugins/acts_as_ferret/lib/more_like_this.rb +++ /dev/null @@ -1,217 +0,0 @@ -module ActsAsFerret #:nodoc: - - module MoreLikeThis - - module InstanceMethods - - # returns other instances of this class, which have similar contents - # like this one. Basically works like this: find out n most interesting - # (i.e. characteristic) terms from this document, and then build a - # query from those which is run against the whole index. Which terms - # are interesting is decided on variour criteria which can be - # influenced by the given options. - # - # The algorithm used here is a quite straight port of the MoreLikeThis class - # from Apache Lucene. - # - # options are: - # :field_names : Array of field names to use for similarity search (mandatory) - # :min_term_freq => 2, # Ignore terms with less than this frequency in the source doc. - # :min_doc_freq => 5, # Ignore words which do not occur in at least this many docs - # :min_word_length => nil, # Ignore words shorter than this length (longer words tend to - # be more characteristic for the document they occur in). - # :max_word_length => nil, # Ignore words if greater than this len. - # :max_query_terms => 25, # maximum number of terms in the query built - # :max_num_tokens => 5000, # maximum number of tokens to examine in a single field - # :boost => false, # when true, a boost according to the relative score of - # a term is applied to this Term's TermQuery. - # :similarity => 'DefaultAAFSimilarity' # the similarity implementation to use (the default - # equals Ferret's internal similarity implementation) - # :analyzer => 'Ferret::Analysis::StandardAnalyzer' # class name of the analyzer to use - # :append_to_query => nil # proc taking a query object as argument, which will be called after generating the query. can be used to further manipulate the query used to find related documents, i.e. to constrain the search to a given class in single table inheritance scenarios - # ferret_options : Ferret options handed over to find_with_ferret (i.e. for limits and sorting) - # ar_options : options handed over to find_with_ferret for AR scoping - def more_like_this(options = {}, ferret_options = {}, ar_options = {}) - options = { - :field_names => nil, # Default field names - :min_term_freq => 2, # Ignore terms with less than this frequency in the source doc. - :min_doc_freq => 5, # Ignore words which do not occur in at least this many docs - :min_word_length => 0, # Ignore words if less than this len. Default is not to ignore any words. - :max_word_length => 0, # Ignore words if greater than this len. Default is not to ignore any words. - :max_query_terms => 25, # maximum number of terms in the query built - :max_num_tokens => 5000, # maximum number of tokens to analyze when analyzing contents - :boost => false, - :similarity => 'ActsAsFerret::MoreLikeThis::DefaultAAFSimilarity', # class name of the similarity implementation to use - :analyzer => 'Ferret::Analysis::StandardAnalyzer', # class name of the analyzer to use - :append_to_query => nil, - :base_class => self.class # base class to use for querying, useful in STI scenarios where BaseClass.find_with_ferret can be used to retrieve results from other classes, too - }.update(options) - #index.search_each('id:*') do |doc, score| - # puts "#{doc} == #{index[doc][:description]}" - #end - clazz = options[:base_class] - options[:base_class] = clazz.name - query = clazz.aaf_index.build_more_like_this_query(self.ferret_key, self.id, options) - options[:append_to_query].call(query) if options[:append_to_query] - clazz.find_with_ferret(query, ferret_options, ar_options) - end - - end - - module IndexMethods - - # TODO to allow morelikethis for unsaved records, we have to give the - # unsaved record's data to this method. check how this will work out - # via drb... - def build_more_like_this_query(key, id, options) - [:similarity, :analyzer].each { |sym| options[sym] = options[sym].constantize.new } - ferret_index.synchronize do # avoid that concurrent writes close our reader - ferret_index.send(:ensure_reader_open) - reader = ferret_index.send(:reader) - term_freq_map = retrieve_terms(key, id, reader, options) - priority_queue = create_queue(term_freq_map, reader, options) - create_query(key, priority_queue, options) - end - end - - protected - - def create_query(key, priority_queue, options={}) - query = Ferret::Search::BooleanQuery.new - qterms = 0 - best_score = nil - while(cur = priority_queue.pop) - term_query = Ferret::Search::TermQuery.new(cur.field, cur.word) - - if options[:boost] - # boost term according to relative score - # TODO untested - best_score ||= cur.score - term_query.boost = cur.score / best_score - end - begin - query.add_query(term_query, :should) - rescue Ferret::Search::BooleanQuery::TooManyClauses - break - end - qterms += 1 - break if options[:max_query_terms] > 0 && qterms >= options[:max_query_terms] - end - # exclude the original record - query.add_query(query_for_record(key), :must_not) - return query - end - - - - # creates a term/term_frequency map for terms from the fields - # given in options[:field_names] - def retrieve_terms(key, id, reader, options) - raise "more_like_this atm only works on saved records" if key.nil? - document_number = document_number(key) rescue nil - field_names = options[:field_names] - max_num_tokens = options[:max_num_tokens] - term_freq_map = Hash.new(0) - doc = nil - record = nil - field_names.each do |field| - #puts "field: #{field}" - term_freq_vector = reader.term_vector(document_number, field) if document_number - #if false - if term_freq_vector - # use stored term vector - # puts 'using stored term vector' - term_freq_vector.terms.each do |term| - term_freq_map[term.text] += term.positions.size unless noise_word?(term.text, options) - end - else - # puts 'no stored term vector' - # no term vector stored, but we have stored the contents in the index - # -> extract terms from there - content = nil - if document_number - doc = reader[document_number] - content = doc[field] - end - unless content - # no term vector, no stored content, so try content from this instance - record ||= options[:base_class].constantize.find(id) - content = record.content_for_field_name(field.to_s) - end - puts "have doc: #{doc[:id]} with #{field} == #{content}" - token_count = 0 - - ts = options[:analyzer].token_stream(field, content) - while token = ts.next - break if (token_count+=1) > max_num_tokens - next if noise_word?(token.text, options) - term_freq_map[token.text] += 1 - end - end - end - term_freq_map - end - - # create an ordered(by score) list of word,fieldname,score - # structures - def create_queue(term_freq_map, reader, options) - pq = Array.new(term_freq_map.size) - - similarity = options[:similarity] - num_docs = reader.num_docs - term_freq_map.each_pair do |word, tf| - # filter out words that don't occur enough times in the source - next if options[:min_term_freq] && tf < options[:min_term_freq] - - # go through all the fields and find the largest document frequency - top_field = options[:field_names].first - doc_freq = 0 - options[:field_names].each do |field_name| - freq = reader.doc_freq(field_name, word) - if freq > doc_freq - top_field = field_name - doc_freq = freq - end - end - # filter out words that don't occur in enough docs - next if options[:min_doc_freq] && doc_freq < options[:min_doc_freq] - next if doc_freq == 0 # index update problem ? - - idf = similarity.idf(doc_freq, num_docs) - score = tf * idf - pq << FrequencyQueueItem.new(word, top_field, score) - end - pq.compact! - pq.sort! { |a,b| a.score<=>b.score } - return pq - end - - def noise_word?(text, options) - len = text.length - ( - (options[:min_word_length] > 0 && len < options[:min_word_length]) || - (options[:max_word_length] > 0 && len > options[:max_word_length]) || - (options[:stop_words] && options.include?(text)) - ) - end - - end - - class DefaultAAFSimilarity - def idf(doc_freq, num_docs) - return 0.0 if num_docs == 0 - return Math.log(num_docs.to_f/(doc_freq+1)) + 1.0 - end - end - - - class FrequencyQueueItem - attr_reader :word, :field, :score - def initialize(word, field, score) - @word = word; @field = field; @score = score - end - end - - end -end - diff --git a/vendor/plugins/acts_as_ferret/lib/multi_index.rb b/vendor/plugins/acts_as_ferret/lib/multi_index.rb deleted file mode 100644 index 440e5a8b..00000000 --- a/vendor/plugins/acts_as_ferret/lib/multi_index.rb +++ /dev/null @@ -1,133 +0,0 @@ -module ActsAsFerret #:nodoc: - - # Base class for remote and local multi-indexes - class MultiIndexBase - include FerretFindMethods - attr_accessor :logger - - def initialize(indexes, options = {}) - # ensure all models indexes exist - @indexes = indexes - indexes.each { |i| i.ensure_index_exists } - default_fields = indexes.inject([]) do |fields, idx| - fields + [ idx.index_definition[:ferret][:default_field] ] - end.flatten.uniq - # Patch to pass an or_default setting on to ferret. - # Without an or_default set, ferret will use OR queries by default. - # This implementation will use OR if any model asks for OR, otherwise - # AND. -- Paul Fitzpatrick, 11/1/2010 (contributed to public domain) - or_default = - indexes.select{|idx| idx.index_definition[:ferret][:or_default]}.size>0 - @options = { - :default_field => default_fields, - :or_default => or_default - }.update(options) - @logger = IndexLogger.new(ActsAsFerret::logger, "multi: #{indexes.map(&:index_name).join(',')}") - end - - def ar_find(query, options = {}, ar_options = {}) - limit = options.delete(:limit) - offset = options.delete(:offset) || 0 - options[:limit] = :all - total_hits, result = super query, options, ar_options - total_hits = result.size if ar_options[:conditions] - # if limit && limit != :all - # result = result[offset..limit+offset-1] - # end - [total_hits, result] - end - - def determine_stored_fields(options) - return nil unless options.has_key?(:lazy) - stored_fields = [] - @indexes.each do |index| - stored_fields += index.determine_stored_fields(options) - end - return stored_fields.uniq - end - - def shared? - false - end - - end - - # This class can be used to search multiple physical indexes at once. - class MultiIndex < MultiIndexBase - - def extract_stored_fields(doc, stored_fields) - ActsAsFerret::get_index_for(doc[:class_name]).extract_stored_fields(doc, stored_fields) unless stored_fields.blank? - end - - def total_hits(q, options = {}) - search(q, options).total_hits - end - - def search(query, options={}) - query = process_query(query, options) - logger.debug "parsed query: #{query.to_s}" - searcher.search(query, options) - end - - def search_each(query, options = {}, &block) - query = process_query(query, options) - searcher.search_each(query, options, &block) - end - - # checks if all our sub-searchers still are up to date - def latest? - #return false unless @reader - # segfaults with 0.10.4 --> TODO report as bug @reader.latest? - @reader and @reader.latest? - #@sub_readers.each do |r| - # return false unless r.latest? - #end - #true - end - - def searcher - ensure_searcher - @searcher - end - - def doc(i) - searcher[i] - end - alias :[] :doc - - def query_parser - @query_parser ||= Ferret::QueryParser.new(@options) - end - - def process_query(query, options = {}) - query = query_parser.parse(query) if query.is_a?(String) - return query - end - - def close - @searcher.close if @searcher - @reader.close if @reader - end - - protected - - def ensure_searcher - unless latest? - @sub_readers = @indexes.map { |idx| - begin - reader = Ferret::Index::IndexReader.new(idx.index_definition[:index_dir]) - logger.debug "sub-reader opened: #{reader}" - reader - rescue Exception - raise "error opening reader on index for class #{clazz.inspect}: #{$!}" - end - } - close - @reader = Ferret::Index::IndexReader.new(@sub_readers) - @searcher = Ferret::Search::Searcher.new(@reader) - end - end - - end # of class MultiIndex - -end diff --git a/vendor/plugins/acts_as_ferret/lib/rdig_adapter.rb b/vendor/plugins/acts_as_ferret/lib/rdig_adapter.rb deleted file mode 100644 index d8661514..00000000 --- a/vendor/plugins/acts_as_ferret/lib/rdig_adapter.rb +++ /dev/null @@ -1,149 +0,0 @@ -#begin -# require 'rdig' -#rescue LoadError -# puts "RDig gem not found, searching and indexing static pages won't work." -#end -require 'digest/md5' - -module ActsAsFerret - - # The RdigAdapter is automatically included into your model if you specify - # the +:rdig+ options hash in your call to acts_as_ferret. It overrides - # several methods declared by aaf to retrieve documents with the help of - # RDig's http crawler when you call rebuild_index. - module RdigAdapter - - if defined?(RDig) - - def self.included(target) - target.extend ClassMethods - target.send :include, InstanceMethods - target.alias_method_chain :ferret_key, :md5 - end - - # Indexer class to replace RDig's original indexer - class Indexer - include MonitorMixin - def initialize(batch_size, model_class, &block) - @batch_size = batch_size - @model_class = model_class - @documents = [] - @offset = 0 - @block = block - super() - end - - def add(doc) - synchronize do - @documents << @model_class.new(doc.uri.to_s, doc) - process_batch if @documents.size >= @batch_size - end - end - alias << add - - def close - synchronize do - process_batch - end - end - - protected - def process_batch - ActsAsFerret::logger.info "RdigAdapter::Indexer#process_batch: #{@documents.size} docs in queue, offset #{@offset}" - @block.call @documents, @offset - @offset += @documents.size - @documents = [] - end - end - - module ClassMethods - # overriding aaf to return the documents fetched via RDig - def records_for_rebuild(batch_size = 1000, &block) - indexer = Indexer.new(batch_size, self, &block) - configure_rdig do - crawler = RDig::Crawler.new RDig.configuration, ActsAsFerret::logger - crawler.instance_variable_set '@indexer', indexer - ActsAsFerret::logger.debug "now crawling..." - crawler.crawl - end - rescue => e - ActsAsFerret::logger.error e - ActsAsFerret::logger.debug e.backtrace.join("\n") - ensure - indexer.close if indexer - end - - # overriding aaf to skip reindexing records changed during the rebuild - # when rebuilding with the rake task - def records_modified_since(time) - [] - end - - # unfortunately need to modify global RDig.configuration because it's - # used everywhere in RDig - def configure_rdig - # back up original config - old_logger = RDig.logger - old_cfg = RDig.configuration.dup - RDig.logger = ActsAsFerret.logger - rdig_configuration[:crawler].each { |k,v| RDig.configuration.crawler.send :"#{k}=", v } if rdig_configuration[:crawler] - if ce_config = rdig_configuration[:content_extraction] - RDig.configuration.content_extraction = OpenStruct.new( :hpricot => OpenStruct.new( ce_config ) ) - end - yield - ensure - # restore original config - RDig.configuration.crawler = old_cfg.crawler - RDig.configuration.content_extraction = old_cfg.content_extraction - RDig.logger = old_logger - end - - # overriding aaf to enforce loading page title and content from the - # ferret index - def find_with_ferret(q, options = {}, find_options = {}) - options[:lazy] = true - super - end - - def find_for_id(id) - new id - end - end - - module InstanceMethods - def initialize(uri, rdig_document = nil) - @id = uri - @rdig_document = rdig_document - end - - # Title of the document. - # Use the +:title_tag_selector+ option to declare the hpricot expression - # that should be used for selecting the content for this field. - def title - @rdig_document.title - end - - # Content of the document. - # Use the +:content_tag_selector+ option to declare the hpricot expression - # that should be used for selecting the content for this field. - def content - @rdig_document.body - end - - # Url of this document. - def id - @id - end - - def ferret_key_with_md5 - Digest::MD5.hexdigest(ferret_key_without_md5) - end - - def to_s - "Page at #{id}, title: #{title}" - end - end - end - end - -end diff --git a/vendor/plugins/acts_as_ferret/lib/remote_functions.rb b/vendor/plugins/acts_as_ferret/lib/remote_functions.rb deleted file mode 100644 index c4415f84..00000000 --- a/vendor/plugins/acts_as_ferret/lib/remote_functions.rb +++ /dev/null @@ -1,43 +0,0 @@ -module ActsAsFerret - module RemoteFunctions - - private - - def yield_results(total_hits, results) - results.each do |result| - yield result[:model], result[:id], result[:score], result[:data] - end - total_hits - end - - - def handle_drb_error(return_value_in_case_of_error = false) - yield - rescue DRb::DRbConnError => e - logger.error "DRb connection error: #{e}" - logger.warn e.backtrace.join("\n") - raise e if ActsAsFerret::raise_drb_errors? - return_value_in_case_of_error - end - - alias :old_handle_drb_error :handle_drb_error - def handle_drb_error(return_value_in_case_of_error = false) - handle_drb_restart do - old_handle_drb_error(return_value_in_case_of_error) { yield } - end - end - - def handle_drb_restart - trys = 1 - begin - return yield - rescue ActsAsFerret::IndexNotDefined - logger.warn "Recovering from ActsAsFerret::IndexNotDefined exception" - ActsAsFerret::ferret_indexes[index_name] = ActsAsFerret::create_index_instance( index_definition ) - ActsAsFerret::ferret_indexes[index_name].register_class ActsAsFerret::index_using_classes.index(index_name).constantize, {} - retry if (trys -= 1) > 0 - end - yield - end - end -end diff --git a/vendor/plugins/acts_as_ferret/lib/remote_index.rb b/vendor/plugins/acts_as_ferret/lib/remote_index.rb deleted file mode 100644 index 9c5849e2..00000000 --- a/vendor/plugins/acts_as_ferret/lib/remote_index.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'drb' -module ActsAsFerret - - # This index implementation connects to a remote ferret server instance. It - # basically forwards all calls to the remote server. - class RemoteIndex < AbstractIndex - include RemoteFunctions - - def initialize(config) - super - @server = DRbObject.new(nil, ActsAsFerret::remote) - end - - # Cause model classes to be loaded (and indexes get declared) on the DRb - # side of things. - def register_class(clazz, options) - handle_drb_error { @server.register_class clazz.name } - end - - def method_missing(method_name, *args) - args.unshift index_name - handle_drb_error { @server.send(method_name, *args) } - end - - # Proxy any methods that require special return values in case of errors - { - :highlight => [] - }.each do |method_name, default_result| - define_method method_name do |*args| - args.unshift index_name - handle_drb_error(default_result) { @server.send method_name, *args } - end - end - - def find_ids(q, options = {}, &proc) - total_hits, results = handle_drb_error([0, []]) { @server.find_ids(index_name, q, options) } - block_given? ? yield_results(total_hits, results, &proc) : [ total_hits, results ] - end - - # add record to index - def add(record) - handle_drb_error { @server.add index_name, record.to_doc } - end - alias << add - - private - - #def model_class_name - # index_definition[:class_name] - #end - - end - -end diff --git a/vendor/plugins/acts_as_ferret/lib/remote_multi_index.rb b/vendor/plugins/acts_as_ferret/lib/remote_multi_index.rb deleted file mode 100644 index 7affd435..00000000 --- a/vendor/plugins/acts_as_ferret/lib/remote_multi_index.rb +++ /dev/null @@ -1,20 +0,0 @@ -module ActsAsFerret - class RemoteMultiIndex < MultiIndexBase - include RemoteFunctions - - def initialize(indexes, options = {}) - @index_names = indexes.map(&:index_name) - @server = DRbObject.new(nil, ActsAsFerret::remote) - super - end - - def find_ids(query, options, &proc) - total_hits, results = handle_drb_error([0, []]) { @server.multi_find_ids(@index_names, query, options) } - block_given? ? yield_results(total_hits, results, &proc) : [ total_hits, results ] - end - - def method_missing(name, *args) - handle_drb_error { @server.send(:"multi_#{name}", @index_names, *args) } - end - end -end diff --git a/vendor/plugins/acts_as_ferret/lib/search_results.rb b/vendor/plugins/acts_as_ferret/lib/search_results.rb deleted file mode 100644 index e3da6a2f..00000000 --- a/vendor/plugins/acts_as_ferret/lib/search_results.rb +++ /dev/null @@ -1,50 +0,0 @@ -module ActsAsFerret - - # decorator that adds a total_hits accessor and will_paginate compatible - # paging support to search result arrays - class SearchResults < ActsAsFerret::BlankSlate - reveal :methods - attr_reader :current_page, :per_page, :total_hits, :total_pages - alias total_entries total_hits # will_paginate compatibility - alias page_count total_pages # will_paginate backwards compatibility - - def initialize(results, total_hits, current_page = 1, per_page = nil) - @results = results - @total_hits = total_hits - @current_page = current_page - @per_page = (per_page || total_hits) - @total_pages = @per_page > 0 ? (@total_hits / @per_page.to_f).ceil : 0 - end - - def method_missing(symbol, *args, &block) - @results.send(symbol, *args, &block) - end - - def respond_to?(name) - methods.include?(name.to_s) || @results.respond_to?(name) - end - - - # code from here on was directly taken from will_paginate's collection.rb - - # Current offset of the paginated collection. If we're on the first page, - # it is always 0. If we're on the 2nd page and there are 30 entries per page, - # the offset is 30. This property is useful if you want to render ordinals - # besides your records: simply start with offset + 1. - # - def offset - (current_page - 1) * per_page - end - - # current_page - 1 or nil if there is no previous page - def previous_page - current_page > 1 ? (current_page - 1) : nil - end - - # current_page + 1 or nil if there is no next page - def next_page - current_page < total_pages ? (current_page + 1) : nil - end - end - -end diff --git a/vendor/plugins/acts_as_ferret/lib/server_manager.rb b/vendor/plugins/acts_as_ferret/lib/server_manager.rb deleted file mode 100644 index a8e08ac1..00000000 --- a/vendor/plugins/acts_as_ferret/lib/server_manager.rb +++ /dev/null @@ -1,71 +0,0 @@ -################################################################################ -require 'optparse' - -################################################################################ -$ferret_server_options = { - 'environment' => nil, - 'debug' => nil, - 'root' => nil -} - -################################################################################ -OptionParser.new do |optparser| - optparser.banner = "Usage: #{File.basename($0)} [options] {start|stop|run}" - - optparser.on('-h', '--help', "This message") do - puts optparser - exit - end - - optparser.on('-R', '--root=PATH', 'Set RAILS_ROOT to the given string') do |r| - $ferret_server_options['root'] = r - end - - optparser.on('-e', '--environment=NAME', 'Set RAILS_ENV to the given string') do |e| - $ferret_server_options['environment'] = e - end - - optparser.on('--debug', 'Include full stack traces on exceptions') do - $ferret_server_options['debug'] = true - end - - $ferret_server_action = optparser.permute!(ARGV) - (puts optparser; exit(1)) unless $ferret_server_action.size == 1 - - $ferret_server_action = $ferret_server_action.first - (puts optparser; exit(1)) unless %w(start stop run).include?($ferret_server_action) -end - -################################################################################ - -def determine_rails_root - possible_rails_roots = [ - $ferret_server_options['root'], - (defined?(FERRET_SERVER) ? File.join(File.dirname(FERRET_SERVER), '..') : nil), - File.join(File.dirname(__FILE__), *(['..']*4)), - '.' - ].compact - # take the first dir where environment.rb can be found - possible_rails_roots.find{ |dir| File.readable?(File.join(dir, 'config', 'environment.rb')) } -end - -begin - ENV['FERRET_USE_LOCAL_INDEX'] = 'true' - ENV['RAILS_ENV'] = $ferret_server_options['environment'] - # determine RAILS_ROOT unless already set - RAILS_ROOT = determine_rails_root unless defined?(RAILS_ROOT) - - begin - require File.join(RAILS_ROOT, 'config', 'environment') - rescue LoadError - puts "Unable to find Rails environment.rb in any of these locations:\n#{possible_rails_roots.join("\n")}\nPlease use the --root option of ferret_server to point it to your RAILS_ROOT." - raise $! - end - - # require 'acts_as_ferret' - ActsAsFerret::Remote::Server.new.send($ferret_server_action) -rescue Exception => e - $stderr.puts(e.message) - $stderr.puts(e.backtrace.join("\n")) if $ferret_server_options['debug'] - exit(1) -end diff --git a/vendor/plugins/acts_as_ferret/lib/unix_daemon.rb b/vendor/plugins/acts_as_ferret/lib/unix_daemon.rb deleted file mode 100644 index 394de0ee..00000000 --- a/vendor/plugins/acts_as_ferret/lib/unix_daemon.rb +++ /dev/null @@ -1,86 +0,0 @@ -################################################################################ -module ActsAsFerret - module Remote - - ################################################################################ - # methods for becoming a daemon on Unix-like operating systems - module UnixDaemon - - ################################################################################ - def platform_daemon (&block) - safefork do - write_pid_file - trap("TERM") { exit(0) } - sess_id = Process.setsid - STDIN.reopen("/dev/null") - STDOUT.reopen("#{RAILS_ROOT}/log/ferret_server.out", "a") - STDERR.reopen(STDOUT) - block.call - end - end - - ################################################################################ - # stop the daemon, nicely at first, and then forcefully if necessary - def stop - pid = read_pid_file - raise "ferret_server doesn't appear to be running" unless pid - $stdout.puts("stopping ferret server...") - Process.kill("TERM", pid) - 30.times { Process.kill(0, pid); sleep(0.5) } - $stdout.puts("using kill -9 #{pid}") - Process.kill(9, pid) - rescue Errno::ESRCH => e - $stdout.puts("process #{pid} has stopped") - ensure - File.unlink(@cfg.pid_file) if File.exist?(@cfg.pid_file) - end - - ################################################################################ - def safefork (&block) - @fork_tries ||= 0 - fork(&block) - rescue Errno::EWOULDBLOCK - raise if @fork_tries >= 20 - @fork_tries += 1 - sleep 5 - retry - end - - ################################################################################# - # create the PID file and install an at_exit handler - def write_pid_file - ensure_stopped - open(@cfg.pid_file, "w") {|f| f << Process.pid << "\n"} - at_exit { File.unlink(@cfg.pid_file) if read_pid_file == Process.pid } - end - - ################################################################################# - def read_pid_file - File.read(@cfg.pid_file).to_i if File.exist?(@cfg.pid_file) - end - - ################################################################################# - def ensure_stopped - if pid = read_pid_file - if process_exists(pid) - raise "ferret_server may already be running, a pid file exists: #{@cfg.pid_file} and a ferret_server process exists with matching pid #{pid}" - else - $stdout.puts("removing stale pid file...") - File.unlink(@cfg.pid_file) if File.exist?(@cfg.pid_file) - end - end - end - - ################################################################################# - # Check for existence of ferret_server process with PID from pid file - # checked on ubuntu and OSX only - def process_exists(pid) - ps = IO.popen("ps -fp #{pid}", "r") - process = ps.to_a[1] - ps.close - process =~ /ferret_server/ - end - - end - end -end diff --git a/vendor/plugins/acts_as_ferret/lib/without_ar.rb b/vendor/plugins/acts_as_ferret/lib/without_ar.rb deleted file mode 100644 index eba5e697..00000000 --- a/vendor/plugins/acts_as_ferret/lib/without_ar.rb +++ /dev/null @@ -1,52 +0,0 @@ -module ActsAsFerret - - # Include this module to use acts_as_ferret with model classes - # not based on ActiveRecord. - # - # Implement the find_for_id(id) class method in your model class in - # order to make search work. - module WithoutAR - def self.included(target) - target.extend ClassMethods - target.extend ActsAsFerret::ActMethods - target.send :include, InstanceMethods - end - - module ClassMethods - def logger - RAILS_DEFAULT_LOGGER - end - def table_name - self.name.underscore - end - def primary_key - 'id' - end - def find(what, args = {}) - case what - when :all - ids = args[:conditions][1] - ids.map { |id| find id } - else - find_for_id what - end - end - def find_for_id(id) - raise NotImplementedError.new("implement find_for_id in class #{self.name}") - end - def count - 0 - end - end - - module InstanceMethods - def logger - self.class.logger - end - def new_record? - false - end - end - end - -end diff --git a/vendor/plugins/acts_as_ferret/rails/init.rb b/vendor/plugins/acts_as_ferret/rails/init.rb deleted file mode 100644 index a15a3cd7..00000000 --- a/vendor/plugins/acts_as_ferret/rails/init.rb +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2006 Kasper Weibel Nielsen-Refs, Thomas Lockney, Jens Krämer -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -require 'acts_as_ferret' - -config.after_initialize { ActsAsFerret::load_config } -config.to_prepare { ActsAsFerret::load_config } diff --git a/vendor/plugins/acts_as_ferret/rakefile b/vendor/plugins/acts_as_ferret/rakefile deleted file mode 100644 index 09d79790..00000000 --- a/vendor/plugins/acts_as_ferret/rakefile +++ /dev/null @@ -1,117 +0,0 @@ -# rakefile for acts_as_ferret. -# use to create a gem or generate rdoc api documentation. -# -# RELEASE creation: -# rake release REL=x.y.z - -require 'pathname' -require 'yaml' -require 'rake' -require 'rake/rdoctask' -require 'rake/packagetask' -require 'rake/gempackagetask' -require 'rake/testtask' -require 'rake/contrib/rubyforgepublisher' - -def announce(msg='') - STDERR.puts msg -end - - -PKG_NAME = 'acts_as_ferret' -PKG_VERSION = ENV['REL'] -PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}" -RUBYFORGE_PROJECT = 'actsasferret' -RUBYFORGE_USER = 'jkraemer' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the acts_as_ferret plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the acts_as_ferret plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'html' - rdoc.title = "acts_as_ferret - Ferret based full text search for any ActiveRecord model" - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.options << '--main' << 'README' - rdoc.rdoc_files.include('README', 'LICENSE') - rdoc.template = "#{ENV['template']}.rb" if ENV['template'] - rdoc.rdoc_files.include('lib/**/*.rb') -end - -# FIXME -desc "Publish the API documentation" -task :pdoc => [:rdoc] do - # Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, RUBYFORGE_USER).upload -end - -if PKG_VERSION - spec = Gem::Specification.new do |s| - s.name = PKG_NAME - s.version = PKG_VERSION.dup - s.platform = Gem::Platform::RUBY - s.rubyforge_project = 'acts_as_ferret' - s.summary = "acts_as_ferret - Ferret based full text search for any ActiveRecord model" - s.description = "Rails plugin that adds powerful full text search capabilities to ActiveRecord models." - s.files = Dir.glob('**/*', File::FNM_DOTMATCH).reject do |f| - [ /\.$/, /sqlite$/, /\.log$/, /^pkg/, /\.svn/, /\.git/, /\.\w+\.sw.$/, - /^html/, /\~$/, /\/\._/, /\/#/, /\._/, /tmp\// ].any? {|regex| f =~ regex } - end - #s.files = FileList["{lib,test}/**/*"].to_a + %w(README MIT-LICENSE CHANGELOG) - s.add_dependency 'ferret' - s.require_path = 'lib' - s.bindir = "bin" - s.executables = ["aaf_install"] - s.default_executable = "aaf_install" - # s.autorequire = 'acts_as_ferret' - s.has_rdoc = true - # s.test_files = Dir['test/**/*_test.rb'] - s.author = "Jens Kraemer" - s.email = "jk@jkraemer.net" - s.homepage = "http://github.com/jkraemer/acts_as_ferret" - end - - desc "Update the gemspec for GitHub's gem server" - task :gemspec do - Pathname("#{spec.name}.gemspec").open('w') {|f| f << YAML.dump(spec) } - end - - desc 'build the gem' - task :package => :gemspec do - `gem build acts_as_ferret.gemspec` - `mv #{PKG_FILE_NAME}.gem pkg/#{PKG_FILE_NAME}.gem` - end - - desc 'publish to rubygems.org' - task :push => [ :package, :tag ] do - if ENV['RELTEST'] - announce "Release Task Testing, not pushing to rubygems.org" - else - `gem push pkg/#{PKG_FILE_NAME}.gem` - end - end - - - desc "tag the new release" - task :tag do - reltag = "rel_#{PKG_VERSION.gsub(/\./, '_')}" - announce "Tagging with [#{PKG_VERSION}]" - if ENV['RELTEST'] - announce "Release Task Testing, skipping tagging" - else - `git tag -m 'tagging release #{reltag}' -s #{reltag} HEAD` - `git tag -d stable` - `git tag -m 'tagging HEAD as stable' -s stable HEAD` - end - end - - desc 'Publish the gem and API docs' - task :release => [:pdoc, :push ] - -end diff --git a/vendor/plugins/acts_as_ferret/recipes/aaf_recipes.rb b/vendor/plugins/acts_as_ferret/recipes/aaf_recipes.rb deleted file mode 100644 index 65ee83b8..00000000 --- a/vendor/plugins/acts_as_ferret/recipes/aaf_recipes.rb +++ /dev/null @@ -1,116 +0,0 @@ -# Ferret DRb server Capistrano tasks -# -# Usage: -# in your Capfile, add acts_as_ferret's recipes directory to your load path and -# load the ferret tasks: -# -# load_paths << 'vendor/plugins/acts_as_ferret/recipes' -# load 'aaf_recipes' -# -# This will hook aaf's DRb start/stop tasks into the standard -# deploy:{start|restart|stop} tasks so the server will be restarted along with -# the rest of your application. -# Also an index directory in the shared folder will be created and symlinked -# into current/ when you deploy. -# -# In order to use the ferret:index:rebuild task, declare the indexes you intend to -# rebuild remotely in config/deploy.rb: -# -# set :ferret_indexes, %w( model another_model shared ) -# -# HINT: To be very sure that your DRb server and application are always using -# the same model and schema versions, and you never lose any index updates because -# of the DRb server being restarted in that moment, use the following sequence -# to update your application: -# -# cap deploy:stop deploy:update deploy:migrate deploy:start -# -# That will stop the DRb server after stopping your application, and bring it -# up before starting the application again. Plus they'll never use different -# versions of model classes (which might happen otherwise) -# Downside: Your downtime is a bit longer than with the usual deploy, so be sure to -# put up some maintenance page for the meantime. Obviously this won't work if -# your migrations need acts_as_ferret (i.e. if you update model instances which -# would lead to index updates). In this case bring up the DRb server before -# running your migrations: -# -# cap deploy:stop deploy:update ferret:start deploy:migrate ferret:stop deploy:start -# -# Chances are that you're still not safe if your migrations not only modify the index, -# but also change the structure of your models. So just don't do both things in -# one go - I can't think of an easy way to handle this case automatically. -# Suggestions and patches are of course very welcome :-) - -namespace :ferret do - - desc "Stop the Ferret DRb server" - task :stop, :roles => :app do - rails_env = fetch(:rails_env, 'production') - ruby = fetch(:ruby, '/usr/bin/env ruby') - run "cd #{current_path}; #{ruby} script/ferret_server -e #{rails_env} stop || true" - end - - desc "Start the Ferret DRb server" - task :start, :roles => :app do - rails_env = fetch(:rails_env, 'production') - ruby = fetch(:ruby, '/usr/bin/env ruby') - run "cd #{current_path}; #{ruby} script/ferret_server -e #{rails_env} start" - end - - desc "Restart the Ferret DRb server" - task :restart, :roles => :app do - top.ferret.stop - sleep 1 - top.ferret.start - end - - namespace :index do - - desc "Rebuild the Ferret index. See aaf_recipes.rb for instructions." - task :rebuild, :roles => :app do - rake = fetch(:rake, 'rake') - rails_env = fetch(:rails_env, 'production') - indexes = fetch(:ferret_indexes, []) - if indexes.any? - run "cd #{current_path}; RAILS_ENV=#{rails_env} INDEXES='#{indexes.join(' ')}' #{rake} ferret:rebuild" - end - end - - desc "purges all indexes for the current environment" - task :purge, :roles => :app do - run "rm -fr #{shared_path}/index/#{rails_env}" - end - - desc "symlinks index folder" - task :symlink, :roles => :app do - run "mkdir -p #{shared_path}/index && rm -rf #{release_path}/index && ln -nfs #{shared_path}/index #{release_path}/index" - end - - desc "Clean up old index versions" - task :cleanup, :roles => :app do - indexes = fetch(:ferret_indexes, []) - indexes.each do |index| - ferret_index_path = "#{shared_path}/index/#{rails_env}/#{index}" - releases = capture("ls -x #{ferret_index_path}").split.sort - count = 2 - if count >= releases.length - logger.important "no old indexes to clean up" - else - logger.info "keeping #{count} of #{releases.length} indexes" - directories = (releases - releases.last(count)).map { |release| - File.join(ferret_index_path, release) }.join(" ") - sudo "rm -rf #{directories}" - end - end - end - end - -end - -after "deploy:stop", "ferret:stop" -before "deploy:start", "ferret:start" - -before "deploy:restart", "ferret:stop" -after "deploy:restart", "ferret:start" -after "deploy:symlink", "ferret:index:symlink" - diff --git a/vendor/plugins/acts_as_ferret/script/ferret_daemon b/vendor/plugins/acts_as_ferret/script/ferret_daemon deleted file mode 100644 index 631c4b50..00000000 --- a/vendor/plugins/acts_as_ferret/script/ferret_daemon +++ /dev/null @@ -1,94 +0,0 @@ -# Ferret Win32 Service Daemon, called by Win 32 service, -# created by Herryanto Siatono -# -# see doc/README.win32 for usage instructions -# -require 'optparse' -require 'win32/service' -include Win32 - -# Read options -options = {} -ARGV.options do |opts| - opts.banner = 'Usage: ferret_daemon [options]' - opts.on("-l", "--log FILE", "Daemon log file") {|file| options[:log] = file } - opts.on("-c","--console","Run Ferret server on console.") {options[:console] = true} - opts.on_tail("-h","--help", "Show this help message") {puts opts; exit} - opts.on("-e", "--environment ENV ", "Rails environment") {|env| - options[:environment] = env - ENV['RAILS_ENV'] = env - } - opts.parse! -end - -require File.dirname(__FILE__) + '/../config/environment' - -# Ferret Win32 Service Daemon, called by Win 32 service, -# to run on the console, use -c or --console option. -module Ferret - class FerretDaemon < Daemon - # Standard logger to redirect STDOUT and STDERR to a log file - class FerretStandardLogger - def initialize(logger) - @logger = logger - end - - def write(s) - @logger.info s - end - end - - def initialize(options={}) - @options = options - - # initialize logger - if options[:log] - @logger = Logger.new @options[:log] - else - @logger = Logger.new RAILS_ROOT + "/log/ferret_service_#{RAILS_ENV}.log" - end - - # redirect stout and stderr to Ferret logger if running as windows service - $stdout = $stderr = FerretStandardLogger.new(@logger) unless @options[:console] - - log "Initializing FerretDaemon..." - if @options[:console] - self.service_init - self.service_main - end - end - - def service_main - log "Service main enterred..." - - while running? - log "Listening..." - sleep - end - - log "Service main exit..." - end - - def service_init - log "Starting Ferret DRb server..." - ActsAsFerret::Remote::Server.start - log "FerretDaemon started." - end - - def service_stop - log "Stopping service..." - DRb.stop_service - log "FerretDaemon stopped." - end - - def log(msg) - @logger.info msg - puts msg if @options[:console] - end - end -end - -if __FILE__ == $0 - d = Ferret::FerretDaemon.new(options) - d.mainloop -end diff --git a/vendor/plugins/acts_as_ferret/script/ferret_server b/vendor/plugins/acts_as_ferret/script/ferret_server deleted file mode 100644 index b2ecc1a6..00000000 --- a/vendor/plugins/acts_as_ferret/script/ferret_server +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env ruby - -FERRET_SERVER = File.expand_path(__FILE__) - -begin - require File.join(File.dirname(__FILE__), '../vendor/plugins/acts_as_ferret/lib/server_manager') -rescue LoadError - # try the gem - require 'rubygems' - gem 'acts_as_ferret' - require 'server_manager' -end diff --git a/vendor/plugins/acts_as_ferret/script/ferret_service b/vendor/plugins/acts_as_ferret/script/ferret_service deleted file mode 100644 index 6c56443f..00000000 --- a/vendor/plugins/acts_as_ferret/script/ferret_service +++ /dev/null @@ -1,178 +0,0 @@ -# Ferret Win32 Service Daemon install script -# created by Herryanto Siatono -# -# see doc/README.win32 for usage instructions -# -require 'optparse' -require 'win32/service' -include Win32 - -module Ferret - # Parse and validate service command and options - class FerretServiceCommand - COMMANDS = ['install', 'remove', 'start', 'stop', 'help'] - BANNER = "Usage: ruby script/ferret_service [options]" - - attr_reader :options, :command - - def initialize - @options = {} - end - - def valid_command? - COMMANDS.include?@command - end - - def valid_options? - @options[:name] and !@options[:name].empty? - end - - def print_command_list - puts BANNER - puts "\nAvailable commands:\n" - puts COMMANDS.map {|cmd| " - #{cmd}\n"} - puts "\nUse option -h for each command to help." - exit - end - - def validate_options - errors = [] - errors << "Service name is required." unless @options[:name] - - if (errors.size > 0) - errors << "Error found. Use: 'ruby script/ferret_service #{@command} -h' for to get help." - puts errors.join("\n") - exit - end - end - - def run(args) - @command = args.shift - @command = @command.dup.downcase if @command - - # validate command and options - print_command_list unless valid_command? or @command == 'help' - - opts_parser = create_options_parser - begin - opts_parser.parse!(args) - rescue OptionParser::ParseError => e - puts e - puts opts_parser - end - - # validate required options - validate_options - end - - def create_options_parser - opts_parser = OptionParser.new - opts_parser.banner = BANNER - opts_parser.on("-n", "--name=NAME", "Service name") {|name| @options[:name] = name } - opts_parser.on_tail("-t", "--trace", "Display stack trace when exception thrown") { @options[:trace] = true } - opts_parser.on_tail("-h", "--help", "Show this help message") { puts opts_parser; exit } - - if ['install'].include?@command - opts_parser.on("-d", "--display=NAME", "Service display name") {|name| @options[:display] = name } - - opts_parser.on("-l", "--log FILE", "Service log file") {|file| @options[:log] = file } - opts_parser.on("-e", "--environment ENV ", "Rails environment") { |env| - @options[:environment] = env - ENV['RAILS_ENV'] = env - } - end - opts_parser - end - end - - # Install, Remove, Start and Stop Ferret DRb server Win32 service - class FerretService - FERRET_DAEMON = 'ferret_daemon' - - def initialize - end - - def install - svc = Service.new - - begin - if Service.exists?(@options[:name]) - puts "Service name '#{@options[:name]}' already exists." - return - end - - svc.create_service do |s| - s.service_name = @options[:name] - s.display_name = @options[:display] - s.binary_path_name = binary_path_name - s.dependencies = [] - end - - svc.close - puts "'#{@options[:name]}' service installed." - rescue => e - handle_error(e) - end - end - - def remove - begin - Service.stop(@options[:name]) - rescue - end - - begin - Service.delete(@options[:name]) - puts "'#{@options[:name]}' service removed." - rescue => e - handle_error(e) - end - end - - def start - begin - Service.start(@options[:name]) - puts "'#{@options[:name]}' successfully started." - rescue => e - handle_error(e) - end - end - - def stop - begin - Service.stop(@options[:name]) - puts "'#{@options[:name]}' successfully stopped.\n" - rescue => e - handle_error(e) - end - end - - def run(args) - svc_cmd = FerretServiceCommand.new - svc_cmd.run(args) - @options = svc_cmd.options - self.send(svc_cmd.command.to_sym) - end - - protected - def handle_error(e) - if @options[:trace] - raise e - else - puts e - end - end - - def binary_path_name - path = "" - path << "#{ENV['RUBY_HOME']}/bin/" if ENV['RUBY_HOME'] - path << "ruby.exe " - path << File.expand_path("script/" + FERRET_DAEMON) - path << " -e #{@options[:environment]} " if @options[:environment] - path << " -l #{@options[:log]} " if @options[:log] - path - end - end -end - -Ferret::FerretService.new.run(ARGV) diff --git a/vendor/plugins/acts_as_ferret/tasks/ferret.rake b/vendor/plugins/acts_as_ferret/tasks/ferret.rake deleted file mode 100644 index 5b543ac8..00000000 --- a/vendor/plugins/acts_as_ferret/tasks/ferret.rake +++ /dev/null @@ -1,22 +0,0 @@ -namespace :ferret do - - # Rebuild index task. Declare the indexes to be rebuilt with the INDEXES - # environment variable: - # - # INDEXES="my_model shared" rake ferret:rebuild - desc "Rebuild a Ferret index. Specify what model to rebuild with the INDEXES environment variable." - task :rebuild => :environment do - indexes = ENV['INDEXES'].split - indexes.each do |index_name| - start = 1.minute.ago - ActsAsFerret::rebuild_index index_name - idx = ActsAsFerret::get_index index_name - # update records that have changed since the rebuild started - idx.index_definition[:registered_models].each do |m| - m.records_modified_since(start).each do |object| - object.ferret_update - end - end - end - end -end From a0a353d7ecf6ddef2201908922444669897372c4 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Thu, 15 Mar 2018 17:02:29 -0400 Subject: [PATCH 31/40] trim enormous map rendering times --- app/controllers/search_controller.rb | 4 ++ app/views/search/_map_core_leaflet.rhtml | 79 +++++++++--------------- 2 files changed, 33 insertions(+), 50 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index a11c0299..da4604d8 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -58,6 +58,9 @@ def search end @merge_target = session[:merge] + if @unlimited_search + @map_style = true + end if params[:q] render_entries end @@ -65,6 +68,7 @@ def search def map @unlimited_search = true + @map_style = true search end diff --git a/app/views/search/_map_core_leaflet.rhtml b/app/views/search/_map_core_leaflet.rhtml index 5d2f0901..39cdb89d 100644 --- a/app/views/search/_map_core_leaflet.rhtml +++ b/app/views/search/_map_core_leaflet.rhtml @@ -1,44 +1,6 @@ <% - at = 0 - markers = {} - bounds = [10000, 10000, -10000, -10000] - @have_something = false - mkr = [] - for e in orgs - if e.respond_to? "latitude" - unless e.latitude.nil? or e.longitude.nil? - unless Float(e.latitude).abs+Float(e.longitude).abs<0.001 - icon = "/openlayers/img/marker-star.png" - pt = [Float(e.latitude), Float(e.longitude)] - markers[e.id] = icon - bounds = [[bounds[0], pt[0]].min, - [bounds[1], pt[1]].min, - [bounds[2], pt[0]].max, - [bounds[3], pt[1]].max] - mkr << { - :point => pt, - :info_bubble => show_link(e), - :title => e.name, - :icon => icon, - :icon_size => [22,22] - } - @have_something = true - end - end - end - end - x1 = bounds[0] - y1 = bounds[1] - x2 = bounds[2] - y2 = bounds[3] - dx = (x2-x1)/10 - dy = (y2-y1)/10 - if dx<0.00001 and dy<0.00001 - dx = 0.1 - dy = 0.1 - end - # map.center_zoom_on_bounds_init([[x1-dx,y1-dy],[x2+dx,y2+dy]]) if @have_something + @have_something = true %> @@ -48,12 +10,25 @@