forked from binaryage/totalfinder-web
/
rakefile
116 lines (102 loc) · 3.17 KB
/
rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# coding: utf-8
ROOT = File.expand_path('.')
WWW = File.join(ROOT, 'www')
BLOG = File.join(ROOT, 'blog')
TOTALFINDER = File.join(ROOT, 'totalfinder')
VISOR = File.join(ROOT, 'visor')
FIREQUERY = File.join(ROOT, 'firequery')
FIRERAINBOW = File.join(ROOT, 'firerainbow')
FIRELOGGER = File.join(ROOT, 'firelogger')
DRYDROP = File.join(ROOT, 'drydrop')
XREFRESH = File.join(ROOT, 'xrefresh')
begin
require 'term/ansicolor'
include Term::ANSIColor
rescue LoadError
raise 'Run "gem install term-ansicolor"'
end
begin
require 'appscript'
include Appscript
rescue LoadError
raise 'Run "gem install rb-appscript"'
end
def file_color(text); yellow(text); end
def dir_color(text); blue(text); end
def cmd_color(text); green(text); end
def sys(cmd)
puts blue("> "+cmd)
system(cmd)
end
def run_in_terminal(cmd, title, background=[0,0,0])
# see http://www.nach-vorne.de/2007/11/22/terminal-trick
# and http://onrails.org/articles/2007/11/28/scripting-the-leopard-terminal
# and http://blog.cbciweb.com/articles/2008/05/02/scripting-mac-terminal-using-ruby
begin
puts yellow("!> #{cmd}")
term = app('Terminal')
term.activate()
current_window = term.windows.first
old_tab = current_window.selected_tab.get()
tab = find_terminal_tab(background)
unless tab
app("System Events").application_processes["Terminal.app"].keystroke("t", :using => :command_down)
tab = current_window.tabs.last
end
term.do_script(cmd, :in => tab)
tab.background_color.set(background)
tab.title_displays_custom_title.set(true)
tab.custom_title.set(title)
current_window.selected_tab.set(old_tab)
sleep 0.1
rescue
die "OSX command failed"
end
end
def find_terminal_tab(color)
term = app('Terminal')
term.windows.get.each do |win|
begin
win.tabs.get.each do |tab|
return tab if color == tab.background_color.get()
end
rescue
end
end
nil
end
################################################################################
desc "run da server"
task :serve do
run_in_terminal("cd \"#{ROOT}\" && jekyll --auto --server 4003 --url http://totalfinder.binaryage.org --permalink pretty_flat", "totalfinder", [0,10000,3])
end
desc "optimize png images"
task :optimize do
Dir.glob(File.join(ROOT, 'shared', "**", "*.png")) do |file|
puts file
`optipng -i1 −o7 "#{file}"`
break
end
Dir.glob(File.join(ROOT, 'images', "**", "*.png")) do |file|
puts file
`optipng −i1 −o7 "#{file}"`
break
end
end
desc "update mainshot"
task :mainshot do
sys("cp images/showcase/showcase-dual-mode.png shared/img/totalfinder-mainshot-full.png")
sys("cp images/showcase/thumb-showcase-dual-mode.png shared/img/totalfinder-mainshot.png")
end
desc "update images"
task :update do
sys("mkdir -p tfdata")
sys("mount -t smbfs //guest:@whale/Store/tfdata tfdata")
sys("rsync -av --delete tfdata/products/showcase/English/ images/showcase/")
sys("cp tfdata/products/basic-screenshots/English/* images/")
sleep(2)
sys("umount tfdata")
sys("rm -rf tfdata")
puts red("run> rake mainshot")
end
task :default => :serve