Skip to content

Commit

Permalink
Merge pull request #22 from felipealfonsog/development
Browse files Browse the repository at this point in the history
termPDF 0.0.2
  • Loading branch information
felipealfonsog authored Aug 10, 2023
2 parents 133084a + 302b70f commit c7a0531
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 16 deletions.
24 changes: 8 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ This is an experimental project aimed at bringing a PDF viewer or reader to the
* You can install it using pip: pip install PyMuPDF
* Make sure to include the appropriate model or adapt it for your needs.

#### How to run the TermPDF Viewer:
#### How to run the TermPDF Viewer (Installation):

* Clone the TermPDF Viewer repository from GitHub.
* Navigate to the project directory:
* Installar with AUR in Arch
yay -S term-pdf

cd TermPDF-Viewer

* Install PyMuPDF library (if not already installed):
pip install PyMuPDF
* Install with bash
./installer.sh

* Run the TermPDF Viewer:
python termpdf.py
Expand All @@ -77,21 +75,15 @@ This is an experimental project aimed at bringing a PDF viewer or reader to the
- Experimental project with limited functionality.
- Built using the MuPDF library for rendering PDF content.

#### 🛠️ Installation

1. Clone the repository to your local machine.
2. Compile the source code using the provided instructions.
3. Run the `termpdf` executable followed by the path to the PDF file you want to view.

#### NOTES
#### NOTES FOR THE AUTHOR

#### Python (Working fine)

pip install PyMuPDF

python3 termpdf.py

********** Generating the executable ***********
> Generating the executable
Recommended:

Expand Down Expand Up @@ -200,7 +192,7 @@ find /usr/local/lib -name "libmupdf*"
- MuPDF library installed (libmupdf and libmupdf-third).
- Terminal environment.
#### 📝 Notes
#### 📝Important
This project is still in its experimental stage and may have limitations in terms of features and compatibility. Use at your own discretion.
Expand Down
155 changes: 155 additions & 0 deletions installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#!/bin/bash
: '
▀▀█▀▀ █▀▀ █▀▀█ █▀▄▀█ ▒█▀▀█ ▒█▀▀▄ ▒█▀▀▀   ▒█░░▒█ ░▀░ █▀▀ █░░░█ █▀▀ █▀▀█
░▒█░░ █▀▀ █▄▄▀ █░▀░█ ▒█▄▄█ ▒█░▒█ ▒█▀▀▀   ░▒█▒█░ ▀█▀ █▀▀ █▄█▄█ █▀▀ █▄▄▀
░▒█░░ ▀▀▀ ▀░▀▀ ▀░░░▀ ▒█░░░ ▒█▄▄▀ ▒█░░░   ░░▀▄▀░ ▀▀▀ ▀▀▀ ░▀░▀░ ▀▀▀ ▀░▀▀
*************************************************
TermPDF Viewer - view and navigate PDF files within the terminal.
*************************************************
* Simple: TermPDF Viewer is a Python program that enables users to
view and navigate PDF files directly within the terminal.
*************************************************
* Developed and engineered by:
* Felipe Alfonso Gonzalez <[email protected]>
* Computer Science Engineer
* Chile
*************************************************
* Prerequisites:
* Python 3.x: The program is written in Python and requires a Python 3.x interpreter to run.
* PyMuPDF: A Python binding for the MuPDF library, used to handle PDF file rendering and interaction.
* You can install it using pip: pip install PyMuPDF
* Make sure to include the appropriate model or adapt it for your needs.
*************************************************
* How to run the TermPDF Viewer:
* Clone the TermPDF Viewer repository from GitHub.
* Navigate to the project directory:
* cd TermPDF-Viewer
* Install PyMuPDF library (if not already installed):
pip install PyMuPDF
* Run the TermPDF Viewer:
* python termpdf.py
* The TermPDF Viewer will start, allowing you to:
* Scan for PDF files in the current directory.
* Select a PDF file to view by entering its number.
* View the PDF with options to move back, forward, or return to the main menu.
* Quit and return to the main menu.
* To exit the TermPDF Viewer, use 'q' in the main menu.
*
*************************************************
* Important Notes:
* - The application has been tested on Linux and macOS.
* - For Windows, additional configurations may be required.
* - Make sure to fulfill the prerequisites before running the application.
* - For more information, please refer to the project documentation.
*************************************************
'

