subtitle_it 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +19 -0
- data/History.txt +53 -0
- data/License.txt +20 -0
- data/Manifest.txt +68 -0
- data/README.markdown +41 -0
- data/README.txt +102 -0
- data/Rakefile +4 -0
- data/bin/subtitle_it +66 -0
- data/config/hoe.rb +73 -0
- data/config/requirements.rb +15 -0
- data/lib/subtitle_it/bin.rb +132 -0
- data/lib/subtitle_it/fixes.rb +12 -0
- data/lib/subtitle_it/formats/ass.rb +13 -0
- data/lib/subtitle_it/formats/mpl.rb +29 -0
- data/lib/subtitle_it/formats/rsb.rb +37 -0
- data/lib/subtitle_it/formats/srt.rb +45 -0
- data/lib/subtitle_it/formats/sub.rb +49 -0
- data/lib/subtitle_it/formats/xml.rb +65 -0
- data/lib/subtitle_it/formats/yml.rb +18 -0
- data/lib/subtitle_it/generator.rb +15 -0
- data/lib/subtitle_it/languages.rb +60 -0
- data/lib/subtitle_it/movie.rb +24 -0
- data/lib/subtitle_it/movie_hasher.rb +30 -0
- data/lib/subtitle_it/platform_endl.rb +9 -0
- data/lib/subtitle_it/subdown.rb +107 -0
- data/lib/subtitle_it/subline.rb +25 -0
- data/lib/subtitle_it/substyle.rb +11 -0
- data/lib/subtitle_it/subtime.rb +41 -0
- data/lib/subtitle_it/subtitle.rb +76 -0
- data/lib/subtitle_it/version.rb +9 -0
- data/lib/subtitle_it.rb +22 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/spec/fixtures/godfather.srt +2487 -0
- data/spec/fixtures/huge.ass +22 -0
- data/spec/fixtures/movie.xml +28 -0
- data/spec/fixtures/movie.yml +163 -0
- data/spec/fixtures/pseudo.rsb +6 -0
- data/spec/fixtures/pulpfiction.sub +2025 -0
- data/spec/fixtures/puplfiction.mpl +12 -0
- data/spec/fixtures/sincity.yml +12 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +71 -0
- data/spec/subtitle_it/bin_spec.rb +142 -0
- data/spec/subtitle_it/fixes_spec.rb +0 -0
- data/spec/subtitle_it/formats/ass_spec.rb +5 -0
- data/spec/subtitle_it/formats/mpl_spec.rb +45 -0
- data/spec/subtitle_it/formats/rsb_spec.rb +42 -0
- data/spec/subtitle_it/formats/srt_spec.rb +57 -0
- data/spec/subtitle_it/formats/sub_spec.rb +49 -0
- data/spec/subtitle_it/formats/xml_spec.rb +60 -0
- data/spec/subtitle_it/formats/yml_spec.rb +20 -0
- data/spec/subtitle_it/generator_spec.rb +0 -0
- data/spec/subtitle_it/movie_hasher_spec.rb +13 -0
- data/spec/subtitle_it/movie_spec.rb +25 -0
- data/spec/subtitle_it/subdown_spec.rb +94 -0
- data/spec/subtitle_it/subline_spec.rb +30 -0
- data/spec/subtitle_it/substyle_spec.rb +1 -0
- data/spec/subtitle_it/subtime_spec.rb +73 -0
- data/spec/subtitle_it/subtitle_spec.rb +40 -0
- data/spec/subtitle_it_spec.rb +11 -0
- data/subtitle_it.gemspec +41 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/rspec.rake +21 -0
- metadata +152 -0
data/script/txt2html
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
GEM_NAME = 'subtitle_it' # what ppl will type to install your gem
|
4
|
+
RUBYFORGE_PROJECT = 'subtitle_it'
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
begin
|
8
|
+
require 'newgem'
|
9
|
+
require 'rubyforge'
|
10
|
+
rescue LoadError
|
11
|
+
puts "\n\nGenerating the website requires the newgem RubyGem"
|
12
|
+
puts "Install: gem install newgem\n\n"
|
13
|
+
exit(1)
|
14
|
+
end
|
15
|
+
require 'redcloth'
|
16
|
+
require 'syntax/convertors/html'
|
17
|
+
require 'erb'
|
18
|
+
require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
|
19
|
+
|
20
|
+
version = SubtitleIt::VERSION::STRING
|
21
|
+
download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
22
|
+
|
23
|
+
def rubyforge_project_id
|
24
|
+
RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT]
|
25
|
+
end
|
26
|
+
|
27
|
+
class Fixnum
|
28
|
+
def ordinal
|
29
|
+
# teens
|
30
|
+
return 'th' if (10..19).include?(self % 100)
|
31
|
+
# others
|
32
|
+
case self % 10
|
33
|
+
when 1: return 'st'
|
34
|
+
when 2: return 'nd'
|
35
|
+
when 3: return 'rd'
|
36
|
+
else return 'th'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Time
|
42
|
+
def pretty
|
43
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def convert_syntax(syntax, source)
|
48
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
49
|
+
end
|
50
|
+
|
51
|
+
if ARGV.length >= 1
|
52
|
+
src, template = ARGV
|
53
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
|
54
|
+
else
|
55
|
+
puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
|
56
|
+
exit!
|
57
|
+
end
|
58
|
+
|
59
|
+
template = ERB.new(File.open(template).read)
|
60
|
+
|
61
|
+
title = nil
|
62
|
+
body = nil
|
63
|
+
File.open(src) do |fsrc|
|
64
|
+
title_text = fsrc.readline
|
65
|
+
body_text_template = fsrc.read
|
66
|
+
body_text = ERB.new(body_text_template).result(binding)
|
67
|
+
syntax_items = []
|
68
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
69
|
+
ident = syntax_items.length
|
70
|
+
element, syntax, source = $1, $2, $3
|
71
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
72
|
+
"syntax-temp-#{ident}"
|
73
|
+
}
|
74
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
75
|
+
body = RedCloth.new(body_text).to_html
|
76
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
77
|
+
end
|
78
|
+
stat = File.stat(src)
|
79
|
+
created = stat.ctime
|
80
|
+
modified = stat.mtime
|
81
|
+
|
82
|
+
$stdout << template.result(binding)
|