shabng 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/DOC/CommandRef.rdoc CHANGED
@@ -39,6 +39,26 @@ And you'll see a list of all your posts. Now, when editing, you can choose the a
39
39
 
40
40
  Just follow the instructions to complete the steps.
41
41
 
42
+ == Adding Files to a Post
43
+ You can now add assets to your post. It's a two-step process. First create your post (as above), then you can add files, including images, video, audio and other general files. To add a new asset, execute the command:
44
+
45
+ shabng new asset [num]
46
+
47
+ Use the ID number for the post you wish to add assets to. You'll be asked to provide the path to the file you wish to upload:
48
+
49
+ shabng new asset 1
50
+ Enter path to file: ~/Desktop/test.png
51
+
52
+ If the file exists at the path you provide, it will be uploaded. You can then issue a list command to see the assets attached to this post:
53
+
54
+ shabng list assets 1
55
+ Here are your assets for post 1...
56
+ [2] - AVEGH.vcf - http://shabng.com/assets/1/2
57
+ [3] - headshotJan09.jpg - http://shabng.com/assets/1/3
58
+ [4] - test.png - http://shabng.com/assets/1/4
59
+
60
+ The provided URL is what you'll use in your post.
61
+
42
62
  == Going live with a post
43
63
 
44
64
  When you're ready to go live with your post, issue the push command:
data/HISTORY CHANGED
@@ -11,3 +11,7 @@
11
11
 
12
12
  ==0.0.8 - November 14, 2010
13
13
  * Addition of sequence attribute for categories (same technique and reason as for posts...)
14
+
15
+ ==0.0.9
16
+ * Fixed bug with listing of categories (says you're looking at posts...)
17
+ * Initial support for images, using the new asset command. In this iteration, assets are tied to posts. You can upload images, video, files, audio... a URL is supplied in the list assets [num] command which you can then use in your post.
data/bin/shabng CHANGED
@@ -6,7 +6,7 @@ require 'rest-client'
6
6
  require 'console_editor'
7
7
  require 'xmlsimple'
8
8
  #require 'ap'
9
- require 'post.rb'
9
+ require '../lib/post.rb'
10
10
 
11
11
  SB_VERSION = "0.0.8"
12
12
 
@@ -60,12 +60,21 @@ arg3 = ARGV[2]
60
60
 
61
61
  if arg == "list"
62
62
  # list all blog posts
63
- puts "Here are your blog postings..."
64
63
  @post = Post.new(@urlstring, @apikey)
65
64
  if arg2.nil? || arg2 == "posts"
65
+ puts "Here are your blog postings..."
66
66
  @post.list("posts")
67
67
  elsif arg2 == "categories"
68
+ puts "Here are your categories..."
68
69
  @post.list("categories")
70
+ elsif arg2 == "assets"
71
+ if arg3.nil?
72
+ puts "Here are all your assets..."
73
+ @post.list("assets")
74
+ else
75
+ puts "Here are your assets for post #{arg3}..."
76
+ @post.list("assets", arg3)
77
+ end
69
78
  end
70
79
 
71
80
  elsif arg == "new"
@@ -89,6 +98,17 @@ elsif arg == "new"
89
98
  category = STDIN.gets.chomp
90
99
  @post = Post.new(@urlstring, @apikey)
91
100
  @post.newcat(category)
101
+ elsif arg2 == "asset"
102
+ if arg3.nil?
103
+ puts "Specify an ID number for a post provided by the list command."
104
+ else
105
+ print "Enter path to file: "
106
+ asset = File.expand_path(STDIN.gets.chomp)
107
+ if File.exists?(asset)
108
+ @post = Post.new(@urlstring, @apikey)
109
+ @post.upload(asset, arg3)
110
+ end
111
+ end
92
112
  end
93
113
 
94
114
  elsif arg == "edit"
data/lib/post.rb CHANGED
@@ -20,7 +20,7 @@ class Post
20
20
  puts "Blog post has been saved with ID " + post["id"].first["content"]
21
21
  end
22
22
 
23
- def list(action)
23
+ def list(action, id=nil)
24
24
  if action == "posts"
25
25
  docs = RestClient.get @urlstring + "/posts", :params=>{:api_key=>@apikey}
26
26
  posts = XmlSimple.xml_in(docs)
@@ -38,7 +38,24 @@ class Post
38
38
  post["category"].each do |c|
39
39
  puts "[" + c["sequence"].first["content"] + "] " + c["name"].first
40
40
  end
41
+ elsif action == "assets"
42
+ if id.nil?
43
+ xml = RestClient.get @urlstring + "/assets", :params=>{:api_key => @apikey}
44
+ else
45
+ xml = RestClient.get @urlstring + "/assets", :params=>{:api_key => @apikey, :id => id}
46
+ end
47
+ assets = XmlSimple.xml_in(xml)
48
+
49
+ #require 'ap'
50
+
51
+ assets["array"].first["array"].each do |a|
52
+ if a.nil? == false
53
+ # ap(a)
54
+ puts "[" + a["sequence"].first["content"] + "] - " + a["asset-file-name"].first + " - " + "http://shabng.com/assets/" + a["post-id"].first["content"] + "/" + a["sequence"].first["content"]
55
+ end
56
+ end
41
57
  end
58
+
42
59
  end
43
60
 
44
61
  def edit(action, sel)
@@ -100,6 +117,10 @@ class Post
100
117
  puts "New category has been saved!"
101
118
  end
102
119
 
120
+ def upload(asset, id)
121
+ xml = RestClient.post @urlstring + "/assets", :api_key => @apikey, :post=>{:id=>id, :asset=>File.new(asset, "rb")}
122
+ end
123
+
103
124
  def push(sel)
104
125
  save = RestClient.put @urlstring + "/posts/" + sel, :api_key => @apikey, :post => {:status=>"Published"}
105
126
  puts "Your post is now live."
data/shabng.gemspec CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'shabng'
10
- s.version = '0.0.8'
11
- s.date = '2010-11-14'
10
+ s.version = '0.0.9'
11
+ s.date = '2010-11-16'
12
12
  s.rubyforge_project = 'shabng'
13
13
 
14
14
  ## Make sure your summary is short. The description may be as long
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shabng
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aaron Vegh
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-14 00:00:00 -05:00
18
+ date: 2010-11-16 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency