faalis 0.26.3 → 1.0.0.alpha0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +35 -6
  3. data/Rakefile +2 -25
  4. data/app/assets/javascripts/faalis/angular-manifest.js +8 -2
  5. data/app/assets/javascripts/faalis/application.js +0 -3
  6. data/app/assets/javascripts/faalis/dashboard/application.js.erb +0 -5
  7. data/app/assets/javascripts/faalis/dashboard/functions.js.erb +9 -0
  8. data/app/assets/javascripts/faalis/dashboard/init.js +1 -1
  9. data/app/assets/javascripts/faalis/dashboard/modules/auth/group.js +0 -6
  10. data/app/assets/javascripts/faalis/dashboard/modules/fields/fields.js +1 -1
  11. data/app/assets/javascripts/faalis/dashboard/modules/fields/image.js +115 -0
  12. data/app/assets/javascripts/faalis/dashboard/modules/fields/tag.js +76 -0
  13. data/app/assets/javascripts/faalis/dashboard/variables.js.erb +1 -1
  14. data/app/assets/locale/templates.pot +282 -0
  15. data/app/assets/stylesheets/faalis/dashboard/dashboard.css.scss +4 -0
  16. data/app/assets/stylesheets/faalis/dashboard/ltr/application.css +4 -4
  17. data/app/assets/stylesheets/faalis/dashboard/rtl/application.css +4 -4
  18. data/app/assets/stylesheets/faalis/dashboard/rtl/base.css.scss.erb +2 -2
  19. data/app/controllers/faalis/api/v1/permissions_controller.rb +8 -39
  20. data/app/controllers/faalis/api/v1/users_controller.rb +7 -7
  21. data/app/models/ability.rb +4 -6
  22. data/app/models/faalis/concerns/assignment.rb +2 -2
  23. data/app/models/faalis/group.rb +18 -4
  24. data/app/models/faalis/permission.rb +11 -2
  25. data/app/models/faalis/permissions/auth.rb +3 -2
  26. data/app/models/faalis/user.rb +27 -73
  27. data/app/models/faalis/user/auth_definitions.rb +94 -0
  28. data/app/models/faalis/user/mongoid_fields.rb +76 -0
  29. data/app/models/faalis/user/permission.rb +21 -0
  30. data/app/views/angularjs_templates/auth/groups/new.html +0 -20
  31. data/app/views/angularjs_templates/fields/image/image.html +1 -0
  32. data/app/views/angularjs_templates/fields/relation/relation.html +3 -1
  33. data/app/views/angularjs_templates/fields/tag/tag.html +1 -0
  34. data/app/views/angularjs_templates/nav.html.erb +0 -1
  35. data/app/views/faalis/api/v1/users/index.json.jbuilder +1 -1
  36. data/app/views/layouts/faalis/application.html.erb +2 -0
  37. data/app/views/layouts/faalis/dashboard.html.erb +1 -0
  38. data/app/views/layouts/faalis/simple.html.erb +1 -0
  39. data/config/initializers/devise.rb +0 -7
  40. data/db/migrate/20131013091000_devise_create_faalis_users.rb +3 -2
  41. data/db/migrate/20140613120923_add_users_groups_table.rb +8 -0
  42. data/db/migrate/20140617124019_faalis_groups_users.rb +4 -0
  43. data/db/seeds.rb +39 -11
  44. data/lib/faalis.rb +5 -4
  45. data/lib/faalis/concerns.rb +7 -0
  46. data/lib/faalis/concerns/authorizable.rb +76 -0
  47. data/lib/faalis/discovery.rb +8 -0
  48. data/lib/faalis/discovery/permissions.rb +51 -0
  49. data/lib/faalis/engine.rb +19 -5
  50. data/lib/faalis/extensions.rb +18 -0
  51. data/lib/faalis/extensions/base.rb +29 -0
  52. data/lib/faalis/fake_assets.rb +7 -0
  53. data/lib/faalis/generators/dashboard_scaffold.rb +23 -5
  54. data/lib/faalis/omniauth.rb +3 -0
  55. data/lib/faalis/orm.rb +29 -0
  56. data/lib/faalis/{active_record.rb → patches/models.rb} +1 -3
  57. data/lib/faalis/version.rb +1 -1
  58. data/lib/generators/faalis/install_generator.rb +7 -3
  59. data/lib/{faalis/plugins.rb → generators/faalis/js/install_i18n_generator.rb} +20 -17
  60. data/lib/generators/faalis/scaffold_generator.rb +139 -0
  61. data/lib/generators/faalis/templates/application.js +1 -1
  62. data/lib/generators/faalis/templates/i18n/Gruntfile.js.erb +30 -0
  63. data/lib/generators/faalis/templates/i18n/README +13 -0
  64. data/lib/generators/faalis/templates/i18n/fa.js +3 -0
  65. data/lib/generators/faalis/templates/js/list_view/README +1 -1
  66. data/lib/tasks/faalis_tasks.rake +26 -20
  67. data/lib/tasks/grunt/Gruntfile.js +7 -2
  68. data/spec/dummy/config/initializers/faalis.rb +40 -0
  69. metadata +134 -44
  70. data/app/assets/javascripts/faalis/dashboard/lib/angular-gettext.js +0 -202
  71. data/app/assets/javascripts/faalis/dashboard/lib/ng-grid.js +0 -3260
  72. data/app/assets/javascripts/faalis/dashboard/lib/ng-quick-date.js +0 -297
  73. data/app/assets/javascripts/faalis/dashboard/lib/restangular.js +0 -1066
  74. data/app/assets/javascripts/faalis/dashboard/lib/select2.js +0 -3255
  75. data/app/assets/javascripts/faalis/dashboard/lib/ui.select2.js +0 -217
  76. data/app/assets/stylesheets/faalis/dashboard/ng-grid.css.scss +0 -442
  77. data/app/assets/stylesheets/faalis/dashboard/ng-quick-date-default-theme.css.scss +0 -20
  78. data/app/assets/stylesheets/faalis/dashboard/ng-quick-date.css.scss +0 -19
  79. data/app/assets/stylesheets/faalis/dashboard/select2.css.scss.erb +0 -618
  80. data/app/controllers/faalis/api/v1/#conversations_controller.rb# +0 -120
  81. data/app/models/faalis/workflow.rb +0 -4
  82. data/db/migrate/20140413180202_create_faalis_workflows.rb +0 -9
  83. data/lib/faalis/permissions.rb +0 -72
  84. data/lib/faalis/workflows.rb +0 -7
  85. data/lib/faalis/workflows/base.rb +0 -70
  86. data/lib/faalis/workflows/discovery.rb +0 -42
  87. data/lib/generators/faalis/js_scaffold_generator.rb +0 -113
