classiccms 0.6.1 → 0.6.2

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.
@@ -90,21 +90,32 @@ module Classiccms
90
90
  end
91
91
  return errors
92
92
  end
93
- post '/upload/image' do
93
+ post '/upload' do
94
94
  image = Image.new
95
95
  image.file = params[:Filedata][:tempfile].read
96
96
  image.file.name = params[:Filedata][:filename]
97
- image.save
98
- show :images
97
+ if !image.save
98
+ file = Document.new
99
+ file.file = params[:Filedata][:tempfile].read
100
+ file.file.name = params[:Filedata][:filename]
101
+ file.save
102
+ end
103
+
104
+ return show(:images) + show(:files)
99
105
  end
100
106
  get '/images' do
101
107
  show :browse
102
108
  end
103
- post '/image/destroy' do
104
- image = Image.find(params[:id])
105
- image.destroy
109
+ post '/file/destroy' do
110
+ image = Image.where(:id => params[:id]).first
111
+ p image
112
+ if image != nil
113
+ image.destroy
114
+ else
115
+ Document.where(:id => params[:id]).first.destroy
116
+ end
106
117
  end
107
- get '/ckeditor/images' do
118
+ get '/ckeditor/files' do
108
119
  show :ckeditor
109
120
  end
110
121
 
@@ -17,7 +17,12 @@ class ImageType
17
17
  # Get the object as it was stored in the database, and instantiate
18
18
  # this custom class from it.
19
19
  def demongoize(object_id)
20
- Image.find(object_id).file
20
+ image = Image.where(:id => object_id).first
21
+ if image != nil
22
+ image.file
23
+ else
24
+ Dragonfly[:file].fetch_file(File.join(Dir.pwd, 'public/not_found.jpeg'))
25
+ end
21
26
  end
22
27
 
23
28
  # Takes any possible object and converts it to how it would be
@@ -1,5 +1,6 @@
1
1
  class Image
2
2
  include Mongoid::Document
3
+ include Mongoid::Timestamps
3
4
 
4
5
  field :file_uid
5
6
  field :file_name
@@ -7,3 +8,14 @@ class Image
7
8
  file_accessor :file
8
9
  validates_property :format, :of => :file, :in => [:jpg, :jpeg, :png, :gif]
9
10
  end
11
+
12
+ class Document
13
+ include Mongoid::Document
14
+ include Mongoid::Timestamps
15
+
16
+ field :file_uid
17
+ field :file_name
18
+
19
+ file_accessor :file
20
+ #validates_property :format, :of => :file
21
+ end
@@ -1,46 +1,72 @@
1
+
1
2
  $ ->
2
- new Image
3
+ new Browser
4
+
3
5
 
4
- class Image
6
+
7
+ class Browser
5
8
  constructor: ->
6
9
  @p =
7
10
  images: '.images'
8
- image: '.images .image img'
9
- destroy: '.images .image .destroy'
11
+ image: 'img'
12
+ destroy: '.destroy'
10
13
  button: '#file_upload'
11
14
  @listen()
12
-
15
+
13
16
  listen: ->
14
17
  $('#edit_bg').slideDown()
15
18
  @set_upload_button()
16
19
  @select()
17
20
  @destroy()
21
+ @add_tooltip()
22
+ $('ul.menu li').click (event) => @change_window($(event.currentTarget).attr('id'))
23
+
24
+ add_tooltip: ->
25
+ $('[rel=tooltip]').tooltip();
26
+ change_window: (id)->
27
+ console.log id
28
+ $('.menu li').removeClass('active')
29
+ $('#' + id).addClass('active')
30
+ if id == 'images'
31
+ $('.files').hide()
32
+ else
33
+ $('.images').hide()
34
+ $('.'+id).show()
18
35
 
19
36
  select: () ->
20
- $('img').click ->
37
+ $('.item').click ->
21
38
  input = $('input').first().val()
22
39
  url = $(this).attr('url')
23
- window.opener.CKEDITOR.tools.callFunction(input, url)
40
+ if input.length > 0
41
+ window.opener.CKEDITOR.tools.callFunction(input, url)
42
+ else
43
+ window.opener.$('#file_select').val($(this).attr('id'))
24
44
  self.close()
