scms 4.2.6 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDYyNWM0MTM0MWYzZjE4MDE3N2RiMjhmMzY5MmQ5YjhmN2U4NGIxNg==
4
+ M2Q5Yjg1ZTM4OGM2YWYxN2FlZjM3NGY5NjdjZmFjY2NkM2FkMzEyYw==
5
5
  data.tar.gz: !binary |-
6
- YTM2NjlkMTQ4YWI5NmY4ZTQ2OGJiMGEwN2ZiMDU5MDYzYmE1ZGZjMw==
6
+ ZTFhMTIwMzFjZjYxZThiN2UyMmQzMDA4NGY3ZjYwM2M2YWJkMGY2Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Zjk5OWEyZTY2ZmU3YTViZmE5NGY1NWFjODMwYmJmYzZjOGQ0MTkxNDhjNWYw
10
- MzdhZDJlZmE1Yjc1ODc0NjI5NmY2YmU4OTQzZDAxMzc2YTg2OWNhZDlmZDU5
11
- MzMxYmEyYmNiYTg0OTg1N2E5OGZkNjQ0NmUzZWU2NjI1ZTI1MjA=
9
+ M2Y2YWM4NGE3Zjk2MDk0MWYyMDhlZTQ4NzYwOWVmZTAzMTMxYjUzMGY3ZDYy
10
+ MmNiNzFlY2JiY2JlMjU4ZWY4N2ZiNzMwZGUwMTVhYTMzZTk5MzI5YWM5YTI2
11
+ ZDYxMmI2MWQ2Y2VhZmQxZmMwNTk5OGYyOTViMTdjYzhmN2QwMDg=
12
12
  data.tar.gz: !binary |-
13
- ZWIxNGFhYzMyYTU1OTIzMGM4YWVjODY1NmYwYWU2M2U3NTgxNWM3MWNlZDNj
14
- ZjAzZTAyYzQ4ODliN2E4ODQwM2YzN2M4NTkwY2I4NGNhZjNjZmViZmI4NGJm
15
- N2UyZTEyMTM2ZDg0MTc2ZDRmMWJiM2MxMmZkMzAwYTdlNTY1ZjE=
13
+ M2Y0NTAyYmI3ZmY0YmU2ZTI0OThiMTZhYjVkOGExMThiZGFmY2NmMzBhNWYx
14
+ MGMyNzMxZWI1M2VhNDk5MDQ0ZDU5NDUzY2FmOTI2ZDFiMmExNjc4OWQ3ODI4
15
+ Mzc2Nzc4MjM4ZmI4NWYwZmY5NjczMjI1Yjg1NjdiMWU3M2M3MzY=
data/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ scms (4.2.6)
5
+ cprobert-s3sync
6
+ filewatcher
7
+ launchy
8
+ listen
9
+ maruku
10
+ nokogiri
11
+ packr
12
+ sass
13
+ webrick
14
+
15
+ GEM
16
+ remote: https://rubygems.org/
17
+ specs:
18
+ addressable (2.3.5)
19
+ celluloid (0.15.2)
20
+ timers (~> 1.1.0)
21
+ cprobert-s3sync (1.4.1)
22
+ ffi (1.9.3-x86-mingw32)
23
+ filewatcher (0.3.2)
24
+ trollop (>= 1.16.2)
25
+ launchy (2.4.2)
26
+ addressable (~> 2.3)
27
+ listen (2.4.0)
28
+ celluloid (>= 0.15.2)
29
+ rb-fsevent (>= 0.9.3)
30
+ rb-inotify (>= 0.9)
31
+ maruku (0.7.1)
32
+ mini_portile (0.5.2)
33
+ nokogiri (1.6.1-x86-mingw32)
34
+ mini_portile (~> 0.5.0)
35
+ oyster (0.9.5)
36
+ packr (3.2.1)
37
+ oyster (>= 0.9.5)
38
+ rake (10.1.1)
39
+ rb-fsevent (0.9.4)
40
+ rb-inotify (0.9.3)
41
+ ffi (>= 0.5.0)
42
+ sass (3.2.13)
43
+ timers (1.1.0)
44
+ trollop (2.0)
45
+ webrick (1.3.1)
46
+
47
+ PLATFORMS
48
+ x86-mingw32
49
+
50
+ DEPENDENCIES
51
+ rake
52
+ scms!
data/bin/scms CHANGED
@@ -14,6 +14,9 @@ require "scms/version"
14
14
  require 'scms/scms-watcher.rb'
15
15
  require 'scms/scms-httpserver.rb'
16
16
 
17
+ require 'scms/deploy-s3.rb'
18
+ require 'scms/deploy-ftp.rb'
19
+
17
20
  class String
18
21
  def to_path(end_slash=false)