@@ -1,120 +0,0 @@
1
- require_dependency 'faalis/application_controller'
2
-
3
- module Faalis
4
- class API::V1::ConversationsController < ::APIController
5
- before_filter :authenticate_user!
6
- helper_method :mailbox, :conversation
7
-
8
- def create
9
- #binding.pry
10
- recipient_emails = message_params(:recipients).split(',')
11
- recipients = User.where(email: recipient_emails).all
12
-
13
- @conversation = current_user.
14
- send_message(recipients, *message_params(:body, :subject)).conversation
15
-
16
- respond_with(@conversation)
17
- end
18
-
19
- def reply
20
- @conversation = current_user.reply_to_conversation(conversation, *message_params(:body, :subject))
21
- respond_with(@conversation)
22
- end
23
-
24
- def trash
25
- ids = params[:id].split(",")
26
- ids.each do |id|
27
- conversation = current_user.mailbox.conversations.find(params[:id])
28
- conversation.move_to_trash(current_user)
29
- end
30
- end
31
-
32
- def untrash
33
- ids = params[:id].split(",")
34
- ids.each do |id|
35
- conversation = current_user.mailbox.conversations.find(params[:id])
36
- conversation.untrash(current_user)
37
- end
38
-
39
- end
40
-
41
- def destroy
42
- ids = params[:id].split(",")
43
- ids.each do |id|
44
- conversation = current_user.mailbox.conversations.find(params[:id])
45
- current_user.mark_as_deleted conversation
46
- #conversation.mark_as_deleted(current_user)
47
- end
48
- respond_with
49
- end
50
-
51
- def index
52
- if params[:box] == "inbox"
53
- box = "inbox"
54
- elsif params[:box] == "sentbox"
55
- box = "sentbox"
56
- elsif params[:box] == "trash"
57
- box = "trash"
58
- else
59
- respond_to do |f|
60
- f.any { head :not_found }
61
- end
62
- returng
63
- end
64
- # puts current_user.mailbox.sent.to_json
65
- @mailbox ||= current_user.mailbox.send(box.to_sym)
66
- respond_with @mailbox
67
- end
68
-
69
-
70
- def show
71
- #def conversation
72
- @conversations ||= current_user.mailbox.conversations.find(params[:id])
73
- @current_user = current_user
74
- # @conversation = {}
75
- # conversations.each do |conversation|
76
- # tmp = {
77
- # :receipts => conversation.receipts,
78
- # :body => conversation.messages.body,
79
- # :is_read => conversation.is_read,
80
- # :trashed => conversation.trashed,
81
- # :deleted => conversation.deleted,
82
- # :recipients => conversation.recipients
83
- # }
84
- #unless @conversation.include? conversation.id
85
- # @conversation[conversation.id] = tmp
86
- #end
87
- #end
88
-
89
- end
90
- private
91
-
92
- def mailbox
93
- @mailbox ||= current_user.mailbox
94
- end
95
-
96
-
97
- def conversation
98
- @conversation ||= mailbox.conversations.find(params[:id])
99
- end
100
-
101
- def conversation_params(*keys)
102
- fetch_params(:conversation, *keys)
103
- end
104
-
105
- def message_params(*keys)
106
- fetch_params(:message, *keys)
107
- end
108
-
109
- def fetch_params(key, *subkeys)
110
- params[key].instance_eval do
111
- case subkeys.size
112
- when 0 then self
113
- when 1 then
114
- self[subkeys.first]
115
- else subkeys.map{|k| self[k] }
116
- end
117
- end
118
- end
119
- end
120
- end
@@ -1,4 +0,0 @@
1
- module Faalis
2
- class Workflow < ActiveRecord::Base
3
- end
4
- end
@@ -1,9 +0,0 @@
1
- class CreateFaalisWorkflows < ActiveRecord::Migration
2
- def change
3
- create_table :faalis_workflows do |t|
4
- t.string :name
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,72 +0,0 @@
1
- module Faalis
2
- module Permissions
3
- extend ActiveSupport::Concern
4
-
5
-
6
- module ClassMethods
7
-
8
- # Default permission hash
9
- @@permissions = {
10
- :read => nil,
11
- :update => nil,
12
- :create => nil,
13
- :destroy => nil,
14
- }
15
-
16
- @@only_owner = false
17
-
18
- # @return an array of strings representation of permissions
19
- def permission_strings(model)
20
- strings = []
21
- model_name = model.to_s
22
- humanize_name = ActiveModel::Name.new(model).human
23
- if model.respond_to? :model_name
24
- model_name = model.model_name
25
- humanize_name = model_name.human
26
- end
27
- @@permissions.each do |key, value|
28
- strings << {
29
- :name => "#{key}|#{model_name}",
30
- :string => _("can %s %s") % [_(key.to_s), humanize_name]
31
- }
32
- end
33
- strings
34
- end
35
-
36
- def possible_permissions
37
- @@permissions.keys
38
- end
39
-
40
- # Define permissions using this method
41
- def permissions(*args)
42
-
43
- args.each do |permission|
44
- if permission.class == Symbol
45
- if not @@permissions.include? permission
46
- @@permission[permission] = nil
47
-
48
- elsif permission.class == Hash
49
-
50
- permission.each do |key, value|
51
- @@permissions[key.to_sym] = value
52
- end
53
-
54
- end
55
- end
56
-
57
-
58
- end
59
- end
60
-
61
- # This force user to have access to resources which is his.
62
- def only_his_objects
63
- @@only_owner = true
64
- end
65
-
66
- def only_his_objects?
67
- @@only_owner
68
- end
69
-
70
- end
71
- end
72
- end
@@ -1,7 +0,0 @@
1
- # This module package all related concept and implementations
2
- # to workflow
3
- module Faalis::Workflows
4
- end
5
-
6
- require 'faalis/workflows/base'
7
- require 'faalis/workflows/discovery'
@@ -1,70 +0,0 @@
1
- module Faalis
2
- module Workflows
3
-
4
- # Base class for all the workflows in a `Faalis application`
5
- class Base
6
-
7
- attr_reader :id
8
-
9
- @@default_values = {:title => self.class.to_s.underscore,
10
- :icon => nil,
11
- :image => nil,
12
- :permissions => []}
13
-
14
- def initialize(model_instance)
15
- @id = model_instance.id
16
- end
17
-
18
- # class method to set the title of current workflow
19
- def self.title(name)
20
- define_method :title do
21
- name || self.to_s.underscore
22
- end
23
- end
24
-
25
-
26
- # Set the current workflow icon if any
27
- def self.icon(icon)
28
- define_method :icon do
29
- icon
30
- end
31
- end
32
-
33
-
34
- def icon?
35
- return true if defined? :icon
36
- false
37
- end
38
-
39
-
40
- # Set the current workflow image if any
41
- def self.image(image)
42
- define_method :image do
43
- image
44
- end
45
- end
46
-
47
- def image?
48
- return true if defined? :image
49
- false
50
- end
51
-
52
- # Use this class method to add any permission that is neeeded
53
- # for this workflow to work
54
- def self.permissions(*args)
55
- define_method :permissions do
56
- args || []
57
- end
58
- end
59
-
60
- def method_missing(m, *args, &block)
61
- if @@default_values.include? m
62
- @@default_values[m]
63
- else
64
- super
65
- end
66
- end
67
-
68
- end
69
- end
70
- end
@@ -1,42 +0,0 @@
1
- module Faalis
2
- module Workflows
3
- # Discover all the workflows in current application in addition to
4
- # gem files and add them to database for future reference.
5
- class Discovery
6
- # A class method to use in `seed.rb` to create all workflows in
7
- # database
8
- def self.build_table_list
9
- # Get all gem by requiring them
10
- all_gems = Bundler.require
11
-
12
- # Discover all model files in gem files and load them
13
- all_gems.each do |gem|
14
- if gem.groups.include?(Rails.env.to_sym) || \
15
- gem.groups.include?(:default)
16
-
17
- puts "Gem name: #{gem.name}"
18
- spec = Gem::Specification.find_by_name gem.name
19
- discover spec.gem_dir
20
- end
21
- end
22
-
23
- # Discover models in current rails app and load them
24
- discover Rails.root
25
-
26
- # Create a content type entry for all Models
27
- Faalis::Workflows::Base.subclasses.each do |workflow|
28
- Faalis::Workflow.find_or_create_by(name: workflow.to_s)
29
- end
30
- end
31
-
32
- private
33
-
34
- def self.discover(path)
35
- Dir["#{path}/app/workflows/**/*.rb"].each do |workflow_file|
36
- puts "File matched: #{workflow_file}"
37
- load workflow_file
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,113 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- # Faalis - Basic website skel engine
3
- # Copyright (C) 2012-2013 Yellowen
4
- #
5
- # This program is free software; you can redistribute it and/or modify
6
- # it under the terms of the GNU General Public License as published by
7
- # the Free Software Foundation; either version 2 of the License, or
8
- # (at your option) any later version.
9
- #
10
- # This program is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- # GNU General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License along
16
- # with this program; if not, write to the Free Software Foundation, Inc.,
17
- # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
- # -----------------------------------------------------------------------------
19
-
20
- module Faalis
21
- module Generators
22
- # `js_scaffold` main class
23
- class JsScaffoldGenerator < Faalis::Generators::DashboardScaffold
24
- # We keep this class to keep backward compatiblity
25
- puts "[DEPRECATED]: This generator will be removed soon, Use faalis:js:list_view instead."
26
- # TODO: Remove this ater a while
27
-
28
-
29
- # templates path
30
- source_root File.expand_path('../templates', __FILE__)
31
-
32
- # Field name to use as title of each object
33
- class_option :title_field, :type => :string, :default => "name", :desc => "Field name to use as title of each object"
34
-
35
- # Don't copy the new.html template
36
- class_option :no_new_template, :type => :boolean, :default => false, :desc => "Don't copy the new.html template"
37
-
38
- desc "Create a new resource for client side application"
39
- def create_module
40
- unless options[:only_controller]
41
- unless options[:only_specs]
42
- template "angularjs/module.js.erb", "#{angularjs_app_path}modules/#{resource_path}.js"
43
- end
44
- end
45
- end
46
-
47
- def create_template
48
- unless options[:only_controller]
49
- unless options[:only_specs]
50
- template "angularjs/index.html.erb", "app/views/angularjs_templates/#{resource.underscore}/index.html"
51
- unless options[:no_new_template]
52
- template "angularjs/new.html.erb", "app/views/angularjs_templates/#{resource.underscore}/new.html"
53
- end
54
- template "angularjs/details.html.erb", "app/views/angularjs_templates/#{resource.underscore}/details.html"
55
- end
56
- end
57
-
58
- unless options[:only_specs]
59
- template "views/index.json.jbuilder.erb", "app/views/api/v1/#{resource.pluralize.underscore}/index.json.jbuilder"
60
- template "views/show.json.jbuilder.erb", "app/views/api/v1/#{resource.pluralize.underscore}/show.json.jbuilder"
61
- template "views/create.json.jbuilder.erb", "app/views/api/v1/#{resource.pluralize.underscore}/create.json.jbuilder"
62
- template "views/destroy.json.jbuilder.erb", "app/views/api/v1/#{resource.pluralize.underscore}/destroy.json.jbuilder"
63
- template "views/update.json.jbuilder.erb", "app/views/api/v1/#{resource.pluralize.underscore}/update.json.jbuilder"
64
- end
65
- end
66
-
67
- def create_api
68
- unless options[:only_specs]
69
- template "api/controller.rb.erb", "app/controllers/api/v1/#{resource.pluralize.underscore}_controller.rb"
70
- end
71
- end
72
-
73
- def create_specs
74
- unless options[:without_specs]
75
- template "features/api.feature", "features/#{resource.underscore}.api.feature"
76
- template "features/api.step.rb", "features/step_definitions/#{resource.underscore}.rb"
77
- end
78
- end
79
-
80
- def show_readme
81
- readme "js_scaffold.README" if behavior == :invoke
82
- end
83
-
84
- # PRIVATES --------------------------------------------
85
- private
86
-
87
- def is_in_engine?
88
- false
89
- end
90
-
91
- def random_json_data
92
- data = {}
93
- fields.each do |field, type|
94
- case type
95
- when "belongs_to"
96
- data["#{field}_id"] = 1
97
- when "integer"
98
- data[field] = 1+ rand(1000)
99
- else
100
- data[field] = random_string
101
- end
102
- end
103
- data.to_json.to_s
104
- end
105
-
106
- def random_string
107
- o = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten
108
- (0...50).map{ o[rand(o.length)] }.join
109
- end
110
-
111
- end
112
- end
113
- end