From c2c1acc85c0adacea42a983a84775664b777ddee Mon Sep 17 00:00:00 2001 From: Arpit Goyal Date: Fri, 18 Jul 2014 00:50:42 +0530 Subject: [PATCH 1/4] Adding a default TV share with a name TV and a tag TV Signed-off-by: Arpit Goyal --- app/models/share.rb | 2 +- plugins/020-shares/app/views/shares/_tags.html.slim | 2 +- plugins/020-shares/config/locales/en.yml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/share.rb b/app/models/share.rb index 94c2647f..fc76e63d 100644 --- a/app/models/share.rb +++ b/app/models/share.rb @@ -23,7 +23,7 @@ class Share < ActiveRecord::Base DEFAULT_SHARES_ROOT = '/var/hda/files' SIGNATURE = "Amahi configuration" - DEFAULT_SHARES = [ "Books", "Pictures", "Movies", "Videos", "Music", "Docs", "Public" ].each {|s| I18n.t s } + DEFAULT_SHARES = [ "Books", "Pictures", "Movies", "Videos", "Music", "Docs", "Public", "TV" ].each {|s| I18n.t s } PDC_SETTINGS = "/var/hda/domain-settings" default_scope {order("name")} diff --git a/plugins/020-shares/app/views/shares/_tags.html.slim b/plugins/020-shares/app/views/shares/_tags.html.slim index 09c949e9..435f38dc 100644 --- a/plugins/020-shares/app/views/shares/_tags.html.slim +++ b/plugins/020-shares/app/views/shares/_tags.html.slim @@ -6,7 +6,7 @@ = spinner p[class="shares-fixed-tags"] - - [t('music'), t('pictures'), t('videos'), t('docs')].each_with_index do |tag, i| + - [t('music'), t('pictures'), t('videos'), t('docs'), t('tv')].each_with_index do |tag, i| = simple_remote_checkbox :id => "share_visible_#{share.id}_#{i}", :css_class => 'share_tags_checkbox', :url => update_tags_share_path(:id => share.id, :name => tag), diff --git a/plugins/020-shares/config/locales/en.yml b/plugins/020-shares/config/locales/en.yml index fb36bfb7..d11dc9e1 100644 --- a/plugins/020-shares/config/locales/en.yml +++ b/plugins/020-shares/config/locales/en.yml @@ -3,3 +3,4 @@ 'en': # put here your string symbols and translations hello_world: Hello World! (yay for the Amahi plugins!) + tv: TV From 10b3ccd1992fb72ca3d63221aa758c7b87e29f65 Mon Sep 17 00:00:00 2001 From: Arpit Goyal Date: Fri, 18 Jul 2014 01:09:27 +0530 Subject: [PATCH 2/4] Adding movies tag Signed-off-by: Arpit Goyal --- plugins/020-shares/app/views/shares/_tags.html.slim | 2 +- plugins/020-shares/config/locales/en.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/020-shares/app/views/shares/_tags.html.slim b/plugins/020-shares/app/views/shares/_tags.html.slim index 435f38dc..3ef6ea0f 100644 --- a/plugins/020-shares/app/views/shares/_tags.html.slim +++ b/plugins/020-shares/app/views/shares/_tags.html.slim @@ -6,7 +6,7 @@ = spinner p[class="shares-fixed-tags"] - - [t('music'), t('pictures'), t('videos'), t('docs'), t('tv')].each_with_index do |tag, i| + - [t('music'), t('pictures'), t('videos'), t('docs'), t('tv'), t('movies')].each_with_index do |tag, i| = simple_remote_checkbox :id => "share_visible_#{share.id}_#{i}", :css_class => 'share_tags_checkbox', :url => update_tags_share_path(:id => share.id, :name => tag), diff --git a/plugins/020-shares/config/locales/en.yml b/plugins/020-shares/config/locales/en.yml index d11dc9e1..ab46e618 100644 --- a/plugins/020-shares/config/locales/en.yml +++ b/plugins/020-shares/config/locales/en.yml @@ -4,3 +4,4 @@ # put here your string symbols and translations hello_world: Hello World! (yay for the Amahi plugins!) tv: TV + movies: Movies From d2fdfce6af43abe02efc6ebd5f2f50dea864fff3 Mon Sep 17 00:00:00 2001 From: Arpit Goyal Date: Fri, 18 Jul 2014 02:33:48 +0530 Subject: [PATCH 3/4] Add migration for tv shares if not exist --- db/migrate/20140717200213_add_tv_to_shares.rb | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 db/migrate/20140717200213_add_tv_to_shares.rb diff --git a/db/migrate/20140717200213_add_tv_to_shares.rb b/db/migrate/20140717200213_add_tv_to_shares.rb new file mode 100644 index 00000000..f98c0730 --- /dev/null +++ b/db/migrate/20140717200213_add_tv_to_shares.rb @@ -0,0 +1,22 @@ +class AddTvToShares < ActiveRecord::Migration + def self.up + if(Setting.get('initialized') && Setting.get('initialized') == '1') + name = "TV" + sh = Share.where(:name=>name).first + if !sh + sh = Share.new + sh.path = Share.default_full_path(name) + sh.name = name + sh.rdonly = false + sh.visible = true + sh.tags = name.downcase + sh.extras = "" + sh.disk_pool_copies = 0 + sh.save! + end + end + end + + def self.down + end +end From 040b9f86dd5d2a222d929ede39cf27b5ebf5c412 Mon Sep 17 00:00:00 2001 From: Arpit Goyal Date: Fri, 18 Jul 2014 11:57:20 +0530 Subject: [PATCH 4/4] Adding tag 'tv' to teh existing tv share Signed-off-by: Arpit Goyal --- db/migrate/20140717200213_add_tv_to_shares.rb | 7 ++++++- db/schema.rb | 3 +-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/db/migrate/20140717200213_add_tv_to_shares.rb b/db/migrate/20140717200213_add_tv_to_shares.rb index f98c0730..374a4c25 100644 --- a/db/migrate/20140717200213_add_tv_to_shares.rb +++ b/db/migrate/20140717200213_add_tv_to_shares.rb @@ -3,7 +3,12 @@ def self.up if(Setting.get('initialized') && Setting.get('initialized') == '1') name = "TV" sh = Share.where(:name=>name).first - if !sh + if sh + if !sh.tags.include?("tv") + sh.tags = "#{sh.tags}, tv" + sh.save! + end + else sh = Share.new sh.path = Share.default_full_path(name) sh.name = name diff --git a/db/schema.rb b/db/schema.rb index 18f11e2e..a444a784 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,8 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140627195608) do - +ActiveRecord::Schema.define(version: 20140717200213) do create_table "app_dependencies", force: true do |t| t.integer "app_id" t.integer "dependency_id"