welcome_message() {
echo
echo "▀▀█▀▀ █▀▀ █▀▀█ █▀▄▀█ ▒█▀▀█ ▒█▀▀▄ ▒█▀▀▀   ▒█░░▒█ ░▀░ █▀▀ █░░░█ █▀▀ █▀▀█"
echo "░▒█░░ █▀▀ █▄▄▀ █░▀░█ ▒█▄▄█ ▒█░▒█ ▒█▀▀▀   ░▒█▒█░ ▀█▀ █▀▀ █▄█▄█ █▀▀ █▄▄▀"
echo "░▒█░░ ▀▀▀ ▀░▀▀ ▀░░░▀ ▒█░░░ ▒█▄▄▀ ▒█░░░   ░░▀▄▀░ ▀▀▀ ▀▀▀ ░▀░▀░ ▀▀▀ ▀░▀▀"
echo "-------------------------------------------------------------------------"
echo "TermPDF Viewer - view and navigate PDF files within the terminal."
echo "-------------------------------------------------------------------------"
echo "* Simple: TermPDF Viewer is a Python program that enables users to "
echo "* view and navigate PDF files directly within the terminal."
echo "-------------------------------------------------------------------------"
echo
echo "╭────────────-----────── TERMS OF USE ──────────----------───╮"
echo "│ This software is licensed under the MIT License. │"
echo "│ By Felipe Alfonso González - github.com/felipealfonsog │"
echo "│ Computer Science Engineer - Email: [email protected]"
echo "╰───────────────────────────────────────────────---------────╯"
echo
echo "Welcome to the TermPDF Viewer Installer!"
echo "This script will install the TermPDF Viewer program on your system."
echo "Please make sure you have the necessary permissions to perform the installation."
echo "Press Enter to continue or Ctrl+C to exit."
read
}

install_homebrew() {
if ! command -v brew &>/dev/null; then
echo "Homebrew not found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
}

install_dependencies() {
if ! command -v python &>/dev/null; then
echo "Python not found. Installing Python..."
brew install python
fi

if ! command -v pip &>/dev/null; then
echo "Pip not found. Installing pip..."
brew install python
fi

if ! pip show pymupdf &>/dev/null; then
echo "PyMuPDF not found. Installing PyMuPDF..."
pip install pymupdf
fi
}

copy_and_rename_binary() {
local source_path="$1"
local dest_path="$2"

sudo cp "$source_path" "$dest_path"
local binary_name=$(basename "$dest_path")
echo "Binary '$binary_name' has been copied to '$dest_path'."
}

move_to_bin_directory() {
local binary_name=$(basename "$1")
local os=$(uname -s)
local dest_dir=""

if [[ "$os" == "Darwin" ]]; then
dest_dir="/usr/local/bin"
elif [[ "$os" == "Linux" ]]; then
dest_dir="/usr/local/bin"
else
echo "Unsupported platform."
exit 1
fi

sudo mv "$1" "$dest_dir/$binary_name"
echo "Binary '$binary_name' has been moved to '$dest_dir'."
}

remove_compiled_file() {
rm installer
}

set_permissions() {
chmod +x "/usr/local/bin/termpdf"
}

source_path=""
if [[ $(uname -s) == "Darwin" ]]; then
source_path="./dist/macos/termpdf-macos"
elif [[ $(uname -s) == "Linux" ]]; then
source_path="./dist/linux/termpdf-linux"
else
echo "Unsupported platform."
exit 1
fi

welcome_message
install_homebrew
install_dependencies
copy_and_rename_binary "$source_path" "./termpdf"
move_to_bin_directory "./termpdf"
remove_compiled_file
set_permissions

echo "TermPDF Viewer has been successfully installed as 'termpdf' command!"

0 comments on commit c7a0531

Please sign in to comment.