From d75dd4f936311d4118d4807c5c4ed460349e7f43 Mon Sep 17 00:00:00 2001 From: Kaito Date: Tue, 16 Aug 2011 12:14:01 +0800 Subject: [PATCH] completing the code with segment fault --- .../admin/.designs_controller.rb.swp | Bin 12288 -> 16384 bytes app/controllers/admin/designs_controller.rb | 20 ++++++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/controllers/admin/.designs_controller.rb.swp b/app/controllers/admin/.designs_controller.rb.swp index d81669d20df3199767390205c2f8e3e9d64ee837..5131583d8ed5a7c691ee1798a04566efb8363594 100644 GIT binary patch delta 2184 zcmbW&UuauZ90%~*b;nQ4_ zbAG?y`JHob8?%kZw$c3L@#z`%AfF;!!$fainLctU9VO@S_eQ^noSp1%UW@FAj`z_9 ze(wVVw)r-2P2j%L92x#G_A=W(gb4Jt{24cfJHnQnC!<6U!A`g_NOT@vffcwPV(`c9 zMAzXmybA?*1pdB_=o46lr(rkzd@IofuwVuT;QIlh7eIq!@E9D1!2xpUyIY9X;B`>p z5RAaL{Y2-$hBOfTwjBxJ2Uvs8;3N1Dns63ggfq~95@;|B$6z;Hj}Uzd&%^P^464Kp zhrPgH9Aa<GSVF+8W1Wyp_xOxN4VZJK=v;t&V zaN9lUuI`e!9OWKO-#sNG_k=`MVo@`ady2x+OI02}Eo)ufqwv;1cPy2Pd6kAa+%-Px znki*RkbNIZETt1lYk>RZem32)G>YrhLak!TKP${Xj`LjOi7vB&=X0J9x0CDlCmHl|_|ha)*-f)2DP(l}%bza+#zz7k50BOy>B! zSyEQ;X;!_@l0K&>xl!$rb3z*l!0A3X+!fL0Sw|X+# zWl`x|taCG~^(F^-3RXuV?kFba5d9CX?ve5c;0W2G zVz$oZ0Sj{q_Cnp87ffOuBm5jobsYyjDfdYR;dP-Ey)9+lN%H5$@o6}%x>}pREKjU_ za;P1A%bh>*OfGXWg{>~z6{Fp6uLLH)?25vezq)W0Dq4kv&dn?^oXr2@8s!q1H%sRG zmt}_i-{ORa>+IU?u#lb&FK8AzZ)$cq=%x1-3VRW5ivL{l(eB4`1@F(`a@W(l9@xD7 zJg-+PwPO1iZ0?}jNZm6YJg4cz{;7ojB4ORpC&TFe(b+n*H^6-^wae)UeBb84J#UjN zJ8?2h+VQZ4ubZv`Jx^!XZ~g(wyVdla&Bc9ZB92xh%Hx0TUm*V*PvGP87|}Z*U<}sp zAo>Nqfy?j~yaBJltMC$(K!aI$0@AP(ejg(G6|TWg@IJf=8azBi_fiHoG3bX46tV6X V^Jla9@Lw7@d4I~{&y24g%12?W_P}wZ@$@jT~nXv zP7cP#qHH*Dh|p|AwQnQG$D$S*J@&ABRjaQ^nf_qoi*}dAs-Zs!*#TwHG#s|~*1193 zJkxc)(hx0bn;VqnE>^8|T8LK6M6)mhXCVX{STzyd1rhecPb1M9tiV%v43FRr+=Q#J z09POj37CKwgkcyCgBQMb5WVQ28r{I;H2A>OK%ae^IBb9=CyX{WLI!Q)jl-ms*AEUDO38CPCCNSReS4bIKqfD87G@GJl;g@= zwt4#8y)*f8yqG9(=3~NufL@v|w>{(~k$Vwom)9d!`Hat)k(5_{CRBZbS3SN`g3{Cl zBxp;g=23PhHA3z9R6^`^ruk$(TMW1^D(Nmey#by`wAGLzT#B`}5 zZ7E^g?=mx%=E+Jn%g>X%+vD!prX;lroI!pWIiM6_X)j{lxA&A1fQ^M_ia<^(hyr7- pEs6gZ!`OJPR1woG$yw`6>fI`Z`X{->q>{3f;ZiEsDEa5Ke*v%`<}3gJ diff --git a/app/controllers/admin/designs_controller.rb b/app/controllers/admin/designs_controller.rb index 8289ae07..3228eb6a 100644 --- a/app/controllers/admin/designs_controller.rb +++ b/app/controllers/admin/designs_controller.rb @@ -27,13 +27,10 @@ class Admin::DesignsController < ApplicationController Zip::ZipFile.open(file) { |zip_file| design = Design.new.from_json(zip_file.read("#{zip_name}/info.json")) Dir.mktmpdir('f_path') { |dir| - #layout_entry ="" - #struct_css_entry ="" design.build_layout themes_entries = [] javascripts_entries = [] images_entries = [] - debugger temp_file4layout = File.new(dir + '/' + zip_name+'-1', 'w+') temp_file4layout.binmode #dir/zip_name @@ -60,21 +57,22 @@ class Admin::DesignsController < ApplicationController images_entries << entry end end - debugger ['themes', 'javascripts', 'images'].each do |type| + eval("#{type}_entries").each do |entry| #incompleted - eval("#{type}.entries").each do |entry| - title = File.basename entry - debugger - temp_file = File.new(dir + '/' + title+'-3', 'w+') + filename = File.basename entry.to_s + temp_file = File.new(dir + '/' + filename, 'w+') + temp_file.binmode temp_file.write zip_file.read entry - object.file = temp_file - object.to_save = true + build_and_store = eval("design.#{type}").build + build_and_store.file = temp_file + build_and_store.file_filename = filename + build_and_store._type = (File.extname entry.to_s).delete '.' + build_and_store.to_save = true end end } - design.save } end