-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
503 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,6 @@ SESSION_ENCRYPT=false | |
SESSION_PATH=/ | ||
SESSION_DOMAIN=null | ||
|
||
BROADCAST_CONNECTION=log | ||
FILESYSTEM_DISK=local | ||
QUEUE_CONNECTION=database | ||
|
||
|
@@ -69,6 +68,20 @@ OPENAI_ORGANIZATION= | |
ADMIN_PASSWORD=password | ||
ADMIN_EMAIL=[email protected] | ||
|
||
|
||
|
||
REVERB_HOST="localhost" | ||
REVERB_PORT=8080 | ||
REVERB_SCHEME=http | ||
|
||
BROADCAST_CONNECTION=reverb | ||
|
||
|
||
REVERB_APP_ID=SOMETHING | ||
REVERB_APP_KEY=SOMETHING | ||
REVERB_APP_SECRET=SOMETHING | ||
REVERB_APP_SECRET=SOMETHING | ||
|
||
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}" | ||
VITE_REVERB_HOST="${REVERB_HOST}" | ||
VITE_REVERB_PORT="${REVERB_PORT}" | ||
VITE_REVERB_SCHEME="${REVERB_SCHEME}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ yarn-error.log | |
/.idea | ||
/.vscode | ||
docs/images/.DS_Store | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use Facades\App\Domains\Documents\Transformers\ProcessPpt; | ||
use Illuminate\Console\Command; | ||
|
||
class TestConvertFileCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'app:test-convert-file-command {full_path}'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Give the path to the file to see if we can do it or not'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle() | ||
{ | ||
$path = $this->argument('full_path'); | ||
$results = ProcessPpt::handle($path); | ||
|
||
while ($results->valid()) { | ||
$this->info($results->current()); | ||
$results->next(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace App\Domains\Documents\Transformers; | ||
|
||
use Faker\Core\File; | ||
use Generator; | ||
use Illuminate\Support\Facades\File as FacadesFile; | ||
use Illuminate\Support\Str; | ||
use Illuminate\Support\Facades\Log; | ||
use PhpOffice\PhpPresentation\IOFactory; | ||
use PhpOffice\PhpPresentation\PhpPresentation; | ||
use PhpOffice\PhpPresentation\Shape\Drawing\Gd; | ||
use PhpOffice\PhpPresentation\Shape\RichText; | ||
use PhpOffice\PhpPresentation\Shape\Table; | ||
|
||
class ProcessPpt | ||
{ | ||
public function handle(string $pathToFile): Generator | ||
{ | ||
$parser = IOFactory::createReader('PowerPoint2007'); | ||
if (! $parser->canRead($pathToFile)) { | ||
throw new \Exception('Can not read the document '.$pathToFile); | ||
} | ||
|
||
$phppres = new PhpPresentation(); | ||
$oPHPPresentation = $parser->load($pathToFile); | ||
|
||
foreach ($oPHPPresentation->getAllSlides() as $page_number => $page) { | ||
try { | ||
foreach ($page->getShapeCollection() as $shape) { | ||
// Check if shape contains text | ||
Log::info('Processing PPTX Document', [ | ||
'page_number' => $page_number, | ||
'shape' => class_basename($shape), | ||
]); | ||
if ($shape instanceof RichText) { | ||
// Get the text from the shapes | ||
$page_number = $page_number + 1; | ||
$pageContent = $shape->getPlainText(); | ||
$guid = $pathToFile.'_'.$page_number; | ||
|
||
yield $pageContent; | ||
} elseif($shape instanceof Table) { | ||
$table = $shape->getRows(); | ||
foreach ($table as $row) { | ||
foreach ($row->getCells() as $cell) { | ||
$pageContent = $cell->getPlainText(); | ||
yield $pageContent; | ||
} | ||
} | ||
} elseif($shape instanceof Gd) { | ||
$mimtype = str($shape->getMimeType())->afterLast("/")->toString(); | ||
$contents = $shape->getContents(); | ||
$name = Str::random(10); | ||
$nameAndType = $name . '.' . $mimtype; | ||
$path = storage_path('app/temp/' . $nameAndType); | ||
FacadesFile::put($path, $contents); | ||
} | ||
} | ||
} catch (\Exception $e) { | ||
Log::error('Error processing PPTX Document', [ | ||
'page_number' => $page_number, | ||
'error' => $e->getMessage(), | ||
]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.