xforum 0.0.23 → 0.0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: daa8a9801c65c8378e2dada2148c71f10e8c2345
4
- data.tar.gz: 24d364fe9aff810ce12ae25f5f250f4b579e5c95
3
+ metadata.gz: fc117ec03d67331b03463b23ad6bd5f7a497e442
4
+ data.tar.gz: 9ea7c11c3b567a1af0265c3c08d13dc51facb1f8
5
5
  SHA512:
6
- metadata.gz: 5bc456f9dba77b0210c6e32501e690368d1a1012142722c41b8624d5c4e1d18f2ba5dc32e059e28d719040ff65e394ba35503ee51adf255b42adf4dedcdf6feb
7
- data.tar.gz: ec01ef886bc872f616270f4d54304596de545ea27b1482fe75e8ffebf36aa4b7ae0286bb5e6fedf744ecd11e93225150fbdb8a23b1f87104cdffe7bd97cd675c
6
+ metadata.gz: f5e609daa43c2f2ea42740b402dc8ab08de6623397426bb81abc4fc87aba334323643cb28756f970c8dbb460dc47b0f69abec8f8f299843a7478b7c7e7a29140
7
+ data.tar.gz: a6251e7c28d92c1785df25b1d92fa7842bfb78a74caca2bcc9ef31eb7e32c4f1fe2177f5cfb445d789ba149d5a3d06b5fa5ddc18f12247a4b48c1172aa28490f
@@ -60,8 +60,8 @@ module Xforum
60
60
  Category.create(name:'select category',closed:false,suggestion:false)
61
61
  end
62
62
  params[:hold_test]=='true' ?
63
- category_list= ForumAssist.named_array(Category.where(closed:false,suggestion:false).pluck(:id,:name,:closed,:restricted),[:id,:name,:closed,:restricted]) :
64
- category_list= ForumAssist.named_array(Category.all.pluck(:id,:name,:closed,:restricted),[:id,:name,:closed,:restricted])
63
+ category_list= Category.grab({closed:false,suggestion:false},[:id,:name,:closed,:restricted],{}) :
64
+ category_list= Category.grab('all',[:id,:name,:closed,:restricted],{})
65
65
  category_list=ForumAssist.make_last(category_list.clone, {key: :id,ref:Category.where(name:'request new category').pluck(:id)[0]})
66
66
  category_list=ForumAssist.make_first(category_list.clone,{key: :id,ref:Category.where(name:'select category').pluck(:id)[0]})
67
67
  category_list=PeopleList.check_restrictions(category_list.clone,user,'categories') unless user.forum_admin?
@@ -64,7 +64,7 @@ module Xforum
64
64
  if senate_list.nil? || senate_list.empty?
65
65
  []
66
66
  else
67
- voting=ForumAssist.named_array(Topic.where(id:topic_id).pluck(:vote,:votes),[:vote,:votes])[0]
67
+ voting=Topic.grab({id:topic_id},[:vote,:votes],{})[0]
68
68
  voting[:vote] ? votes=Topic.count_votes(JSON.load(voting[:votes])) : votes=0
69
69
  parent=Forum.look_for_key(senate_list,:parent,0)
70
70
  new_list=[]
@@ -90,7 +90,7 @@ module Xforum
90
90
  end
91
91
 
92
92
  def self.clear_user_topic(user_id,topic_id)
93
- comments=ForumAssist.named_array(Forum.where(topic_id:topic_id).order(:tag).pluck(:id,:tag),[:id,:tag])
93
+ comments=Forum.grab({topic_id:topic_id},[:id,:tag],{order:[:tag]})
94
94
  tags=[]
95
95
  test_comments=comments.clone
