oos4ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +39 -0
- data/README.txt +1 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/lib/oos4ruby/auth.rb +39 -0
- data/lib/oos4ruby/bean.rb +189 -0
- data/lib/oos4ruby/category.rb +28 -0
- data/lib/oos4ruby/collection.rb +96 -0
- data/lib/oos4ruby/contact.rb +72 -0
- data/lib/oos4ruby/contacts.rb +11 -0
- data/lib/oos4ruby/entry.rb +91 -0
- data/lib/oos4ruby/feed.rb +65 -0
- data/lib/oos4ruby/http_invoker.rb +140 -0
- data/lib/oos4ruby/oos.rb +54 -0
- data/lib/oos4ruby/search.rb +75 -0
- data/lib/oos4ruby/service.rb +13 -0
- data/lib/oos4ruby/site.rb +220 -0
- data/lib/oos4ruby/sites.rb +11 -0
- data/lib/oos4ruby/user.rb +122 -0
- data/lib/oos4ruby/version.rb +9 -0
- data/lib/oos4ruby.rb +72 -0
- data/log/debug.log +0 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +74 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +27 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_oos4ruby.rb +85 -0
- data/website/index.html +131 -0
- data/website/index.txt +62 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +98 -0
data/lib/oos4ruby.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module Oos4ruby
|
2
|
+
class UnknownUser < ArgumentError; end
|
3
|
+
|
4
|
+
AtomNamespace = 'http://www.w3.org/2005/Atom'
|
5
|
+
AppNamespace = 'http://www.w3.org/2007/app'
|
6
|
+
OosNamespace = 'http://11870.com/api/oos'
|
7
|
+
XhtmlNamespace = 'http://www.w3.org/1999/xhtml'
|
8
|
+
GeoRSSNamespace = 'http://www.georss.org/georss/10'
|
9
|
+
GmlNamespace = 'http://www.opengis.net/gml'
|
10
|
+
XmlNamespaces = {
|
11
|
+
'app' => AppNamespace,
|
12
|
+
'atom' => AtomNamespace,
|
13
|
+
'xhtml' => XhtmlNamespace,
|
14
|
+
'oos' => OosNamespace,
|
15
|
+
'georss' => GeoRSSNamespace,
|
16
|
+
'gml' => GmlNamespace
|
17
|
+
}
|
18
|
+
|
19
|
+
AtomEntryContentType = 'application/atom+xml;type=entry'
|
20
|
+
|
21
|
+
OOS_URL = 'http://11870.com'
|
22
|
+
API_URL = OOS_URL + '/api/v1'
|
23
|
+
|
24
|
+
SITES_URL = Oos4ruby::API_URL + '/sites'
|
25
|
+
CONTACTS_URL = Oos4ruby::API_URL + '/contacts'
|
26
|
+
USERS_URL = Oos4ruby::API_URL + '/users'
|
27
|
+
TAGS_URL = API_URL + '/tags'
|
28
|
+
LISTS_URL = API_URL + '/lists'
|
29
|
+
PRIVACY_URL = API_URL + '/privacy'
|
30
|
+
TRUSTED_URL = API_URL + '/trusted'
|
31
|
+
SEARCH_URL = API_URL + '/search'
|
32
|
+
end
|
33
|
+
%w(rubygems builder).each { |f| require f }
|
34
|
+
|
35
|
+
require 'oos4ruby/http_invoker.rb'
|
36
|
+
require 'oos4ruby/auth.rb'
|
37
|
+
require 'oos4ruby/bean.rb'
|
38
|
+
require 'oos4ruby/category.rb'
|
39
|
+
require 'oos4ruby/collection.rb'
|
40
|
+
require 'oos4ruby/contact.rb'
|
41
|
+
require 'oos4ruby/contacts.rb'
|
42
|
+
require 'oos4ruby/entry.rb'
|
43
|
+
require 'oos4ruby/feed.rb'
|
44
|
+
require 'oos4ruby/oos.rb'
|
45
|
+
require 'oos4ruby/search.rb'
|
46
|
+
require 'oos4ruby/service.rb'
|
47
|
+
require 'oos4ruby/site.rb'
|
48
|
+
require 'oos4ruby/sites.rb'
|
49
|
+
require 'oos4ruby/user.rb'
|
50
|
+
require 'oos4ruby/version.rb'
|
51
|
+
|
52
|
+
|
53
|
+
class String
|
54
|
+
def underscore
|
55
|
+
self.to_s.gsub(/::/, '/').
|
56
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
57
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
58
|
+
tr("-", "_").
|
59
|
+
downcase
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
require 'rexml/element'
|
64
|
+
class REXML::Element
|
65
|
+
def add_category(term, scheme = nil, label = nil)
|
66
|
+
c = REXML::Element.new('category', self)
|
67
|
+
c.add_attribute('term', term)
|
68
|
+
c.add_attribute('scheme', scheme) if scheme
|
69
|
+
c.add_attribute('label', label) if label
|
70
|
+
c
|
71
|
+
end
|
72
|
+
end
|
data/log/debug.log
ADDED
File without changes
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/txt2html
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
begin
|
5
|
+
require 'newgem'
|
6
|
+
rescue LoadError
|
7
|
+
puts "\n\nGenerating the website requires the newgem RubyGem"
|
8
|
+
puts "Install: gem install newgem\n\n"
|
9
|
+
exit(1)
|
10
|
+
end
|
11
|
+
require 'redcloth'
|
12
|
+
require 'syntax/convertors/html'
|
13
|
+
require 'erb'
|
14
|
+
require File.dirname(__FILE__) + '/../lib/oos4ruby/version.rb'
|
15
|
+
|
16
|
+
version = Oos4ruby::VERSION::STRING
|
17
|
+
download = 'http://rubyforge.org/projects/oos4ruby'
|
18
|
+
|
19
|
+
class Fixnum
|
20
|
+
def ordinal
|
21
|
+
# teens
|
22
|
+
return 'th' if (10..19).include?(self % 100)
|
23
|
+
# others
|
24
|
+
case self % 10
|
25
|
+
when 1: return 'st'
|
26
|
+
when 2: return 'nd'
|
27
|
+
when 3: return 'rd'
|
28
|
+
else return 'th'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Time
|
34
|
+
def pretty
|
35
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def convert_syntax(syntax, source)
|
40
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
41
|
+
end
|
42
|
+
|
43
|
+
if ARGV.length >= 1
|
44
|
+
src, template = ARGV
|
45
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
|
46
|
+
|
47
|
+
else
|
48
|
+
puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
|
49
|
+
exit!
|
50
|
+
end
|
51
|
+
|
52
|
+
template = ERB.new(File.open(template).read)
|
53
|
+
|
54
|
+
title = nil
|
55
|
+
body = nil
|
56
|
+
File.open(src) do |fsrc|
|
57
|
+
title_text = fsrc.readline
|
58
|
+
body_text = fsrc.read
|
59
|
+
syntax_items = []
|
60
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
61
|
+
ident = syntax_items.length
|
62
|
+
element, syntax, source = $1, $2, $3
|
63
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
64
|
+
"syntax-temp-#{ident}"
|
65
|
+
}
|
66
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
67
|
+
body = RedCloth.new(body_text).to_html
|
68
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
69
|
+
end
|
70
|
+
stat = File.stat(src)
|
71
|
+
created = stat.ctime
|
72
|
+
modified = stat.mtime
|
73
|
+
|
74
|
+
$stdout << template.result(binding)
|