rufio 0.10.0 → 0.11.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.
- checksums.yaml +4 -4
- data/info/welcome.txt +21 -0
- data/lib/rufio/info_notice.rb +100 -0
- data/lib/rufio/terminal_ui.rb +55 -0
- data/lib/rufio/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 19b8250183857c347874fd648f1b41883d99e4fe396a31fc9822aae07d89887e
|
|
4
|
+
data.tar.gz: 6f4b898c0cc273bdc43e98d3f73f28d4ce29cd09a2ad55f69fe3b356ed150bca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4c8ead01be0c96c710880a4685a249d240fb161264750043c65149b04a0b58e7fa90b0d86900fd08bdfe863be8231c0f67add98c3eae49bf32811d97c947d024
|
|
7
|
+
data.tar.gz: f466e43c95e80537eb2d6b20d9310916b7bdf9e0794b3b86526d0acead6a918cb9f1dbf77b2c2bde39988d8941435914b771fb14299efdd0c6b1c6e6e2ddb969
|
data/info/welcome.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Welcome to rufio!
|
|
2
|
+
|
|
3
|
+
Thank you for using rufio - a terminal-based file manager.
|
|
4
|
+
|
|
5
|
+
Key Features:
|
|
6
|
+
- Vim-like keybindings (j/k/h/l for navigation)
|
|
7
|
+
- Real-time filtering (f key)
|
|
8
|
+
- Advanced search with fzf and rga
|
|
9
|
+
- Bookmark support (b key)
|
|
10
|
+
- Plugin system for extensibility
|
|
11
|
+
|
|
12
|
+
Quick Start:
|
|
13
|
+
j/k - Move up/down
|
|
14
|
+
h/l - Parent dir / Enter dir
|
|
15
|
+
f - Filter files
|
|
16
|
+
b - Bookmarks
|
|
17
|
+
: - Command mode
|
|
18
|
+
q - Quit
|
|
19
|
+
|
|
20
|
+
For more information, visit:
|
|
21
|
+
https://github.com/masisz/rufio
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
|
|
5
|
+
module Rufio
|
|
6
|
+
# Manages info notices from the info directory
|
|
7
|
+
class InfoNotice
|
|
8
|
+
INFO_DIR = File.join(File.dirname(__FILE__), '..', '..', 'info')
|
|
9
|
+
NOTICE_TRACKING_DIR = File.join(Dir.home, '.config', 'rufio', 'notices')
|
|
10
|
+
|
|
11
|
+
attr_accessor :info_dir, :tracking_dir
|
|
12
|
+
|
|
13
|
+
def initialize(info_dir: nil, tracking_dir: nil)
|
|
14
|
+
@info_dir = info_dir || INFO_DIR
|
|
15
|
+
@tracking_dir = tracking_dir || NOTICE_TRACKING_DIR
|
|
16
|
+
ensure_tracking_directory
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Get all available notices that haven't been shown
|
|
20
|
+
# @return [Array<Hash>] Array of notice hashes with :file, :title, :content
|
|
21
|
+
def unread_notices
|
|
22
|
+
return [] unless Dir.exist?(@info_dir)
|
|
23
|
+
|
|
24
|
+
Dir.glob(File.join(@info_dir, '*.txt')).map do |file_path|
|
|
25
|
+
next if shown?(file_path)
|
|
26
|
+
|
|
27
|
+
{
|
|
28
|
+
file: file_path,
|
|
29
|
+
filename: File.basename(file_path),
|
|
30
|
+
title: extract_title(file_path),
|
|
31
|
+
content: read_content(file_path)
|
|
32
|
+
}
|
|
33
|
+
end.compact
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Check if a notice has been shown
|
|
37
|
+
# @param file_path [String] Path to the notice file
|
|
38
|
+
# @return [Boolean] true if already shown
|
|
39
|
+
def shown?(file_path)
|
|
40
|
+
tracking_file = tracking_file_path(file_path)
|
|
41
|
+
File.exist?(tracking_file)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Mark a notice as shown
|
|
45
|
+
# @param file_path [String] Path to the notice file
|
|
46
|
+
def mark_as_shown(file_path)
|
|
47
|
+
tracking_file = tracking_file_path(file_path)
|
|
48
|
+
FileUtils.touch(tracking_file)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Extract title from the first line of the file
|
|
52
|
+
# @param file_path [String] Path to the notice file
|
|
53
|
+
# @return [String] The title
|
|
54
|
+
def extract_title(file_path)
|
|
55
|
+
first_line = File.open(file_path, &:readline).strip
|
|
56
|
+
# Remove markdown heading markers if present
|
|
57
|
+
first_line.gsub(/^#+\s*/, '')
|
|
58
|
+
rescue StandardError
|
|
59
|
+
File.basename(file_path, '.txt')
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Read the content of a notice file
|
|
63
|
+
# @param file_path [String] Path to the notice file
|
|
64
|
+
# @return [Array<String>] Content lines
|
|
65
|
+
def read_content(file_path)
|
|
66
|
+
lines = File.readlines(file_path, chomp: true)
|
|
67
|
+
|
|
68
|
+
# Skip the first line if it's a markdown heading (title)
|
|
69
|
+
lines = lines.drop(1) if lines.first&.start_with?('#')
|
|
70
|
+
|
|
71
|
+
# Add empty lines at the beginning and end for padding
|
|
72
|
+
[''] + lines + ['', 'Press any key to continue...', '']
|
|
73
|
+
rescue StandardError => e
|
|
74
|
+
[
|
|
75
|
+
'',
|
|
76
|
+
"Error reading notice: #{e.message}",
|
|
77
|
+
'',
|
|
78
|
+
'Press any key to continue...',
|
|
79
|
+
''
|
|
80
|
+
]
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
private
|
|
84
|
+
|
|
85
|
+
def ensure_tracking_directory
|
|
86
|
+
FileUtils.mkdir_p(@tracking_dir) unless Dir.exist?(@tracking_dir)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Get the tracking file path for a given notice file
|
|
90
|
+
# @param file_path [String] Path to the notice file
|
|
91
|
+
# @return [String] Path to the tracking file
|
|
92
|
+
def tracking_file_path(file_path)
|
|
93
|
+
filename = File.basename(file_path)
|
|
94
|
+
# Use MD5 hash of the filename to avoid issues with special characters
|
|
95
|
+
require 'digest'
|
|
96
|
+
hash = Digest::MD5.hexdigest(filename)
|
|
97
|
+
File.join(@tracking_dir, ".#{hash}_shown")
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
data/lib/rufio/terminal_ui.rb
CHANGED
|
@@ -60,6 +60,9 @@ module Rufio
|
|
|
60
60
|
@running = true
|
|
61
61
|
setup_terminal
|
|
62
62
|
|
|
63
|
+
# Show info notices if any
|
|
64
|
+
show_info_notices
|
|
65
|
+
|
|
63
66
|
begin
|
|
64
67
|
main_loop
|
|
65
68
|
ensure
|
|
@@ -625,6 +628,58 @@ module Rufio
|
|
|
625
628
|
# 画面を再描画
|
|
626
629
|
draw_screen
|
|
627
630
|
end
|
|
631
|
+
|
|
632
|
+
# Show info notices from the info directory if any are unread
|
|
633
|
+
def show_info_notices
|
|
634
|
+
require_relative 'info_notice'
|
|
635
|
+
info_notice = InfoNotice.new
|
|
636
|
+
notices = info_notice.unread_notices
|
|
637
|
+
|
|
638
|
+
notices.each do |notice|
|
|
639
|
+
show_info_notice(notice, info_notice)
|
|
640
|
+
end
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
# Show a single info notice
|
|
644
|
+
# @param notice [Hash] Notice hash with :title and :content
|
|
645
|
+
# @param info_notice [InfoNotice] InfoNotice instance to mark as shown
|
|
646
|
+
def show_info_notice(notice, info_notice)
|
|
647
|
+
# Calculate window dimensions
|
|
648
|
+
width = [@screen_width - 10, 70].min
|
|
649
|
+
# Calculate height based on content length
|
|
650
|
+
content_length = notice[:content].length
|
|
651
|
+
height = [content_length + 4, @screen_height - 4].min # +4 for borders and title
|
|
652
|
+
x = (@screen_width - width) / 2
|
|
653
|
+
y = (@screen_height - height) / 2
|
|
654
|
+
|
|
655
|
+
# Display the notice window
|
|
656
|
+
@dialog_renderer.draw_floating_window(
|
|
657
|
+
x, y, width, height,
|
|
658
|
+
notice[:title],
|
|
659
|
+
notice[:content],
|
|
660
|
+
{
|
|
661
|
+
border_color: "\e[36m", # Cyan
|
|
662
|
+
title_color: "\e[1;36m", # Bold cyan
|
|
663
|
+
content_color: "\e[37m" # White
|
|
664
|
+
}
|
|
665
|
+
)
|
|
666
|
+
|
|
667
|
+
# Force flush to ensure display
|
|
668
|
+
$stdout.flush
|
|
669
|
+
|
|
670
|
+
# Wait for any key press
|
|
671
|
+
require 'io/console'
|
|
672
|
+
IO.console.getch
|
|
673
|
+
|
|
674
|
+
# Mark as shown
|
|
675
|
+
info_notice.mark_as_shown(notice[:file])
|
|
676
|
+
|
|
677
|
+
# Clear the notice window
|
|
678
|
+
@dialog_renderer.clear_area(x, y, width, height)
|
|
679
|
+
|
|
680
|
+
# Redraw the screen
|
|
681
|
+
draw_screen
|
|
682
|
+
end
|
|
628
683
|
end
|
|
629
684
|
end
|
|
630
685
|
|
data/lib/rufio/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rufio
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- masisz
|
|
@@ -131,6 +131,7 @@ files:
|
|
|
131
131
|
- config_example.rb
|
|
132
132
|
- docs/PLUGIN_GUIDE.md
|
|
133
133
|
- docs/plugin_example.rb
|
|
134
|
+
- info/welcome.txt
|
|
134
135
|
- lib/rufio.rb
|
|
135
136
|
- lib/rufio/application.rb
|
|
136
137
|
- lib/rufio/bookmark.rb
|
|
@@ -147,6 +148,7 @@ files:
|
|
|
147
148
|
- lib/rufio/file_preview.rb
|
|
148
149
|
- lib/rufio/filter_manager.rb
|
|
149
150
|
- lib/rufio/health_checker.rb
|
|
151
|
+
- lib/rufio/info_notice.rb
|
|
150
152
|
- lib/rufio/keybind_handler.rb
|
|
151
153
|
- lib/rufio/logger.rb
|
|
152
154
|
- lib/rufio/plugin.rb
|