diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index d2230767..79c9f926 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -15,7 +15,7 @@ class DesktopController< ApplicationController @desktop.save! end @currentusername = current_user.name - @currentname = current_user.first_name + current_user.last_name + @currentname = current_user.first_name + current_user.last_name rescue "" @title = "Desktop - " + @currentusername @section = @desktop.sections.first end diff --git a/lib/desktop_themes/Earth.zip b/lib/desktop_themes/Earth.zip new file mode 100644 index 00000000..c1cba341 Binary files /dev/null and b/lib/desktop_themes/Earth.zip differ diff --git a/lib/desktop_themes/Mars.zip b/lib/desktop_themes/Mars.zip new file mode 100644 index 00000000..66cf4b7c Binary files /dev/null and b/lib/desktop_themes/Mars.zip differ diff --git a/lib/desktop_themes/Mercury.zip b/lib/desktop_themes/Mercury.zip new file mode 100644 index 00000000..97e24144 Binary files /dev/null and b/lib/desktop_themes/Mercury.zip differ diff --git a/lib/desktop_themes/Neptune.zip b/lib/desktop_themes/Neptune.zip new file mode 100644 index 00000000..8ac7f96e Binary files /dev/null and b/lib/desktop_themes/Neptune.zip differ diff --git a/lib/desktop_themes/Saturn.zip b/lib/desktop_themes/Saturn.zip new file mode 100644 index 00000000..8d1a6b8e Binary files /dev/null and b/lib/desktop_themes/Saturn.zip differ diff --git a/lib/desktop_themes/Venus.zip b/lib/desktop_themes/Venus.zip new file mode 100644 index 00000000..a9d30643 Binary files /dev/null and b/lib/desktop_themes/Venus.zip differ diff --git a/lib/desktop_themes/nature.zip b/lib/desktop_themes/nature.zip new file mode 100644 index 00000000..7e939cca Binary files /dev/null and b/lib/desktop_themes/nature.zip differ diff --git a/lib/desktop_themes/vintage.zip b/lib/desktop_themes/vintage.zip new file mode 100644 index 00000000..b5a98c1c Binary files /dev/null and b/lib/desktop_themes/vintage.zip differ diff --git a/lib/tasks/desktop.rake b/lib/tasks/desktop.rake index 8d04ad5d..f6bb0284 100644 --- a/lib/tasks/desktop.rake +++ b/lib/tasks/desktop.rake @@ -21,10 +21,37 @@ namespace :desktop do # flash[:error] = "Upload file should be in zip format" #end temp_file.close + + Dir.glob("#{Rails.root}/lib/desktop_themes/*.zip").each do |theme_zip| + upload_desktop_theme(theme_zip,File.basename(theme_zip, ".zip")) + end end Rake::Task["tiles:destroy_build_tiles"].execute end + def upload_desktop_theme(file, zip_name) + Zip::ZipFile.open(file) { |zip_file| + dt = DesktopTheme.new.from_json(zip_file.read("#{zip_name}/settings.json")) + Dir.mktmpdir('f_path') { |dir| + images_entries = [] + + zip_file.entries.each do |entry| + case (path = entry.to_s) + when /\A(#{zip_name})\/(theme\.css)\z/ #for default css + dt.build_css_default(:file => get_temp_file(zip_file, dir, entry)) + when /\A(#{zip_name})\/(background)\/.*((\.jpg)|(\.png)|(\.gif))\z/ #for img + images_entries << entry + end + end + + images_entries.each do |image| + dt.images.build(:file => get_temp_file(zip_file,dir,image)) + end + } + dt.save + } + end + def unzip_widget(file, zip_name) Zip::ZipFile.open(file) { |zip_file| dw = DesktopWidget.new.from_json(zip_file.read("#{zip_name}/settings.json"))