Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 2090 Bytes
1 | class TaskSupport |
2 | class << self |
3 | def establish_connection |
4 | unless ActiveRecord::Base.connected? |
5 | connection_hash = YAML.load_file("#{Rails.root}/config/database.yml").to_hash |
6 | env_connection = connection_hash[RAILS_ENV] |
7 | ActiveRecord::Base.establish_connection(env_connection) |
8 | end |
9 | end |
10 | def config_export(path = "#{Rails.root}/config/radiant_config.yml") |
11 | self.establish_connection |
12 | FileUtils.mkdir_p(File.dirname(path)) |
13 | if File.open(File.expand_path(path), 'w') { |f| YAML.dump(Radiant::Config.to_hash.to_yaml,f) } |
14 | puts "Radiant::Config saved to #{path}" |
15 | end |
16 | end |
17 | def config_import(path = "#{Rails.root}/config/radiant_config.yml", clear = nil) |
18 | self.establish_connection |
19 | Radiant::Config.delete_all if clear |
20 | if File.exist?(path) |
21 | configs = YAML.load(YAML.load_file(path)) |
22 | configs.each do |key, value| |
23 | c = Radiant::Config.find_or_initialize_by_key(key) |
24 | c.value = value |
25 | c.save |
26 | end |
27 | puts "Radiant::Config updated from #{path}" |
28 | else |
29 | puts "No file exists at #{path}" |
30 | end |
31 | end |
32 | |
33 | # Write the combined content of files in dir into cache_file in the same dir. |
34 | # |
35 | def cache_files(dir, files, cache_file) |
36 | cache_content = files.collect { |f| |
37 | File.read(File.join(dir, f)) }.join("\n\n") |
38 | |
39 | cache_path = File.join(dir, cache_file) |
40 | rm(cache_path) if File.exists?(cache_path) |
41 | File.open(cache_path, "w+") { |f| f.write(cache_content) } |
42 | end |
43 | |
44 | # Reads through the layout file and returns an array of JS filenames |
45 | # |
46 | def find_admin_js |
47 | layout = "#{RADIANT_ROOT}/app/views/layouts/application.html.haml" |
48 | js_regexp = /javascript_include_tag %w\((.*)\), :cache => 'admin\/all/ |
49 | files = File.open(layout) { |f| f.read.match(js_regexp)[1].split } |
50 | files.collect { |f| f.split('/').last + '.js' } |
51 | end |
52 | |
53 | def cache_admin_js |
54 | dir = "#{Rails.root}/public/javascripts/admin" |
55 | cache_files(dir, find_admin_js, 'all.js') |
56 | end |
57 | end |
58 | end |