vitae 0.1.4 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32,15 +32,15 @@ class CV
32
32
 
33
33
 
34
34
  def name
35
- @name ||= data_hash.delete("name")
35
+ @name ||= data_hash.delete("name")
36
36
  end
37
37
 
38
38
  def vitae_config
39
- @vitae_config ||= data_hash.delete("vitae_config")
39
+ @vitae_config ||= data_hash.delete("vitae_config")
40
40
  end
41
41
 
42
42
  def data_hash
43
- @data_hash ||= YAML::load_file(@yaml_file)
43
+ @data_hash ||= (YAML::load_file(@yaml_file) rescue Hash.new)
44
44
  end
45
45
 
46
46
 
@@ -93,7 +93,7 @@ class Node
93
93
  end
94
94
 
95
95
  def child_node_class_from_yaml(value)
96
- Node.types[value["node_type"]] if value.respond_to? :[]
96
+ Node.types[value["node_type"]] if value.is_a? Hash
97
97
  end
98
98
 
99
99
  def child_node_class_from_name(name)
@@ -1,5 +1,6 @@
1
1
  require 'sinatra/base'
2
2
  require 'haml'
3
+ require 'pdfkit'
3
4
  require "vitae/server/helpers"
4
5
  require "vitae/server/node"
5
6
 
@@ -9,7 +10,7 @@ class Server < Sinatra::Base
9
10
  set :public, File.join(Vitae::project_root, "themes") rescue ''
10
11
 
11
12
  before do
12
- request.path_info = CV.first.link if CV.size==1
13
+ request.path_info = CV.first.link if CV.size==1 && request.path_info=='/'
13
14
  end
14
15
 
15
16
  get '/' do
@@ -21,11 +22,28 @@ class Server < Sinatra::Base
21
22
  send_file File.join(File.dirname(__FILE__), "assets", "favicon.ico"), :type => 'image/x-icon', :disposition => 'inline'
22
23
  end
23
24
 
24
- get '/:name' do
25
+ get '/:path' do
25
26
  reload_nodes_module if ENV["RACK_ENV"]=="development"
26
27
 
27
- @cv = CV.find( params[:name] )
28
- haml :show
28
+ name, ext = params[:path].split('.')
29
+
30
+ @cv = CV.find( name )
31
+
32
+ case ext.to_s
33
+ when '', 'html', 'htm'
34
+ haml :show
35
+ when 'yaml', 'yml'
36
+ yaml_path = File.join(Vitae::project_root, "cvs", "#{@cv.file_name}.yaml")
37
+ send_file yaml_path, :type => 'text/yaml', :disposition => 'inline'
38
+ when 'pdf'
39
+ content_type 'application/pdf', :charset => 'utf-8'
40
+
41
+ pdf = PDFKit.new(haml(:show), :page_size => 'Letter', :print_media_type => true)
42
+ pdf.stylesheets << File.join(Server::public, current_theme, "application.css")
43
+ pdf.to_pdf
44
+ else
45
+ "Sorry, we don't have anything with a .#{ext} extension here."
46
+ end
29
47
  end
30
48
 
31
49
  def reload_nodes_module
@@ -1,5 +1,6 @@
1
1
  %h1#title Vitae
2
2
  %ul
3
3
  - @cvs.each do |cv|
4
- %li
5
- %h2= link_to cv.name, cv.link
4
+ - if cv.name
5
+ %li
6
+ %h2= link_to cv.name, cv.link
@@ -1,5 +1,10 @@
1
1
  = haml :vcard, :locals => { :name => @cv.name, :contact_details => @cv["contact"] } if @cv["contact"]
2
2
 
3
+ #download-links
4
+ = link_to "pdf", @cv.link+".pdf"
5
+ = link_to "html", @cv.link
6
+ = link_to "yaml", @cv.link+".yaml"
7
+
3
8
  = Vitae::Nodes::BaseNode.new(@cv.except(%w[vitae_config contact]))
4
9
 
5
10
  %br
@@ -19,49 +19,4 @@
19
19
  - postal-code: 9016
20
20
  - phones: !omap
21
21
  - home: (03) 477 99 44