25
45
 
26
46
  destroy: () ->
27
- $(@p.images + ' .image').live 'mouseover mouseout', (event) =>
28
- if (event.type == 'mouseover')
29
- $(event.currentTarget).find('.destroy').show()
30
- else
31
- $(event.currentTarget).find('.destroy').hide()
32
47
  $(@p.destroy).click (event) =>
33
- id = $(event.currentTarget).parent().attr('id')
34
- $('.images').find('#' + id).hide()
35
- $.post '/cms/image/destroy', {id: id}
48
+ id = $(event.currentTarget).attr('data-id')
49
+ $('#' + id).hide()
50
+ $.post '/cms/file/destroy', {id: id}
36
51
 
37
52
  set_upload_button: ->
38
53
  if($('#file_upload').length != 0)
39
54
  $('#file_upload').uploadify
55
+ 'buttonClass' : 'btn btn-info'
56
+ 'buttonText' : 'upload bestanden'
40
57
  'swf' : '/cms/js/uploadify/uploadify.swf'
41
- 'uploader' : '/cms/upload/image'
58
+ 'uploader' : '/cms/upload'
59
+ 'queueID' : 'file_queue'
60
+ 'onSelect' : (file) =>
61
+ console.log(file)
62
+ $('#progress').append("<div class='alert alert-info' id='file-#{file.index}'><strong>"+ file.name + "</strong><button class='close' type='button' date-dismiss='alert'>x</button></div>")
63
+ 'onUploadComplete' : (file) =>
64
+ $("#progress #file-#{file.index}").hide();
42
65
  'onUploadSuccess' : (file, data, response) =>
43
- $(data).replaceAll(@p.images)
66
+ $('.wrapper').empty().append(data)
67
+ #$(data).replaceAll('.wrapper')
44
68
  @select()
45
69
  @destroy()
70
+ @add_tooltip()
71
+ @change_window($('ul.menu li.active').first().attr('id'))
46
72
 
@@ -1,3 +1,5 @@
1
+ go = ()->
2
+ console.log 'woohoo'
1
3
  class Cms
2
4
  constructor: ->
3
5
  @input = 'input[name=cms]'
@@ -40,7 +42,9 @@ class Image
40
42
  images: '#iki #edit_bg .images'
41
43
  image: '#iki #edit_bg .images .image img'
42
44
  destroy: '#iki #edit_bg .images .image .destroy'
43
- button: '#iki #edit_bg #file_upload'
45
+ button: '#iki #file_upload'
46
+
47
+ window.open('/cms/ckeditor/files?input='+$(@input).attr('id'),'upload','width=960,height=750,left=200,top=100,screenX=200,screenY=100')
44
48
  @listen()
45
49
 
46
50
  listen: ->
@@ -171,9 +175,10 @@ class Editor
171
175
  { name: 'links', items : [ 'Link','Unlink','-'] },
172
176
  { name: 'tools', items : [ 'Maximize' ] }
173
177
  ],
174
- filebrowserBrowseUrl : '/cms/ckeditor/images',
175
- filebrowserWindowWidth : '640',
176
- filebrowserWindowHeight : '480'
178
+ filebrowserBrowseUrl : '/cms/ckeditor/files',
179
+ filebrowserImageBrowseUrl : '/cms/ckeditor/files?Type=Images',
180
+ filebrowserWindowWidth : '960',
181
+ filebrowserWindowHeight : '750'
177
182
  }
178
183
  hover: ->
179
184
  $j(@p.buttons).mouseenter ->
@@ -1,3 +1,3 @@
1
1
  module Classiccms #:nodoc
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -1,3 +1,6 @@
1
1
  #edit_bg.popup
2
2
  = show :images
3
+ - if params[:Type] != 'Images'
4
+ .test
5
+
3
6
  %input{:type => 'hidden', :id => 'file_upload', :name=> 'file_upload'}
@@ -3,21 +3,41 @@
3
3
  %head
4
4
  %meta{:'http-equiv' => 'Content-Type', :content => 'text/html; charset=utf-8'}
5
5
  %title