19
22
  "#{'/' if self[0]=='\\'}#{self.split('\\').join('/')}#{'/' if end_slash}"
@@ -75,7 +78,11 @@ optparse = OptionParser.new do|opts|
75
78
  # This displays the help screen, all programs are assumed to have this option.
76
79
  opts.on( '-h', '--help', 'Display this help screen' ) do
77
80
  puts "Default action = build; default website directory = current working directory"
81
+ puts ""
78
82
  puts opts
83
+ puts ""
84
+ puts "Get the lowdown at: http://cprobert.github.io/Static-CMS"
85
+ puts ""
79
86
  exit
80
87
  end
81
88
  end
@@ -96,11 +103,11 @@ $website = Folders[:website]
96
103
  $watch = options[:watch]
97
104
  $cmsmode = options[:mode] == "cms"
98
105
 
99
- # ScmsUtils.log "System root folder = #{Folders[:root]}"
100
- # ScmsUtils.log "Website folder = #{Folders[:website]}"
101
- # ScmsUtils.log "Destination dir = #{Folders[:destination]}"
102
- # ScmsUtils.log "Config dir = #{Folders[:config]}"
103
- # ScmsUtils.log "Mode = #{options[:mode]}"
106
+ ScmsUtils.log "System root folder = #{Folders[:root]}"
107
+ ScmsUtils.log "Website folder = #{Folders[:website]}"
108
+ ScmsUtils.log "Destination dir = #{Folders[:destination]}"
109
+ ScmsUtils.log "Config dir = #{Folders[:config]}"
110
+ ScmsUtils.log "Mode = #{options[:mode]}"
104
111
 
105
112
  raise "Invalid working directory! #{Folders[:website]}" if !File::directory?(Folders[:website])
106
113
  Dir.chdir Folders[:website]
@@ -151,4 +158,9 @@ if options[:publish]
151
158
  mimetypefile = File.join(Folders[:assets], "mime.types")
152
159
  S3Deploy.sync(Folders[:website], Folders[:config], mimetypefile)
153
160
  end
161
+
162
+ if File.exists?(File.join(Folders[:config], "_ftpconfig.yml"))
163
+ puts "Deploying to FTP"
164
+ FtpDeploy.sync(Folders[:website], Folders[:config])
165
+ end
154
166
  end