96
96
  test_comments.each{ |comment|
@@ -28,7 +28,7 @@ module Xforum
28
28
 
29
29
  def self.get_photo(params)
30
30
  params[:id].nil? || params[:id] == '' ? which = {tag:params[:tag]} : which = {id:params[:id]}
31
- data=ForumAssist.named_array(Forum.where(which).pluck(:id,:parent),[:id,:parent])[0]
31
+ data=Forum.grab(which,[:id,:parent],{})[0]
32
32
  urls=Photo.get_photos(data[:id])
33
33
  {tag:params[:tag],edit:params[:edit],urls:urls,id:data[:id],parent:data[:parent],count:params[:count].to_i+1}
34
34
  end
@@ -15,12 +15,12 @@ module Xforum
15
15
  unless params[:category] == 'select category'
16
16
  category_id=Category.where(name:params[:category]).pluck(:id)[0]
17
17
  params[:hold_test]=='true' ?
18
- topics=ForumAssist.named_array(Topic.where(category_id:category_id,closed:false,suggestion:false).pluck(:id,:name,:state,:restricted,:closed), [:id,:item,:state,:restricted,:closed]) :
19
- topics=ForumAssist.named_array(Topic.where(category_id:category_id).pluck(:id,:name,:state,:restricted,:closed), [:id,:item,:state,:restricted,:closed])
18
+ topics=Topic.grab({category_id:category_id,closed:false,suggestion:false}, [:id,:name,:state,:restricted,:closed],{swap:{name: :item}}) :
19
+ topics=Topic.grab({category_id:category_i}, [:id,:name,:state,:restricted,:closed],{swap:{name: :item}})
20
20
  topics=[] if topics[0][:id].nil?
21
21
  topics=PeopleList.check_restrictions(topics,user,'topic') unless user.forum_admin?
22
- a=ForumAssist.named_array(Topic.where(name:'select topic').pluck(:id,:name,:state,:restricted,:closed), [:id,:item,:state,:restricted,:closed])[0]
23
- b=ForumAssist.named_array(Topic.where(name:'request new topic').pluck(:id,:name,:state,:restricted,:closed), [:id,:item,:state,:restricted,:closed])[0]
22
+ a=Topic.grab({name:'select topic'},[:id,:name,:state,:restricted,:closed],{swap:{name: :item}})[0]
23
+ b=Topic.grab({name:'request new topic'}, [:id,:name,:state,:restricted,:closed],{swap:{name: :item}})[0]
24
24
  topics.unshift(a)
25
25
  topics.push(b)
26
26
  {list_data:Translation.translate_list(topics,params[:language],'topic'),id:params[:list]}
@@ -1,3 +1,16 @@
1
+ # forum_id t.integer
2
+ # user_id t.integer
3
+ # topic_id t.integer
4
+ # category_id t.integer
5
+ # language_id t.integer
6
+ # hyperlink_id t.integer
7
+ # suggestion, t.boolean default: false
8
+ # state, t.string limit: 20, default: new
9
+ # content t.text
10
+ # resolution t.text
11
+ # created_at t.datetime
12
+ # updated_at t.datetime
13
+
1
14
 
2
15
  module Xforum
3
16
  class Translation < ActiveRecord::Base
@@ -9,7 +22,7 @@ module Xforum
9
22
 
10
23
  def self.translate_to(list)
11
24
  list.each{|entry|
12
- translations=ForumAssist.named_array(Translation.where(forum_id:entry[:id]).pluck(:language,:content),[:language,:content])
25
+ translations=AssitMe.named_array(Translation.where(forum_id:entry[:id]).pluck(:language,:content),[:language,:content])
13
26
  entry.store(:translations,translations)
14
27
  }
15
28
  list
@@ -52,9 +65,11 @@ module Xforum
52
65
 
53
66
  # noinspection RubyLiteralArrayInspection
54
67
  def self.get_translations(params)
55
- language = Language.get_me(params)
56
- topic = Topic.where(name:params[:topic]).pluck(:id)[0]
57
- ForumAssist.named_array(Translation.where(topic_id:topic,language_id:language,state:['new','open']).pluck(:forum_id,:content,:suggestion),[:forum_id,:translation,:suggestion])
68
+ language_id = Language.get_me(params)
69
+ topic_id = Topic.where(name:params[:topic]).pluck(:id)[0]
70
+ ForumAssist.named_array(Translation.where(topic_id:topic_id,language_id:language_id,state:['new','open']).pluck(:forum_id,:content,:suggestion),[:forum_id,:item,:suggestion])
71
+ #Translation.grab({topic_id:topic_id,language_id:language_id,state:['new','open']},[:forum_id,:item,:suggestion],{swap:{name: :item}})
72
+
58
73
  end
59
74
 
60
75
  def self.add_one(params,topic_id,user_id,forum_id)
@@ -0,0 +1,69 @@
1
+ module ActiveRecordExtension
2
+
3
+ extend ActiveSupport::Concern
4
+
5
+ # add your instance methods here
6
+ def foo
7
+ "foo"
8
+ end
9
+
10
+ # add your static(class) methods here
11
+ module ClassMethods
12
+ def grab(which,what,options)
13
+ pluck=Assist.make_string_list(what)
14
+ unless options[:swap].nil?
15
+ swaps=options[:swap]
16
+ swaps.each_key { |key|
17
+ index=what.index(key.to_sym)
18
+ what[index]=swaps[key.to_sym]
19
+ }
20
+ end
21
+ order=Assist.make_string_list(options[:sort]) unless options.nil? || options[:sort].nil?
22
+ if which=='all'
23
+ order.nil? ?
24
+ Assist.named_array(self.all.pluck(pluck),what) :
25
+ Assist.named_array(self.all.order(order).pluck(pluck),what)
26
+ else
27
+ order.nil? ?
28
+ Assist.named_array(self.where(which).pluck(pluck),what) :
29
+ Assist.named_array(self.where(which).order(order).pluck(pluck),what)
30
+ end
31
+ end
32
+ end
33
+
34
+ module Assist
35
+
36
+ def self.make_string_list(alist)
37
+ plucking=''
38
+ alist.each {|entry|
39
+ plucking.concat(',' ) unless plucking==''
40
+ plucking.concat(entry.to_s)
41
+ }
42
+ plucking
43
+ end
44
+
45
+ def self.named_array(data,what)
46
+ data = Array.new(what.size,nil) if data.nil? || data.empty?
47
+ if data.size==1
48
+ double=true
49
+ data.push(data[0])
50
+ end
51
+ pseudo= !data[0].is_a?(Array) && what.size>1
52
+ temp=Array.new{{}}
53
+ pseudo ? size=1 : size=data.size
54
+ (0...size).each {|i|
55
+ temp[i]={}
56
+ datax=data[i]
57
+ (0...what.size).each { |j|
58
+ pseudo ? temp[i].store(what[j], data[j]) : temp[i].store(what[j], datax[j]) }
59
+ Rails.logger.debug 'hello'
60
+ }
61
+ temp.shift if double
62
+ temp
63
+ end
64
+
65
+ end
66
+ end
67
+
68
+ # include the extension
69
+ ActiveRecord::Base.send(:include, ActiveRecordExtension)
data/lib/xforum/engine.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Xforum
2
+ require "active_record_extension"
2
3
  class Engine < ::Rails::Engine
3
4
  isolate_namespace Xforum
4
5
 
@@ -1,3 +1,3 @@
1
1
  module Xforum
2
- VERSION = '0.0.23'
2
+ VERSION = '0.0.24'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xforum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.23
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert D Blanton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-17 00:00:00.000000000 Z
11
+ date: 2014-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -220,6 +220,7 @@ files:
220
220
  - db/migrate/20140601_create_forum_forums.rb
221
221
  - db/migrate/20140602_add_restricted_to_category.rb
222
222
  - db/migrate/20140602_change_suggestion_default.rb
223
+ - lib/active_record_extension.rb
223
224
  - lib/tasks/xforum_tasks.rake
224
225
  - lib/xforum.rb
225
226
  - lib/xforum/engine.rb
@@ -275,7 +276,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
275
276
  requirements:
276
277
  - - "~>"
277
278
  - !ruby/object:Gem::Version
278
- version: '2.1'
279
+ version: '2.0'
279
280
  required_rubygems_version: !ruby/object:Gem::Requirement
280
281
  requirements:
281
282
  - - "~>"