commit
Showing
8 changed files
with
80 additions
and
157 deletions
app/Http/Controllers/FilesController.php
0 → 100644
| 1 | <?php | ||
| 2 | |||
| 3 | namespace App\Http\Controllers; | ||
| 4 | |||
| 5 | use Illuminate\Http\Request; | ||
| 6 | use App\Http\Requests; | ||
| 7 | use App\Http\Controllers; | ||
| 8 | use App\pdfModel; | ||
| 9 | use URL; | ||
| 10 | use Storage; | ||
| 11 | use Response; | ||
| 12 | use File; | ||
| 13 | Use PDF; | ||
| 14 | use Illuminate\Support\Facades\Input; | ||
| 15 | use Intervention\Image\Facades\Image; | ||
| 16 | use Illuminate\Support\Facades\Facade; | ||
| 17 | use Illuminate\Support\Facades\Response; | ||
| 18 | use League\Flysystem\Filesystem; | ||
| 19 | use App\File; | ||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | class FilesController extends Controller | ||
| 25 | { | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Previews an image if possible. | ||
| 29 | * | ||
| 30 | * @param File $file | ||
| 31 | * @return mixed | ||
| 32 | * @internal param $id | ||
| 33 | */ | ||
| 34 | public function preview(File $file) | ||
| 35 | { | ||
| 36 | $path = storage_path('app/') . $file->path . $file->name_thumbnail; | ||
| 37 | $handler = new \Symfony\Component\HttpFoundation\File\File($path); | ||
| 38 | |||
| 39 | $lifetime = 31556926; // One year in seconds | ||
| 40 | |||
| 41 | /** | ||
| 42 | * Prepare some header variables | ||
| 43 | */ | ||
| 44 | $file_time = $handler->getMTime(); // Get the last modified time for the file (Unix timestamp) | ||
| 45 | |||
| 46 | $header_content_type = $handler->getMimeType(); | ||
| 47 | $header_content_length = $handler->getSize(); | ||
| 48 | $header_etag = md5($file_time . $path); | ||
| 49 | $header_last_modified = gmdate('r', $file_time); | ||
| 50 | $header_expires = gmdate('r', $file_time + $lifetime); | ||
| 51 | |||
| 52 | $headers = array( | ||
| 53 | 'Content-Disposition' => 'inline; filename="' . $file->name_thumbnail . '"', | ||
| 54 | 'Last-Modified' => $header_last_modified, | ||
| 55 | 'Cache-Control' => 'must-revalidate', | ||
| 56 | 'Expires' => $header_expires, | ||
| 57 | 'Pragma' => 'public', | ||
| 58 | 'Etag' => $header_etag | ||
| 59 | ); | ||
| 60 | |||
| 61 | /** | ||
| 62 | * Is the resource cached? | ||
| 63 | */ | ||
| 64 | $h1 = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $header_last_modified; | ||
| 65 | $h2 = isset($_SERVER['HTTP_IF_NONE_MATCH']) && str_replace('"', '', stripslashes($_SERVER['HTTP_IF_NONE_MATCH'])) == $header_etag; | ||
| 66 | |||
| 67 | if ($h1 || $h2) { | ||
| 68 | return Response::make('', 304, $headers); // File (image) is cached by the browser, so we don't have to send it again | ||
| 69 | } | ||
| 70 | |||
| 71 | $headers = array_merge($headers, array( | ||
| 72 | 'Content-Type' => $header_content_type, | ||
| 73 | 'Content-Length' => $header_content_length | ||
| 74 | )); | ||
| 75 | |||
| 76 | return Response::make(file_get_contents($path), 200, $headers); | ||
| 77 | } | ||
| 78 | |||
| 79 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -28,6 +28,7 @@ Route::group(array('prefix' => 'api/v1'), function($json) | ... | @@ -28,6 +28,7 @@ Route::group(array('prefix' => 'api/v1'), function($json) |
| 28 | Route::resource('api', 'ApiController@getApi'); | 28 | Route::resource('api', 'ApiController@getApi'); |
| 29 | 29 | ||
| 30 | }); | 30 | }); |
| 31 | Route::get('files/{file}/preview', ['as' => 'file_preview', 'uses' => 'FilesController@preview']); | ||
| 31 | 32 | ||
| 32 | //Route::resource('js/interface.js', function () { | 33 | //Route::resource('js/interface.js', function () { |
| 33 | // return asset('js/interface.js'); | 34 | // return asset('js/interface.js'); | ... | ... |
resources/assets/js/interface.js
deleted
100644 → 0
| 1 | <SCRIPT LANGUAGE="JavaScript"> | ||
| 2 | |||
| 3 | function pickPdfFromList(){ | ||
| 4 | |||
| 5 | var strVar=""; | ||
| 6 | strVar += "<link rel=\"stylesheet\" href=\"http:\/\/dhbhdrzi4tiry.cloudfront.net\/cdn\/sites\/foundation.min.css\">"; | ||
| 7 | strVar += " <link href=\"http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/foundicons\/3.0.0\/foundation-icons.css\" rel=\"stylesheet\" type=\"text\/css\">"; | ||
| 8 | strVar += " <script src=\"https:\/\/code.jquery.com\/jquery-2.2.3.min.js\" integrity=\"sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=\" crossorigin=\"anonymous\"><\/script>"; | ||
| 9 | |||
| 10 | var json = [{"idPDF":14,"name":"SISKINDS_test file","folder":"SISKINDS_test","file":"SISKINDS_test_file.pdf","image":"SISKINDS_test_file.jpg","custId":1,"apiCallId":3},{"idPDF":27,"name":"test file","folder":"SISKINDStest-file","file":"pdf-sample.pdf","image":"pdf-sample.jpg","custId":1,"apiCallId":25}]; | ||
| 11 | |||
| 12 | |||
| 13 | |||
| 14 | var i; | ||
| 15 | var pdflist =""; | ||
| 16 | for (i = 0; i < json.length; ++i) { | ||
| 17 | pdflist += "<div class=\"column\">"; | ||
| 18 | pdflist += ' <img class=\"thumbnail\" src="/Applications/MAMP/htdocs/pdfEdit/storage/app/public/'+json[i].folder+'/'+json[i].image+'" height=\"270px\">'; | ||
| 19 | pdflist += " <h5>"+json[i].name+"<\/h5>"; | ||
| 20 | pdflist += "<\/div>"; | ||
| 21 | } | ||
| 22 | |||
| 23 | |||
| 24 | strVar += " <link rel=\"stylesheet\" href=\"http:\/\/dhbhdrzi4tiry.cloudfront.net\/cdn\/sites\/foundation.min.css\">"; | ||
| 25 | strVar += "<div class=\"off-canvas-wrapper\">"; | ||
| 26 | strVar += " <div class=\"off-canvas-wrapper-inner\" data-off-canvas-wrapper>"; | ||
| 27 | strVar += " <div class=\"off-canvas position-left reveal-for-large\" id=\"my-info\" data-off-canvas data-position=\"left\">"; | ||
| 28 | strVar += " <div class=\"row column\">"; | ||
| 29 | strVar += " <br>"; | ||
| 30 | strVar += " <img class=\"thumbnail\" src=\"http:\/\/placehold.it\/550x350\">"; | ||
| 31 | strVar += " <\/div>"; | ||
| 32 | strVar += " <\/div>"; | ||
| 33 | strVar += " <div class=\"off-canvas-content\" data-off-canvas-content>"; | ||
| 34 | strVar += " <div class=\"title-bar hide-for-large\">"; | ||
| 35 | strVar += " <div class=\"title-bar-left\">"; | ||
| 36 | strVar += " <button class=\"menu-icon\" type=\"button\" data-open=\"my-info\"><\/button>"; | ||
| 37 | strVar += " <span class=\"title-bar-title\">Synapsus<\/span>"; | ||
| 38 | strVar += " <\/div>"; | ||
| 39 | strVar += " <\/div>"; | ||
| 40 | strVar += " <div class=\"callout primary\">"; | ||
| 41 | strVar += " <div class=\"row column\">"; | ||
| 42 | strVar += " <h1>Welcome to Synapsus Online PDF Editor<\/h1>"; | ||
| 43 | strVar += " <p class=\"lead\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.<\/p>"; | ||
| 44 | strVar += " <\/div>"; | ||
| 45 | strVar += " <\/div>"; | ||
| 46 | strVar += " <div class=\"row small-up-2 medium-up-3 large-up-4\">"; | ||
| 47 | strVar += pdflist; | ||
| 48 | strVar += " <\/div>"; | ||
| 49 | strVar += " <hr>"; | ||
| 50 | strVar += ""; | ||
| 51 | strVar += " <\/div>"; | ||
| 52 | strVar += " <\/div>"; | ||
| 53 | strVar += " <\/div>"; | ||
| 54 | strVar += " <\/div>"; | ||
| 55 | strVar += "<\/div>"; | ||
| 56 | strVar += ""; | ||
| 57 | strVar += "<script src=\"http:\/\/dhbhdrzi4tiry.cloudfront.net\/cdn\/sites\/foundation.js\"><\/script>"; | ||
| 58 | strVar += "<script>"; | ||
| 59 | strVar += " $(document).foundation();"; | ||
| 60 | strVar += "<\/script>"; | ||
| 61 | strVar += ""; | ||
| 62 | strVar += ""; | ||
| 63 | } | ||
| 64 | |||
| 65 | function changePdfOptions(){ | ||
| 66 | |||
| 67 | var strVar2=""; | ||
| 68 | strVar2 += "<link rel=\"stylesheet\" href=\"http:\/\/dhbhdrzi4tiry.cloudfront.net\/cdn\/sites\/foundation.min.css\">"; | ||
| 69 | strVar2 += " <link href=\"http:\/\/cdnjs.cloudflare.com\/ajax\/libs\/foundicons\/3.0.0\/foundation-icons.css\" rel=\"stylesheet\" type=\"text\/css\">"; | ||
| 70 | strVar2 += " <script src=\"https:\/\/code.jquery.com\/jquery-2.2.3.min.js\" integrity=\"sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=\" crossorigin=\"anonymous\"><\/script>"; | ||
| 71 | |||
| 72 | var json = [{"idPDF":14,"name":"test file","folder":"SISKINDS_test","file":"SISKINDS_test_file.pdf","image":"SISKINDS_test_file.jpg","custId":1,"apiCallId":3,"idchangesPDF":18,"PDF_idPDF":14,"change_typePDF_idchange_typePDF":1,"stylesPDF_idstylesPDF":18,"locationUp":"60","locationRight":290,"pages":"1","content":"519.660.2121 siskinds.com\/change","z-index":0,"idstylesPDF":18,"order":"1","label":"Text","style":"a:3:{s:11:\"font-family\";s:11:\"TradeGothic\";s:9:\"font-size\";s:2:\"14\";s:10:\"font-color\";s:14:\"cmyk 0 0 0.5 0\";}","idchange_typePDF":1,"change_type":"text"},{"idPDF":14,"name":"test file","folder":"SISKINDS_test","file":"SISKINDS_test_file.pdf","image":"SISKINDS_test_file.jpg","custId":1,"apiCallId":3,"idchangesPDF":17,"PDF_idPDF":14,"change_typePDF_idchange_typePDF":2,"stylesPDF_idstylesPDF":17,"locationUp":"400","locationRight":90,"pages":"1","content":"siskins.png","z-index":0,"idstylesPDF":17,"order":"2","label":"Image","style":null,"idchange_typePDF":2,"change_type":"img"}]; | ||
| 73 | var pdflist =""; | ||
| 74 | |||
| 75 | pdflist += "<div class=\"column\">"; | ||
| 76 | pdflist += ' <img src=\"/Applications/MAMP/htdocs/pdfEdit/storage/app/public/'+json[0].folder+'/'+json[0].image+'\" width=\"300px\">'; | ||
| 77 | pdflist += "<\/div>"; | ||
| 78 | var pdfChange="<br>"; | ||
| 79 | pdfChange += "<form id=\"changes\" action=\"\"><h4>" + json[0].name+"</h4>"; | ||
| 80 | for (i = 0; i < json.length; ++i) { | ||
| 81 | if(json[i].change_type == "text"){ | ||
| 82 | |||
| 83 | |||
| 84 | pdfChange += " Text: <input id=\"content"+i+"\" type=\"text\" name=\"content"+i+"\" value=\""+json[i].content+"\">"; | ||
| 85 | |||
| 86 | |||
| 87 | |||
| 88 | }if(json[i].change_type == "img"){ | ||
| 89 | pdfChange += " <input type=\"hidden\" id=\"content"+i+"\" name=\"content"+i+"\" value=\""+json[i].content+"\">"; | ||
| 90 | pdfChange += " Image: <input id=\"content"+i+"\" style=\"display: block; box-sizing: border-box; width: 100%; height: 2.4375rem; padding: .5rem; border: 1px solid #cacaca; margin: 0 0 1rem; font-family: inherit; font-size: 1rem; color: #8a8a8a; background-color: #fefefe; box-shadow: inset 0 1px 2px rgba(10,10,10,.1); border-radius: 0; transition: box-shadow .5s,border-color .25s ease-in-out; -webkit-appearance: none; -moz-appearance: none;\" type=\"file\" name=\"content"+i+"\" value=\""+json[i].content+"\">"; | ||
| 91 | } | ||
| 92 | |||
| 93 | } | ||
| 94 | pdfChange += " <input type=\"submit\" value=\"Submit\">"; | ||
| 95 | pdfChange += "<\/form>"; | ||
| 96 | |||
| 97 | strVar2 += " <link rel=\"stylesheet\" href=\"http:\/\/dhbhdrzi4tiry.cloudfront.net\/cdn\/sites\/foundation.min.css\">"; | ||
| 98 | strVar2 += "<div class=\"off-canvas-wrapper\">"; | ||
| 99 | strVar2 += " <div class=\"off-canvas-wrapper-inner\" data-off-canvas-wrapper>"; | ||
| 100 | strVar2 += " <div class=\"off-canvas position-left reveal-for-large\" id=\"my-info\" data-off-canvas data-position=\"left\">"; | ||
| 101 | strVar2 += " <div class=\"row column\">"; | ||
| 102 | strVar2 += " <br>"; | ||
| 103 | strVar2 += " <img class=\"thumbnail\" src=\"http:\/\/placehold.it\/550x350\">"; | ||
| 104 | strVar2 += " <\/div>"; | ||
| 105 | strVar2 += " <\/div>"; | ||
| 106 | strVar2 += " <div class=\"off-canvas-content\" data-off-canvas-content>"; | ||
| 107 | strVar2 += " <div class=\"title-bar hide-for-large\">"; | ||
| 108 | strVar2 += " <div class=\"title-bar-left\">"; | ||
| 109 | strVar2 += " <button class=\"menu-icon\" type=\"button\" data-open=\"my-info\"><\/button>"; | ||
| 110 | strVar2 += " <span class=\"title-bar-title\">Synapsus<\/span>"; | ||
| 111 | strVar2 += " <\/div>"; | ||
| 112 | strVar2 += " <\/div>"; | ||
| 113 | strVar2 += " <div class=\"callout primary\">"; | ||
| 114 | strVar2 += " <div class=\"row column\">"; | ||
| 115 | strVar2 += " <h1>Welcome to Synapsus Online PDF Editor<\/h1>"; | ||
| 116 | strVar2 += " <p class=\"lead\">Lorem ipsum dolor sit amet, consectetur adipiscing elit.<\/p>"; | ||
| 117 | strVar2 += " <\/div>"; | ||
| 118 | strVar2 += " <\/div>"; | ||
| 119 | strVar2 += " <div class=\"row small-up-2 medium-up-3 large-up-3\">"; | ||
| 120 | strVar2 += pdflist+"<div class=\"column\">"+pdfChange+"<\/div>"; | ||
| 121 | strVar2 += " <\/div>"; | ||
| 122 | strVar2 += " <hr>"; | ||
| 123 | strVar2 += ""; | ||
| 124 | strVar2 += " <\/div>"; | ||
| 125 | strVar2 += " <\/div>"; | ||
| 126 | strVar2 += " <\/div>"; | ||
| 127 | strVar2 += " <\/div>"; | ||
| 128 | strVar2 += "<\/div>"; | ||
| 129 | strVar2 += ""; | ||
| 130 | strVar2 += "<script src=\"http:\/\/dhbhdrzi4tiry.cloudfront.net\/cdn\/sites\/foundation.js\"><\/script>"; | ||
| 131 | strVar2 += "<script>"; | ||
| 132 | strVar2 += " $(document).foundation();"; | ||
| 133 | strVar2 += "<\/script>"; | ||
| 134 | strVar2 += ""; | ||
| 135 | strVar2 += ""; | ||
| 136 | |||
| 137 | } | ||
| 138 | |||
| 139 | function returnOptions(){ | ||
| 140 | |||
| 141 | var jsonReturn = '{"pdf":[{"name":"'+json[0].name+'", "folder":"'+json[0].name+'", "pdfLocation":""}],"changes":[' | ||
| 142 | |||
| 143 | for (i = 0; i < json.length; ++i) { | ||
| 144 | |||
| 145 | jsonReturn +='{"label":"'+json[i].label+'", "locationUp":"'+json[i].locationUp+'", "locationRight":"'+json[i].locationRight+'", "pages":"'+json[i].pages+'", "content":"'+json[i].content+'", "z-index":null, "idstylesPDF":"'+json[i].idstylesPDF, "order":"'+json[i].order, "style":"'+json[i].style, "idchange_typePDF":"'+json[i].idchange_typePDF+'", "change_type":"'+json[i].change_type+'", "fileLocation":""}'; | ||
| 146 | |||
| 147 | |||
| 148 | } | ||
| 149 | jsonReturn +=' }]}'; | ||
| 150 | |||
| 151 | |||
| 152 | } | ||
| 153 | |||
| 154 | |||
| 155 | </script> | ||
| 156 | |||
| 157 | |||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
43.6 KB
No preview for this file type
No preview for this file type
storage/app/SISKINDStest-file/pdf-sample.jpg
0 → 100644
487 KB
storage/app/SISKINDStest-file/pdf-sample.pdf
0 → 100644
No preview for this file type
-
Please register or sign in to post a comment