@@ -0,0 +1,139 @@
1
+ require 'net/ftp'
2
+ require 'fileutils'
3
+
4
+ require 'scms/extensions.rb'
5
+ require 'scms/scms-utils.rb'
6
+
7
+ module FtpDeploy
8
+
9
+ # yml file example:
10
+
11
+ # host: localhost
12
+ # port: 21
13
+ # username: exampleuser
14
+ # password: seCre7Squr1al
15
+ # passive: true
16
+ # directory: /htdocs
17
+
18
+ def FtpDeploy.sync(website, config)
19
+
20
+ ftpYamlPath=File.join(config, "_ftpconfig.yml")
21
+ settings = YAML.load_file(ftpYamlPath)
22
+ throw "No gost defined in _ftpconfig.yml settings file" if settings['host'] == nil
23
+
24
+ host = settings['host']
25
+ port = (settings['port'] || 21).to_i
26
+ passive = settings['passive'] || true
27
+ remote_dir = settings['directory'] || "/"
28
+
29
+ ScmsUtils.boldlog("Sending site over FTP (host: #{host}, port: #{port})")
30
+ begin
31
+ if settings['username'].nil?
32
+ print "FTP Username: "
33
+ username = $stdin.gets.chomp
34
+ else
35
+ username = settings['username']
36
+ end
37
+
38
+ if settings['password'].nil?
39
+ print "FTP Password: "
40
+ # We hide the entered characters before to ask for the password
41
+ system "stty -echo"
42
+ password = $stdin.gets.chomp
43
+ system "stty echo"
44
+ else
45
+ password = settings['password']
46
+ end
47
+ rescue NoMethodError, Interrupt
48
+ # When the process is exited, we display the characters again
49
+ # And we exit
50
+ system "stty echo"
51
+ exit
52
+ end
53
+
54
+ ftp = FtpDeploy::Ftp.new(host, port, {:username => username, :password => password, :passive => passive})
55
+ puts "\r\nConnected to server. Sending site"
56
+ ftp.sync(website, remote_dir)
57
+ puts "Successfully sent site"
58
+ end
59
+
60
+ class Ftp
61
+ attr_reader :host, :port, :username, :password, :passive
62
+
63
+ def initialize(host, port = 21, options = Hash.new)
64
+ options = {:username => nil, :password => nil}.merge(options)
65
+ @host, @port = host, port
66
+ @username, @password = options[:username], options[:password]
67
+ @passive = options[:passive]
68
+ end
69
+
70
+ def sync(local, distant)
71
+ connect do |ftp|
72
+ send_dir(ftp, local, distant)
73
+ end
74
+ end
75
+
76
+ private
77
+ def connect
78
+ begin
79
+ Net::FTP.open(host) do |ftp|
80
+ ftp.passive = @passive
81
+ #ftp.debug_mode = true
82
+ ftp.connect(host, port)
83
+ ftp.login(username, password)
84
+ puts ftp.welcome
85
+ yield ftp
86
+ end
87
+ rescue Exception=>e
88
+ ScmsUtils.errLog(e.message)
89
+ ScmsUtils.log(e.backtrace.inspect)
90
+ end
91
+ end
92
+
93
+ def send_dir(ftp, local, distant)
94
+ begin
95
+ ftp.mkdir(distant)
96
+ rescue Net::FTPPermError
97
+ # We don't do anything. The directory already exists.
98
+ # TODO : this is also risen if we don't have write access. Then, we need to raise.
99
+ end
100
+ Dir.foreach(local) do |file_name|
101
+
102
+ # If the file/directory is hidden (first character is a dot), we ignore it
103
+ next if file_name =~ /^(\.|\.\.)$/
104
+ next if file_name =~ /^(\.)/
105
+ next if file_name =~ /^_/
106
+
107
+ #puts file_name
108
+
109
+ if ::File.stat(local + "/" + file_name).directory?
110
+ # It is a directory, we recursively send it
111
+ begin
112
+ ftp.mkdir(distant + "/" + file_name)
113
+ rescue Net::FTPPermError
114
+ # We don't do anything. The directory already exists.
115
+ # TODO : this is also risen if we don't have write access. Then, we need to raise.
116
+ end
117
+ send_dir(ftp, local + "/" + file_name, distant + "/" + file_name)
118
+ else
119
+ # It's a file, we just send it
120
+ localFilePath = local + "/" + file_name
121
+ remoteFilePath = distant + "/" + file_name
122
+
123
+ if File.binary?(local + "/" + file_name)
124
+ puts "#{file_name} (binary)"
125
+ ftp.putbinaryfile(localFilePath, remoteFilePath)
126
+ else
127
+ puts "#{file_name} (text)"
128
+ ftp.puttextfile(localFilePath, remoteFilePath)
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ private
135
+ def host_with_port
136
+ "#{host}:#{port}"
137
+ end
138
+ end
139
+ end
File without changes
@@ -0,0 +1,21 @@
1
+ class File
2
+
3
+ # def self.is_bin?(f)
4
+ # file_test = %x(file #{f})
5
+
6
+ # # http://stackoverflow.com/a/8873922
7
+ # file_test = file_test.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode('UTF-8', 'UTF-16')
8
+
9
+ # file_test !~ /text/
10
+ # end
11
+
12
+ def File.binary? name
13
+ open name do |f|
14
+ while (b=f.read(256)) do
15
+ return true if b[ "\0"]
16
+ end
17
+ end
18
+ false
19
+ end
20
+
21
+ end
@@ -61,7 +61,7 @@ module ScmsWatcher
61
61
  # Listen to changed to folders that start with an underscore (_)
62
62
  folders = []
63
63
  Dir.glob('*').select { |fn| File.directory?(fn) and (fn.match(/^_/) ) }.each do|f|
64
- folders.push(f)
64
+ folders.push(f)
65
65
  end
66
66
  puts "Listening to #{folders}"
67
67
  listener = Listen.to(folders, force_polling: true) do |modified, added, removed|
data/lib/scms/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Scms
2
- VERSION = "4.2.6"
2
+ VERSION = "4.3.0"
3
3
  end
data/lib/scms.rb CHANGED
@@ -6,7 +6,6 @@ module Scms
6
6
  require 'scms/scms-bundler.rb'
7
7
  require 'scms/scms-parser.rb'
8
8
  require 'scms/scms-xmlhandler.rb'
9
- require 'scms/s3deploy.rb'
10
9
 
11
10
  require 'fileutils'
12
11
  require 'pathname'
@@ -50,6 +49,7 @@ module Scms
50
49
  ScmsUtils.writelog("type NUL > #{bootstrap}", website)
51
50
  end
52
51
  end
52
+ ScmsUtils.log("Generating pages")
53
53
  Scms.generatePages(website, settings, options)
54
54
  else
55
55
  ScmsUtils.errLog("Config is empty")
@@ -60,10 +60,32 @@ module Scms
60
60
  end
61
61
 
62
62
  def Scms.generatePages(website, settings, options)
63
- # build pages defined in config file
64
- Scms.generatePagesFromSettings(website, settings, options)
65
63
  # build pages pased on _pages folder
66
64
  Scms.generatePagesFromFolder(website, settings, options)
