ayadn 1.1.1 → 1.1.3

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.
data/README.md CHANGED
@@ -36,27 +36,9 @@ Uninstall:
36
36
 
37
37
  `gem uninstall ayadn`
38
38
 
39
- ### OS X, LINUX, BSD
40
-
41
- Please use something like RVM or RBENV to install Ruby if necessary.
42
-
43
- You can also use the Ruby shipped with your system but you shouldn't, as it would require root privileges.
44
-
45
- ### OTHER PLATFORMS
46
-
47
- Ayadn 1.0.x isn't compatible with Windows: there's too many issues due to external Gems and POSIX-dependant tools.
48
-
49
- That may change in the future...
50
-
51
- ### ALPHA-BETA-PRE
52
-
53
- This is only necessary if you installed a pre-1.0 testing version:
54
-
55
- Users of alpha, beta or pre-release versions should first uninstall the old versions with `gem uninstall ayadn` then run `ayadn set defaults` after installing version 1.0 (note that this will replace the config file contents).
56
-
57
39
  # DOCUMENTATION
58
40
 
59
- Read the [manual](https://github.com/ericdke/na/blob/master/MANUAL.md).
41
+ [Read the docs at ayadn-app.net/doc](http://ayadn-app.net/doc/)
60
42
 
61
43
  # CONTACT
62
44
 
@@ -65,3 +47,5 @@ Author: [@ericd](http://app.net/ericd)
65
47
  App account: [@ayadn](http://app.net/ayadn)
66
48
 
67
49
  Website: [ayadn-app.net](http://ayadn-app.net)
50
+
51
+ ADN Directory: [Ayadn](https://directory.app.net/app/345/ayadn/)
data/ayadn.gemspec CHANGED
@@ -6,12 +6,13 @@ require 'ayadn/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "ayadn"
8
8
  spec.version = Ayadn::VERSION
9
- spec.author = "Eric Dejonckheere"
9
+ spec.author = "Eric Dejonckheere"
10
10
  spec.email = "eric@aya.io"
11
11
  spec.summary = %q{App.net command-line client.}
12
- spec.description = %q{App.net command-line client: toolbox to access and manage your ADN data, show your streams, post, manage conversations, star/follow/repost... and many, many more.}
12
+ spec.description = %q{App.net command-line client: toolbox to access and manage your ADN data, show your streams, post, manage conversations, star/follow/repost... and many, many more. http://ayadn-app.net/doc/}
13
13
  spec.homepage = "http://ayadn-app.net"
14
14
  spec.license = "MIT"
15
+ spec.metadata = { "documentation" => "http://ayadn-app.net/doc/" }
15
16
 
16
17
  spec.bindir = 'bin'
17
18
  spec.files = `git ls-files`.split("\n")
data/lib/ayadn/action.rb CHANGED
@@ -226,8 +226,7 @@ module Ayadn
226
226
  missing_post_id unless post_id.is_integer?
227
227
  doing(options)
228
228
  id = get_original_id(post_id, @api.get_details(post_id, options))
229
- stream = @api.get_convo(id, options)
230
- post_404(id) if meta_404(stream)
229
+ stream = get_convo id, options
231
230
  Databases.pagination["replies:#{id}"] = stream['meta']['max_id']
232
231
  render_view(stream, options)
233
232
  Scroll.new(@api, @view).convo(id, options) if options[:scroll]
@@ -238,6 +237,12 @@ module Ayadn
238
237
  end
239
238
  end
240
239
 
240
+ def get_convo id, options
241
+ stream = @api.get_convo(id, options)
242
+ post_404(id) if meta_404(stream)
243
+ stream
244
+ end
245
+
241
246
  def delete(post_id)
242
247
  begin
243
248
  missing_post_id unless post_id.is_integer?
data/lib/ayadn/app.rb CHANGED
@@ -3,7 +3,7 @@ module Ayadn
3
3
  class App < Thor
4
4
  package_name "Ayadn"
5
5
 
6
- %w{action api descriptions endpoints cnx view workers settings post status extend databases fileops logs pinboard set alias errors blacklist scroll authorize switch}.each { |r| require_relative "#{r}" }
6
+ %w{action api descriptions endpoints cnx view workers settings post status extend databases fileops logs pinboard set alias errors blacklist scroll authorize switch mark}.each { |r| require_relative "#{r}" }
7
7
 
8
8
  desc "timeline", "Show your App.net timeline, aka the Unified Stream (-tl)"
9
9
  map "unified" => :timeline
@@ -391,6 +391,10 @@ module Ayadn
391
391
  long_desc Descriptions.alias
392
392
  subcommand "alias", Alias
393
393
 
394
+ desc "mark POST (TITLE)", "Bookmark a conversation / manage bookmarks"
395
+ long_desc Descriptions.mark
396
+ subcommand "mark", Mark
397
+
394
398
  desc "download FILE", "Download the file with id FILE (-df)"
395
399
  map "-df" => :download
396
400
  long_desc Descriptions.download
@@ -4,7 +4,7 @@ module Ayadn
4
4
  class Databases
5
5
 
6
6
  class << self
7
- attr_accessor :users, :index, :pagination, :aliases, :blacklist
7
+ attr_accessor :users, :index, :pagination, :aliases, :blacklist, :bookmarks
8
8
  end
9
9
 
10
10
  def self.open_databases
@@ -13,14 +13,14 @@ module Ayadn
13
13
  @pagination = self.init "#{Settings.config[:paths][:pagination]}/pagination.db"
14
14
  @aliases = self.init "#{Settings.config[:paths][:db]}/aliases.db"
15
15
  @blacklist = self.init "#{Settings.config[:paths][:db]}/blacklist.db"
16
+ @bookmarks = self.init "#{Settings.config[:paths][:db]}/bookmarks.db"
16
17
  end
17
18
 
18
19
  def self.close_all
19
- @pagination.compact if (File.size("#{Settings.config[:paths][:pagination]}/pagination.db") > (250000))
20
- @index.compact if (File.size("#{Settings.config[:paths][:pagination]}/index.db") > (250000))
21
- [@users, @index, @pagination, @aliases, @blacklist].each do |db|
22
- db.flush
23
- db.close
20
+ [@users, @index, @pagination, @aliases, @blacklist, @bookmarks].each do |db|
21
+ db.compact
22
+ db.flush
23
+ db.close
24
24
  end
25
25
  end
26
26
 
@@ -126,6 +126,18 @@ module Ayadn
126
126
  stream['meta']['max_id'].to_i > @pagination[title].to_i
127
127
  end
128
128
 
129
+ def self.add_bookmark bookmark
130
+ @bookmarks[bookmark[:id]] = bookmark
131
+ end
132
+
133
+ def self.delete_bookmark post_id
134
+ @bookmarks.delete post_id
135
+ end
136
+
137
+ def self.rename_bookmark post_id, new_title
138
+ @bookmarks[post_id][:title] = new_title
139
+ end
140
+
129
141
  end
130
142
 
131
143
  end
@@ -896,6 +896,68 @@ module Ayadn
896
896
  \n\n
897
897
  USAGE
898
898
  end
899
+ def self.mark
900
+ <<-USAGE
901
+ Bookmark a conversation and manage your bookmarks.
902
+
903
+ Usage:
904
+
905
+ ayadn mark add 30594331
906
+
907
+ ayadn mark add 30594331 convo_name
908
+
909
+ ayadn mark list
910
+
911
+ ayadn mark delete 30594331
912
+
913
+ ayadn mark rename 'convo name' 'other name'
914
+ \n\n
915
+ USAGE
916
+ end
917
+ def self.mark_add
918
+ <<-USAGE
919
+ Add a conversation to your conversations bookmarks.
920
+
921
+ Usage:
922
+
923
+ ayadn mark add 30594331
924
+
925
+ ayadn mark add 30594331 'title'
926
+
927
+ You don't have to specify the root post of the conversation, any post within the thread will work.
928
+ \n\n
929
+ USAGE
930
+ end
931
+ def self.mark_list
932
+ <<-USAGE
933
+ List your bookmarked conversations.
934
+
935
+ Usage:
936
+
937
+ ayadn mark list
938
+ \n\n
939
+ USAGE
940
+ end
941
+ def self.mark_delete
942
+ <<-USAGE
943
+ Delete entry from your bookmarked conversations.
944
+
945
+ Usage:
946
+
947
+ ayadn mark delete 30594331
948
+ \n\n
949
+ USAGE
950
+ end
951
+ def self.mark_rename
952
+ <<-USAGE
953
+ Rename a bookmarked conversation.
954
+
955
+ Usage:
956
+
957
+ ayadn mark rename 30594331 'new title'
958
+ \n\n
959
+ USAGE
960
+ end
899
961
  def self.blacklist
900
962
  <<-USAGE
901
963
  Manage your blacklist. Commands: add, remove, list, import.
data/lib/ayadn/mark.rb ADDED
@@ -0,0 +1,153 @@
1
+ # encoding: utf-8
2
+ module Ayadn
3
+ class Mark < Thor
4
+
5
+ desc "add POST_ID (TITLE)", "Create a bookmark for this conversation"
6
+ long_desc Descriptions.mark_add
7
+ def add(*args)
8
+ begin
9
+ unless args.empty?
10
+ post_id, convo_title = args[0], args[1]
11
+ else
12
+ init
13
+ abort Status.wrong_arguments
14
+ end
15
+ abort Status.error_missing_post_id unless post_id.is_integer?
16
+ convo_title = post_id if convo_title.nil?
17
+ action, workers, view, users, bucket = Action.new, Workers.new, View.new, [], []
18
+ view.clear_screen
19
+ puts "\nAnalyzing conversation...\n".inverse
20
+ stream = action.get_convo post_id, options
21
+ posts = workers.build_posts(stream['data'].reverse)
22
+ posts.each do |id, post|
23
+ users << "#{post[:original_poster]}"
24
+ post[:mentions].each {|mention| users << "#{mention}"}
25
+ bucket << post
26
+ end
27
+ users.uniq!
28
+ now = Time.now.to_s
29
+ bookmark = {
30
+ id: post_id,
31
+ root_id: bucket[0][:id],
32
+ last_id: (bucket.last)[:id],
33
+ title: convo_title,
34
+ first_date: bucket[0][:date],
35
+ last_date: (bucket.last)[:date],
36
+ mark_date: now[0..18],
37
+ first_poster: bucket[0][:original_poster],
38
+ last_poster: (bucket.last)[:username],
39
+ users: users,
40
+ size: bucket.length,
41
+ url: bucket[0][:canonical_url],
42
+ root_text: bucket[0][:raw_text],
43
+ root_colorized_text: bucket[0][:text]
44
+ }
45
+ view.clear_screen
46
+ puts "Bookmarked conversation:\n".color(:green)
47
+ puts make_entry bookmark
48
+ Databases.add_bookmark bookmark
49
+ Logs.rec.info "Added conversation bookmark for post #{bookmark[:id]}."
50
+ puts Status.done
51
+ rescue => e
52
+ Errors.global_error("mark/add", args, e)
53
+ ensure
54
+ Databases.close_all
55
+ end
56
+ end
57
+
58
+ desc "list", "List your bookmarked conversations"
59
+ long_desc Descriptions.mark_list
60
+ option :raw, aliases: "-x", type: :boolean, desc: Descriptions.options_raw
61
+ def list
62
+ begin
63
+ init
64
+ list = []
65
+ Databases.bookmarks.each {|i,v| list << v}
66
+ if options[:raw]
67
+ jj JSON.parse(list.to_json)
68
+ exit
69
+ end
70
+ puts "\n"
71
+ list.each {|marked| puts make_entry marked; puts "\n"}
72
+ rescue => e
73
+ Errors.global_error("mark/list", nil, e)
74
+ ensure
75
+ Databases.close_all
76
+ end
77
+ end
78
+
79
+ desc "delete POST_ID", "Delete entry POST_ID from your bookmarked conversations"
80
+ long_desc Descriptions.mark_delete
81
+ def delete *args
82
+ begin
83
+ init
84
+ args.empty? ? abort(Status.wrong_arguments) : post_id = args[0]
85
+ abort Status.error_missing_post_id unless post_id.is_integer?
86
+ Databases.delete_bookmark post_id
87
+ puts Status.done
88
+ rescue => e
89
+ Errors.global_error("mark/delete", args, e)
90
+ ensure
91
+ Databases.close_all
92
+ end
93
+ end
94
+
95
+ desc "rename POST_ID NEW_TITLE", "Rename bookmark POST_ID"
96
+ long_desc Descriptions.mark_rename
97
+ def rename *args
98
+ begin
99
+ init
100
+ unless args.empty? || args[1].nil?
101
+ post_id, new_title = args[0], args[1]
102
+ else
103
+ abort Status.wrong_arguments
104
+ end
105
+ abort Status.error_missing_post_id unless post_id.is_integer?
106
+ Databases.rename_bookmark post_id, new_title
107
+ puts Status.done
108
+ rescue => e
109
+ Errors.global_error("mark/rename", args, e)
110
+ ensure
111
+ Databases.close_all
112
+ end
113
+ end
114
+
115
+ private
116
+
117
+ def make_entry content
118
+ entry = ""
119
+ entry << "Post id:".color(:cyan)
120
+ entry << "\t#{content[:id]}\n".color(Settings.options[:colors][:username])
121
+ unless content[:title].is_integer?
122
+ entry << "Title:".color(:cyan)
123
+ entry << "\t\t#{content[:title]}\n".color(Settings.options[:colors][:id])
124
+ end
125
+ entry << "Date:".color(:cyan)
126
+ entry << "\t\t#{content[:first_date]}\n".color(Settings.options[:colors][:date])
127
+ # entry << "Bookmarked:".color(:cyan)
128
+ # entry << "\t#{content[:mark_date]}\n".color(Settings.options[:colors][:date])
129
+ entry << "Posts:".color(:cyan)
130
+ entry << "\t\t#{content[:size]}\n".color(Settings.options[:colors][:name])
131
+ entry << "Posters:".color(:cyan)
132
+ posters = []
133
+ content[:users].each {|mention| posters << "@#{mention}"}
134
+ entry << "\t#{posters.join(', ')}\n".color(Settings.options[:colors][:mentions])
135
+ # entry << "First:\t\t@#{content[:first_poster]}\n"
136
+ # entry << "Last:\t\t@#{content[:last_poster]}\n"
137
+ entry << "Link:".color(:cyan)
138
+ entry << "\t\t#{content[:url]}\n".color(Settings.options[:colors][:link])
139
+ entry << "Beginning:".color(:cyan)
140
+ text = content[:root_colorized_text].gsub(/[\r\n]/, ' ')
141
+ entry << "\t#{text[0..60]} [...]\n"
142
+ end
143
+
144
+ def init
145
+ Settings.load_config
146
+ Settings.get_token
147
+ Settings.init_config
148
+ Logs.create_logger
149
+ Databases.open_databases
150
+ end
151
+
152
+ end
153
+ end
@@ -25,9 +25,9 @@ module Ayadn
25
25
  auth: "#{home}/auth",
26
26
  downloads: "#{home}/downloads",
27
27
  backup: "#{home}/backup",
28
- posts: "#{home}/backup/posts",
29
- messages: "#{home}/backup/messages",
30
- lists: "#{home}/backup/lists"
28
+ posts: "#{home}/posts",
29
+ messages: "#{home}/messages",
30
+ lists: "#{home}/lists"
31
31
  },
32
32
  identity: {
33
33
  id: db[active][:id],
data/lib/ayadn/status.rb CHANGED
@@ -8,46 +8,46 @@ module Ayadn
8
8
  "\nFile downloaded in #{Settings.config[:paths][:downloads]}/#{name}\n".color(:green)
9
9
  end
10
10
  def self.downloading
11
- "Downloading from ADN...\n".inverse
11
+ "Downloading from ADN...".inverse
12
12
  end
13
13
  def self.posting
14
- "Posting to ADN...\n".inverse
14
+ "Posting to ADN...".inverse
15
15
  end
16
16
  def self.deleting_post(post_id)
17
- "\nDeleting post #{post_id}\n".inverse
17
+ "\nDeleting post #{post_id}".inverse
18
18
  end
19
19
  def self.deleting_message(message_id)
20
- "\nDeleting message #{message_id}\n".inverse
20
+ "\nDeleting message #{message_id}".inverse
21
21
  end
22
22
  def self.unfollowing(username)
23
- "\nUnfollowing #{username}\n".inverse
23
+ "\nUnfollowing #{username}".inverse
24
24
  end
25
25
  def self.following(username)
26
- "\nFollowing #{username}\n".inverse
26
+ "\nFollowing #{username}".inverse
27
27
  end
28
28
  def self.unmuting(username)
29
- "\nUnmuting #{username}\n".inverse
29
+ "\nUnmuting #{username}".inverse
30
30
  end
31
31
  def self.muting(username)
32
- "\nMuting #{username}\n".inverse
32
+ "\nMuting #{username}".inverse
33
33
  end
34
34
  def self.unblocking(username)
35
- "\nUnblocking #{username}\n".inverse
35
+ "\nUnblocking #{username}".inverse
36
36
  end
37
37
  def self.blocking(username)
38
- "\nBlocking #{username}\n".inverse
38
+ "\nBlocking #{username}".inverse
39
39
  end
40
40
  def self.unreposting(post_id)
41
- "\nUnreposting #{post_id}\n".inverse
41
+ "\nUnreposting #{post_id}".inverse
42
42
  end
43
43
  def self.reposting(post_id)
44
- "\nReposting #{post_id}\n".inverse
44
+ "\nReposting #{post_id}".inverse
45
45
  end
46
46
  def self.unstarring(post_id)
47
- "\nUnstarring #{post_id}\n".inverse
47
+ "\nUnstarring #{post_id}".inverse
48
48
  end
49
49
  def self.starring(post_id)
50
- "\nStarring #{post_id}\n".inverse
50
+ "\nStarring #{post_id}".inverse
51
51
  end
52
52
  def self.not_deleted(post_id)
53
53
  "Could not delete post #{post_id} (post isn't yours, or is already deleted)\n".color(:red)
@@ -83,22 +83,22 @@ module Ayadn
83
83
  "Could not block user #{username} (doesn't exist, or is already blocked)\n".color(:red)
84
84
  end
85
85
  def self.deleted(post_id)
86
- "Post #{post_id} has been deleted.\n".color(:green)
86
+ "\nPost #{post_id} has been deleted.\n".color(:green)
87
87
  end
88
88
  def self.deleted_m(message_id)
89
89
  "\nMessage #{message_id} has been deleted.\n".color(:green)
90
90
  end
91
91
  def self.starred(post_id)
92
- "Post #{post_id} has been starred.\n".color(:green)
92
+ "\nPost #{post_id} has been starred.\n".color(:green)
93
93
  end
94
94
  def self.unreposted(post_id)
95
- "Post #{post_id} has been unreposted.\n".color(:green)
95
+ "\nPost #{post_id} has been unreposted.\n".color(:green)
96
96
  end
97
97
  def self.reposted(post_id)
98
- "Post #{post_id} has been reposted.\n".color(:green)
98
+ "\nPost #{post_id} has been reposted.\n".color(:green)
99
99
  end
100
100
  def self.unstarred(post_id)
101
- "Post #{post_id} has been unstarred.\n".color(:green)
101
+ "\nPost #{post_id} has been unstarred.\n".color(:green)
102
102
  end
103
103
  def self.unfollowed(username)
104
104
  "\nUser #{username} has been unfollowed.\n".color(:green)
@@ -149,10 +149,10 @@ module Ayadn
149
149
  "\nPosting as ".color(:cyan) + "#{Settings.config[:identity][:handle]}".color(:green) + ".".color(:cyan)
150
150
  end
151
151
  def self.yourpost
152
- "\nYour post:\n\n".color(:cyan)
152
+ "Your post:\n\n".color(:cyan)
153
153
  end
154
154
  def self.yourmessage
155
- "\nYour message:\n\n".color(:cyan)
155
+ "Your message:\n\n".color(:cyan)
156
156
  end
157
157
  def self.message_from(username)
158
158
  "\nMessage from ".color(:cyan) + "#{Settings.config[:identity][:handle]} ".color(:green) + "to ".color(:cyan) + "#{username[0]}".color(:yellow) + ".".color(:cyan)