diff --git a/app/views/case_studies/config.yml b/app/views/case_studies/config.yml
new file mode 100644
index 0000000..6def519
--- /dev/null
+++ b/app/views/case_studies/config.yml
@@ -0,0 +1,69 @@
+---
+- type: group
+ title: people
+ contents:
+ - type: numeric
+ noun: designer
+ source: num_of_designers
+ icon: user
+ - type: numeric
+ noun: user
+ source: num_of_users
+ icon: user
+- type: group
+ title: tools
+ contents:
+ - type: tags
+ source: tools
+ icon: pencil
+- type: group
+ title: tags
+ contents:
+ - type: tags
+ source: tags
+- type: group
+ title: characteristics
+ contents:
+ - type: text
+ title: development cycle
+ source: development_cycle
+ icon: pencil
+ - type: text
+ title: design phase
+ source: design_phase
+ icon: pencil
+ - type: text
+ title: privacy level
+ source: privacy_level
+ icon: pencil
+ - type: text
+ title: social setting
+ source: social_setting
+ icon: pencil
+ - type: boolean
+ title: customer is user
+ source: remote_project
+ icon0: remove
+ icon1: ok
+ - type: boolean
+ title: remote project
+ source: remote_project
+ icon0: remove
+ icon1: ok
+- type: group
+ title: project details
+ contents:
+ - type: text
+ title: project domain
+ source: project_domain
+ icon: pencil
+ - type: text
+ title: customer type
+ source: customer_type
+ icon: pencil
+- type: group
+ title: time
+ contents:
+ - type: tags
+ source: time_period
+ icon: time
diff --git a/app/views/design_methods/config.yml b/app/views/design_methods/config.yml
new file mode 100644
index 0000000..6def519
--- /dev/null
+++ b/app/views/design_methods/config.yml
@@ -0,0 +1,69 @@
+---
+- type: group
+ title: people
+ contents:
+ - type: numeric
+ noun: designer
+ source: num_of_designers
+ icon: user
+ - type: numeric
+ noun: user
+ source: num_of_users
+ icon: user
+- type: group
+ title: tools
+ contents:
+ - type: tags
+ source: tools
+ icon: pencil
+- type: group
+ title: tags
+ contents:
+ - type: tags
+ source: tags
+- type: group
+ title: characteristics
+ contents:
+ - type: text
+ title: development cycle
+ source: development_cycle
+ icon: pencil
+ - type: text
+ title: design phase
+ source: design_phase
+ icon: pencil
+ - type: text
+ title: privacy level
+ source: privacy_level
+ icon: pencil
+ - type: text
+ title: social setting
+ source: social_setting
+ icon: pencil
+ - type: boolean
+ title: customer is user
+ source: remote_project
+ icon0: remove
+ icon1: ok
+ - type: boolean
+ title: remote project
+ source: remote_project
+ icon0: remove
+ icon1: ok
+- type: group
+ title: project details
+ contents:
+ - type: text
+ title: project domain
+ source: project_domain
+ icon: pencil
+ - type: text
+ title: customer type
+ source: customer_type
+ icon: pencil
+- type: group
+ title: time
+ contents:
+ - type: tags
+ source: time_period
+ icon: time
diff --git a/config/info/case_studies.xml b/config/info/case_studies.xml
new file mode 100644
index 0000000..035a1b2
--- /dev/null
+++ b/config/info/case_studies.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+- type: group
+ title: tags
+ contents:
+ - {source: tags, type: tags}
+
+- type: group
diff --git a/config/info/design_methods.yml b/config/info/design_methods.yml
new file mode 100644
index 0000000..5e81092
--- /dev/null
+++ b/config/info/design_methods.yml
@@ -0,0 +1,23 @@
+production:
+ solr:
+ hostname: localhost
+ port: 8983
+ log_level: WARNING
+ path: /solr/production
+ # read_timeout: 2
+ # open_timeout: 0.5
+
+development:
+ solr:
+ hostname: localhost
+ port: 8982
+ log_level: INFO
+ path: /solr/development
+
+test:
+ solr:
+ hostname: localhost
+ port: 8981
+ log_level: WARNING
+ path: /solr/test
+
\ No newline at end of file
diff --git a/config/info/parser.rb b/config/info/parser.rb
new file mode 100644
index 0000000..8eceda5
--- /dev/null
+++ b/config/info/parser.rb
@@ -0,0 +1,39 @@
+require 'representable/yaml'
+require 'hash_control'
+require 'yaml'
+
+class Comment
+ include ::HashControl::Model
+ require_key :author, :body, :date
+ permit_key :image
+end
+comment = Comment.new(author: 'me', body: 'interesting stuff', date: Time.now)
+
+puts comment.author
+puts comment.body
+puts comment.date.class
+puts comment.image
+
+class User
+ include ::HashControl::Model
+ require_key :name, :age
+ permit_key :image
+end
+user = User.new(name: "hi", age: "over 18")
+
+puts user.name
+puts user.age
+
+# module UserRepresenter
+# include Representable::YAML
+
+# collection :hash, :style => :flow
+
+# def hash
+# [name, age]
+# end
+# end
+
+# user.extend(UserRepresenter).to_yaml
+# #=> ---
+# # hash: [Andrew, over 18]
diff --git a/config/routes.rb b/config/routes.rb
index 703b937..5d7ee07 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,39 +1,49 @@
DesignExchange::Application.routes.draw do
-
get "autocomplete_search", to: "application#search"
- resources :companies do
+ resources :companies do
resources :contacts
end
-
+
resources :characteristics do
resources :design_methods, only: [:index], shallow: true
end
-
+
resources :tags
resources :method_case_studies
root "application#index"
- resources :case_studies do
- collection do
- get "related_methods", to: "case_studies#related_methods"
+ case_studies = "studies"
+ resources "#{case_studies}", as: :case_studies, controller: :case_studies do
+ collection do
+ get "related", to: "case_studies#related_methods"
+ match "related_methods" => redirect("related"), via: [:get, :post]
get "search/:query", to: "application#search"
get "search", to: "application#search", :as => "search"
end
- member do
- get "related_methods", to: "case_studies#related_methods", :as => "related_methods"
+ member do
+ get "related", to: "case_studies#related_methods", :as => "related_methods"
+ match "related_methods" => redirect("related"), via: [:get, :post]
end
end
- resources :design_methods do
- collection do
+ # TODO: legacy redirect; remove these eventually
+ match "case_studies" => redirect("#{case_studies}"), via: [:get, :post]
+ match "case_studies/:suffix" => redirect("#{case_studies}/%{suffix}"), via: [:get, :post]
+
+ design_methods = "methods"
+ resources "#{design_methods}", as: :design_methods, controller: :design_methods do
+ collection do
get "search/:query", to: "application#search"
get "search", to: "application#search", :as => "search"
get "method_category/:category_id", to: "application#search", :as => "search_category"
end
end
+ # TODO: legacy redirect; remove these eventually
+ match "design_methods" => redirect("#{design_methods}"), via: [:get, :post]
+ match "design_methods/:suffix" => redirect("#{design_methods}/%{suffix}"), via: [:get, :post]
resources :discussions do
- collection do
+ collection do
get "search/:query", to: "application#search"
get "search", to: "application#search", :as => "search"
end
@@ -50,10 +60,6 @@
ActiveAdmin.routes(self)
devise_for :users
-
-
-
-
resources :method_categories, only: [:show]
resources :citations, only: [:show]
@@ -63,6 +69,5 @@
get 'search/(:query)', controller: 'design_methods', action: 'search', as: 'search'
- get ":action", to:"application##{:action}"
-
+ get ":action", to: "application##{:action}"
end
diff --git a/lib/dx/model_props/infos.rb b/lib/dx/model_props/infos.rb
new file mode 100644
index 0000000..9441735
--- /dev/null
+++ b/lib/dx/model_props/infos.rb
@@ -0,0 +1,140 @@
+require 'hash_control'
+
+module Dx
+ module ModelProps
+ def self.load_file(fname)
+ require 'yaml'
+ data = YAML.load_file(fname)
+ Group.parse(type: 'group', title: nil, contents: data).contents
+ end
+
+ TYPES = {}
+
+ module YamlSupport
+ def self.included(base)
+ base.extend ClassMethods
+ end
+
+ module ClassMethods
+ attr_reader :_yaml_key_order, :_yaml_type
+
+ def yaml_key_order(*key_order)
+ key_order.each do |key|
+ raise "Expected symbols, got #{key_order.inspect}" unless key.is_a? Symbol
+ end
+ @_yaml_key_order = [:type] + key_order
+ end
+
+ def yaml_type(type)
+ raise "Expected symbol, got #{type.inspect}" unless type.is_a? Symbol
+ @_yaml_type = type
+ TYPES[type] = self
+ end
+
+ def parse(data)
+ results = new(data)
+ results
+ end
+ end
+
+ def initialize(data)
+ super(data)
+ post_parse if respond_to? :post_parse
+ end
+
+ def ensure_ordered
+ keys_in_order.each { |key| @hash[key] = @hash.delete(key) }
+ end
+
+ def encode_with(coder)
+ repr = {}
+ keys_in_order.each { |key| repr[key.to_s] = self[key] }
+ coder.represent_map nil, repr
+ end
+
+ private
+
+ def keys_in_order(ordered_keys = nil)
+ ordered_keys ||= self.class._yaml_key_order
+ present_keys = @hash.keys.map(&:to_sym)
+ if present_keys != ordered_keys
+ ordered_keys -= (ordered_keys - present_keys)
+ ordered_keys += (present_keys - ordered_keys)
+ end
+ ordered_keys
+ end
+ end
+
+ YAML_KEY_ORDER = [
+ :type,
+ :title, :noun,
+ :source,
+ :icon, :icon0, :icon1,
+ :contents
+ ]
+
+ class Group
+ include ::HashControl::Model
+ include YamlSupport
+ yaml_type :group
+ require_key :type, :contents
+ require_key :title
+ yaml_key_order(*YAML_KEY_ORDER)
+
+ def post_parse
+ contents.map! { |item| TYPES[item[:type].to_sym].parse(item) }
+ end
+ end
+
+ class Numeric
+ include ::HashControl::Model
+ include YamlSupport
+ yaml_type :numeric
+ require_key :type, :source, :noun, :icon
+ yaml_key_order(*YAML_KEY_ORDER)
+ end
+
+ class Tags
+ include ::HashControl::Model
+ include YamlSupport
+ yaml_type :tags
+ require_key :type, :source
+ permit_key :icon
+ yaml_key_order(*YAML_KEY_ORDER)
+ end
+
+ class Text
+ include ::HashControl::Model
+ include YamlSupport
+ yaml_type :text
+ require_key :type, :source, :title, :icon
+ yaml_key_order(*YAML_KEY_ORDER)
+ end
+
+ class Boolean
+ include ::HashControl::Model
+ include YamlSupport
+ yaml_type :boolean
+ require_key :type, :source, :title, :icon0, :icon1
+ yaml_key_order(*YAML_KEY_ORDER)
+ end
+ end
+end
+
+if __FILE__ == $PROGRAM_NAME
+ case (subcommand = ARGV.shift)
+ when 'parse'
+ ARGV.each { |fname| puts(ModelProps.load_file(fname).to_yaml) }
+ when 'norm', 'normalize'
+ ARGV.each do |fname|
+ print "#{fname}..."
+ $stdout.flush
+ normalized = ModelProps.load_file(fname).to_yaml
+ File.open(fname, 'w') { |file| file.write(normalized) }
+ puts "done."
+ end
+ else
+ puts "Unknown command: #{subcommand}"
+ exit 1
+ end
+end