65
+ # build pages defined in config file
66
+ Scms.generatePagesFromSettings(website, settings, options)
67
+ end
68
+
69
+ def Scms.generatePagesFromFolder(website, settings, options)
70
+ pagesFolder = File.join(website, "_pages")
71
+ Dir.glob("#{pagesFolder}/**/*/").each do |pageFolder|
72
+ pagename = File.basename(pageFolder, ".*")
73
+ pageconfig = nil
74
+ pageconfig = Scms.getSettings(pageFolder) if File.exists?(File.join(pageFolder, "_config.yml"))
75
+ pageOptions = PageOptions.new(pagename, website, pageconfig, settings)
76
+ views = Hash.new {}
77
+ if pageconfig != nil
78
+ views = Scms.getSettingsViews(pageconfig["views"], website, pageOptions, options) if pageconfig["views"] != nil
79
+ end
80
+
81
+ Dir.glob(File.join(pageFolder, "*")).reject { |f| f =~ /\.yml$/ || File.directory?(f) }.each do |view|
82
+ viewname = File.basename(view, ".*")
83
+ viewpath = Pathname.new(view).relative_path_from(Pathname.new(website)).to_s
84
+ viewmodel = Scms.getViewModel(viewname, viewpath, website, pageOptions, options)
85
+ views[viewname] = Scms.renderView(viewpath, viewmodel)
86
+ end
87
+ Scms.savePage(settings, website, pageOptions, views, options)
88
+ end
67
89
  end
68
90
 
69
91
  def Scms.generatePagesFromSettings(website, settings, options)
@@ -105,28 +127,6 @@ module Scms
105
127
  return views
106
128
  end
107
129
 
108
- def Scms.generatePagesFromFolder(website, settings, options)
109
- pagesFolder = File.join(website, "_pages")
110
- Dir.glob("#{pagesFolder}/**/*/").each do |pageFolder|
111
- pagename = File.basename(pageFolder, ".*")
112
- pageconfig = nil
113
- pageconfig = Scms.getSettings(pageFolder) if File.exists?(File.join(pageFolder, "_config.yml"))
114
- pageOptions = PageOptions.new(pagename, website, pageconfig, settings)
115
- views = Hash.new {}
116
- if pageconfig != nil
117
- views = Scms.getSettingsViews(pageconfig["views"], website, pageOptions, options) if pageconfig["views"] != nil
118
- end
119
-
120
- Dir.glob(File.join(pageFolder, "*")).reject { |f| f =~ /\.yml$/ || File.directory?(f) }.each do |view|
121
- viewname = File.basename(view, ".*")
122
- viewpath = Pathname.new(view).relative_path_from(Pathname.new(website)).to_s
123
- viewmodel = Scms.getViewModel(viewname, viewpath, website, pageOptions, options)
124
- views[viewname] = Scms.renderView(viewpath, viewmodel)
125
- end
126
- Scms.savePage(settings, website, pageOptions, views, options)
127
- end
128
- end
129
-
130
130
  def Scms.getViewModel(viewname, viewpath, website, pageOptions, options, viewData = nil)
131
131
  #puts "parsing view: #{viewname}"
132
132
 
data/scms.gemspec CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency "webrick"
37
37
  spec.add_dependency "launchy"
38
38
  spec.add_dependency "nokogiri"
39
+ #spec.add_dependency "ptools"
39
40
 
40
41
  #spec.add_development_dependency "bundler", "~> 1.3"
41
42
  spec.add_development_dependency "rake"
data/setup.cmd ADDED
@@ -0,0 +1,4 @@
1
+ @echo off
2
+
3
+ @call gem install bundler
4
+ @call bundle install
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scms
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.6
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Courtenay Probert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cprobert-s3sync
@@ -162,6 +162,7 @@ files:
162
162
  - .gitattributes
163
163
  - .gitignore
164
164
  - Gemfile
165
+ - Gemfile.lock
165
166
  - LICENSE.txt
166
167
  - README.md
167
168
  - Rakefile
@@ -224,7 +225,9 @@ files:
224
225
  - bin/scms-server
225
226
  - build commands.txt
226
227
  - lib/scms.rb
227
- - lib/scms/s3deploy.rb
228
+ - lib/scms/deploy-ftp.rb
229
+ - lib/scms/deploy-s3.rb
230
+ - lib/scms/extensions.rb
228
231
  - lib/scms/scms-bundler.rb
229
232
  - lib/scms/scms-customHandler.rb
230
233
  - lib/scms/scms-helpers.rb
@@ -237,6 +240,7 @@ files:
237
240
  - lib/scms/version.rb
238
241
  - lib/scms/yui.rb
239
242
  - scms.gemspec
243
+ - setup.cmd
240
244
  homepage: http://cprobert.github.io/Static-CMS/
241
245
  licenses:
242
246
  - MIT