22
- - mobile: 027 477 7723
23
-
24
- - In Short:
25
- Live in Dunedin, NZ. Program a bit.
26
-
27
- - Projects: !omap
28
- - Vitae:
29
- start: 2010-12-01
30
- description: A structured CV publishing system, specifically the one used to generate and very likely serve this CV.
31
- role: Designer and programmer.
32
- - Mewzet.com:
33
- start: 2009-01-01
34
- url: http://mewzet.com
35
- description: A web application to teach music theory online.
36
- role: Co-founder, designer and programmer.
37
- - GunnMap:
38
- start: 2007-06-01
39
- end: 2008-01-01
40
- url: http://gunn.co.nz/map
41
- description: A system to help wikipedia contributors very easily create maps of country level demographics. Wikimedia has a <a href="http://commons.wikimedia.org/wiki/Category:Maps_generated_with_GunnMap">list</a> of some of the generated maps.
42
- role: Designer and programmer
43
- - AstroTour:
44
- start: 2006-01-01
45
- end: 2007-12-30
46
- url: http://gunn.co.nz/astrotour
47
- description: An interactive, customisble, scriptable, 3D, in browser simulation of the solar system.
48
- role: Designer and programmer
49
-
50
- - Expertise:
51
- Ruby: prefer strong
52
- Rails: prefer strong
53
- Sinatra: prefer strong
54
- Flash: prefer strong
55
- Flex: prefer strong
56
- ActionScript: prefer strong
57
- Javascript: prefer
58
- Jquery: prefer
59
- CSS: weak
60
- rspec: weak
61
- html:
62
- haml: prefer strong
63
- sass: prefer weak
64
- mysql: prefer
65
- RR: prefer
66
- Test::Unit: prefer strong
67
- <em>shoulda</em>: prefer
22
+ - mobile: 027 477 7723
@@ -1,4 +1,8 @@
1
- /* CSS by Maxim Chernyak and Juriy Zaytsev - https://github.com/maxim/maxim.github.com */
1
+ /*
2
+ CSS by Maxim Chernyak and Juriy Zaytsev - https://github.com/maxim/maxim.github.com
3
+ Modified slightly fo vitae.
4
+ */
5
+
2
6
  body {
3
7
  font-family: Garamond, "Hoefler Text", "Times New Roman", Times, serif;
4
8
  font-size: 1.1em;
@@ -42,6 +46,8 @@ img {
42
46
 
43
47
  #download-links a {
44
48
  display: block;
49
+ padding: 12px;
50
+ text-align: right;
45
51
  }
46
52
 
47
53
  ul {
@@ -224,7 +230,7 @@ li {
224
230
  /* PRINT MEDIA */
225
231
 
226
232
  @media print {
227
- body { color: #000; font-family: Cambria, Georgia, Times, "Times New Roman", serif; font-size: 1.3em; }
233
+ body { color: #000; font-family: Cambria, Georgia, Times, "Times New Roman", serif; font-size: 1.4em; }
228
234
  em { font-weight: bold; }
229
235
  a:link, a:visited { color: #007; text-decoration: none; }
230
236
  .tags li { color: #000; }
@@ -1,3 +1,3 @@
1
1
  module Vitae
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -47,6 +47,57 @@ class ActiveServerTest < VitaeServerTestCase
47
47
  end
48
48
  end
49
49
 
50
+ test "we have format links" do
51
+ with_project :sals do
52
+ get '/'
53
+
54
+ assert_select "#download-links" do
55
+ assert_select "a[href='/sajal_shah']", "html"
56
+ assert_select "a[href='/sajal_shah.yaml']", "yaml"
57
+ assert_select "a[href='/sajal_shah.pdf']", "pdf"
58
+ end
59
+ end
60
+ end
61
+
62
+ test "serves pdfs" do
63
+ with_project :default do
64
+ get '/arthur_gunn.pdf'
65
+ assert last_response.ok?
66
+
67
+ # how to test this?
68
+ end
69
+ end
70
+
71
+ test "serves yaml files" do
72
+ with_project :default do
73
+ get '/arthur_gunn.yaml'
74
+ assert last_response.ok?
75
+
76
+ # check that we get some yaml:
77
+ assert_match %r(--- !omap\n- name: Arthur Gunn), last_response.body
78
+ end
79
+ end
80
+
81
+ test "repsonds to pages with .html extension" do
82
+ with_project :default do
83
+ get '/arthur_gunn.html'
84
+ assert last_response.ok?
85
+
86
+ # do some standard content checks:
87
+ check_includes_standard_assets
88
+ assert_select "h1", "Arthur Gunn"
89
+ end
90
+ end
91
+
92
+ test "gives error if user requests an unsupported extension" do
93
+ with_project :default do
94
+ get '/arthur_gunn.bogus'
95
+ # assert !last_response.ok?
96
+
97
+ assert_equal("Sorry, we don't have anything with a .bogus extension here.", last_response.body)
98
+ end
99
+ end
100
+
50
101
  def check_includes_standard_assets theme="default"
51
102
  assert_select "script[src='/#{theme}/application.js'][type='text/javascript']"
52
103
  assert_select "link[href='/#{theme}/application.css'][rel='stylesheet'][type='text/css']"
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.add_dependency "sinatra", "~>1.1.0"
16
16
  s.add_dependency "haml", "~>3.0.0"
17
17
  s.add_dependency "thor", "~>0.14.0"
18
+ s.add_dependency "pdfkit", "~>0.5.0"
18
19
 
19
20
  s.add_development_dependency "nokogiri", "~>1.4.0"
20
21
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 4
9
- version: 0.1.4
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Arthur Gunn
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-20 00:00:00 +13:00
17
+ date: 2011-02-04 00:00:00 +13:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -63,9 +63,24 @@ dependencies:
63
63
  type: :runtime
64
64
  version_requirements: *id003
65
65
  - !ruby/object:Gem::Dependency
66
- name: nokogiri
66
+ name: pdfkit
67
67
  prerelease: false
68
68
  requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ - 5
76
+ - 0
77
+ version: 0.5.0
78
+ type: :runtime
79
+ version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: nokogiri
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
69
84
  none: false
70
85
  requirements:
71
86
  - - ~>
@@ -76,7 +91,7 @@ dependencies:
76
91
  - 0
77
92
  version: 1.4.0
78
93
  type: :development
79
- version_requirements: *id004
94
+ version_requirements: *id005
80
95
  description: Vitae is to CVs what rubygems is to ruby code. Still very under development. Semi-usable at this point.
81
96
  email:
82
97
  - arthur@gunn.co.nz