6
-
7
- %link{:rel=>'stylesheet', :href=>'/cms/css/reset.css', :type=> 'text/css'}
8
- %link{:rel=>'stylesheet', :href=>'/cms/css/fonts.css', :type=> 'text/css'}
9
- %link{:rel=>'stylesheet', :href=>'/cms/css/icons.css', :type=> 'text/css'}
10
- %link{:rel=>'stylesheet', :href=>'/cms/css/popup.css', :type=> 'text/css'}
11
- %link{:rel=>'stylesheet', :href=>'/cms/css/scrollbar.css', :type=> 'text/css'}
12
- %link{:rel=>'stylesheet', :href=>'/cms/css/style.css', :type=> 'text/css'}
13
- %link{:rel=>'stylesheet', :href=>'/cms/css/images.css', :type=> 'text/css'}
14
-
6
+
7
+ %link{:rel=>'stylesheet', :href=>'/cms/bootstrap/css/bootstrap.min.css', :type=> 'text/css'}
8
+ /%link{:rel=>'stylesheet', :href=>'/cms/css/reset.css', :type=> 'text/css'}
9
+ /%link{:rel=>'stylesheet', :href=>'/cms/css/fonts.css', :type=> 'text/css'}
10
+ /%link{:rel=>'stylesheet', :href=>'/cms/css/icons.css', :type=> 'text/css'}
11
+ /%link{:rel=>'stylesheet', :href=>'/cms/css/popup.css', :type=> 'text/css'}
12
+ /%link{:rel=>'stylesheet', :href=>'/cms/css/scrollbar.css', :type=> 'text/css'}
13
+ /%link{:rel=>'stylesheet', :href=>'/cms/css/style.css', :type=> 'text/css'}
14
+ /%link{:rel=>'stylesheet', :href=>'/cms/css/images.css', :type=> 'text/css'}
15
+ %body#iki
16
+ .container{:style => 'margin-top: 20px'}
17
+ .row
18
+ .span4
19
+ - if request.params[:Type] != 'images'
20
+ .well.well-small
21
+ %ul.menu.nav.nav-list.bs-docs-sidenav
22
+ %li.active#images
23
+ %a{:href => '#images'}
24
+ %i.icon-camera
25
+ Foto's
26
+ %li#files
27
+ %a{:href => '#files'}
28
+ %i.icon-file
29
+ Bestanden
30
+ .well.well-small
31
+ %input{:type => 'hidden', :id => 'file_upload', :name=> 'file_upload'}
32
+ %input{:type => 'hidden', :name => 'return', :value => params[:CKEditorFuncNum]}
33
+ %br
34
+ .well.well-small#progress
35
+ .span7
36
+ .well.well-small.wrapper
37
+ = show :images
38
+ = show :files
39
+ /---- load js ----/
15
40
  %script{:type=>'text/javascript', :src=>'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'}
41
+ %script{:type=>'text/javascript', :src=>'/cms/bootstrap/js/bootstrap.min.js'}
16
42
  %script{:type=>'text/javascript', :src=>'/cms/js/uploadify/jquery.uploadify-3.1.min.js'}
17
43
  %script{:type=>'text/javascript', :src=>'/cms/js/images.js'}
18
- %body
19
- #iki
20
- %input{:type => 'hidden', :name => 'return', :value => params[:CKEditorFuncNum]}
21
- = show :browse
22
-
23
-
@@ -1,5 +1,6 @@
1
- .images
1
+ .images{:style => 'display: inline-block;'}
2
2
  - Image.all.each do |image|
3
- .image{:class => '', :id => image.id}
4
- .destroy
5
- %img{:src => image.file.process(:thumb, '113x113#').url, :url => image.file.url}
3
+ .span{:style => 'margin-bottom: 20px;', :id => image.id}
4
+ %button.btn.btn-mini.btn-danger.destroy{:style => 'position: absolute;', :type => 'button', :'data-original-title' => 'Verwijder', :rel => 'tooltip', :'data-id' => image.id}
5
+ %i.icon-trash.icon-white
6
+ %img.img-rounded.item{:style => 'height: 113px;', :id => image.id, :src => image.file.process(:thumb, '113x113#').url, :url => image.file.url}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classiccms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-08 00:00:00.000000000 Z
12
+ date: 2012-10-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec