public static function queueBuild($id) { // If already queued, dont queue again if (self::find($id)->queued) { return; } \Eloquent::unguard(); // Update queued flag self::find($id)->update(['queued' => 1]); $repo = \Apigenci\Model\Repo::find($id); \Queue::pushOn('low', new BuildDocuments($repo)); }
protected function handleMediaUpload($request, $inputName) { if ($request->hasFile($inputName)) { $upload = $request->file($inputName); $folderName = date('Y/m'); $dest = 'assets/uploads/' . $folderName . '/'; if (!file_exists($dest)) { mkdir($dest, 0777, TRUE); } $extension = $upload->getClientOriginalExtension(); $mime = $upload->getMimeType(); $filename = md5(time() . $upload->getClientOriginalName()); $type = 'file'; if ($mime == 'application/pdf') { $type = 'pdf'; } else { if (strpos($mime, 'image/') !== FALSE) { $type = 'image'; } } $status = $upload->move($dest, $filename . '_o.' . $extension); if ($status) { $media = new \App\Models\Media(); $media->type = $type; $media->path = $dest; $media->name = $filename; $media->ext = $extension; $media->third_party_type = ''; $media->third_party_thumbnail = ''; $media->third_party_id = ''; $media->save(); if ($type == 'image') { // Add image to queue for processing \Queue::pushOn('media-fpassets-' . \App::environment(), new \App\Commands\ProcessImage($media)); } return $media; } echo 'asdf'; } return null; }
try { \Apigenci\Model\Repo::insert($data); } catch (\exception $ex) { // Prevent updating the PK unset($data['id']); \Apigenci\Model\Repo::find($id)->update($data); } \Apigenci\Model\Repo::queueBuild($id); \Apigenci\Model\Github::webhookRegister($id); }); Route::post('repo/{id}/disable', function ($id) { $id = \Apigenci\Model::repoDecodeWeb($id); $repo = \Apigenci\Model\Repo::find($id); \Eloquent::unguard(); $repo->update(['enabled' => 0, 'queued' => 0, 'failed' => 0, 'built' => 0]); \Queue::pushOn('low', new \App\Jobs\Apigenci\DeleteGeneratedHtml($repo)); }); Route::get('github/{owner}/{repo}', function ($owner, $repo) { return view('apigenci.github.invite', ['owner' => $owner, 'repo' => $repo]); }); Route::get('github/{owner}/{repo}/tag/{tag}', function ($owner, $repo, $tag) { // Make sure repo exists, redirect to invite if not if (!\Apigenci\Model::localRepoExists($owner, $repo)) { return \Redirect::away("/github/{$owner}/{$repo}"); } return view('apigenci.github.tag', ['owner' => $owner, 'repo' => $repo, 'tag' => $tag]); }); Route::get('privacy', function () { return view('apigenci.privacy'); }); Route::any('webhook', function () {
Route::get('/', 'TalkingController@index'); // Route::post('/save','WeiboController@save'); // Route::resource('/', 'AboutController'); }); //系统设置 Route::group(['prefix' => 'setting'], function () { Route::get('/', 'SettingController@index'); // Route::post('/save','WeiboController@save'); // Route::resource('/', 'AboutController'); }); // Route::any('/main','MainController@index'); // Route::group(['prefix'=>'Guest','namespace'=>'\Guest'],function(){ // Route::get('/','GuestController@index'); // }); }); Queue::pushOn('/queue_mail', new \App\Commands\SendEmail()); Route::get('/weibo/show', 'Admin\\WeiboController@show'); Route::get('/weibo/show/{id}', 'Admin\\WeiboController@show_id'); Route::post('/music/search', 'Admin\\MusicController@search'); //主页 Route::get('/', 'Index\\IndexController@index'); Route::get('/home', 'Index\\IndexController@index'); Route::get('/home/{user_id}', 'Index\\IndexController@index_id'); //nav导航 Route::get('/{nav}', 'Index\\IndexController@nav_index'); Route::get('/{nav}/{user_id}', 'Index\\IndexController@nav_id'); //测试 工作上的小查询 // Route::get('/test','TestController@index'); // Route::get('/test/excel','TestController@excel'); // Route::get('/test/mobile','TestController@mobile'); // Route::get('/test/mobile/excel','TestController@mobile_excel');
/** * Upload & Resize the file from \File or url * @param string $type * @param string $input * @param string $name * @param array|null $crop * @param array|null $rotate * @return ImageFile instance */ public function upload($type, $input, $name, $crop = null, $rotate = null, $override_config = []) { if (strlen($name) > 255) { throw new \TarunMangukiya\ImageResizer\Exception\TooLongFileNameException("Error Processing Request", 1); } // Get Config for the current Image type $type_config = ImageResizerConfig::getTypeConfig($type, $override_config); $crop_enabled = $type_config['crop']['enabled']; // Get the original save location according to config if ($crop_enabled && null !== $crop) { $original_location = array_key_exists('uncropped_image', $type_config['crop']) ? $type_config['crop']['uncropped_image'] : $type_config['original']; } else { $original_location = $type_config['original']; } // Check input type is $_FILES input name or local file or url // Check for Input File if (\Request::hasFile($input)) { $original_file = $this->moveUploadedFile($input, $name, $original_location); } elseif (file_exists($input)) { $original_file = $this->copyFile($input, $name, $original_location); } elseif (filter_var($input, FILTER_VALIDATE_URL) !== FALSE) { $original_file = $this->transferURLFile($input, $name, $original_location); } else { throw new \TarunMangukiya\ImageResizer\Exception\InvalidInputException("Invalid Input for Image Resizer."); } // crop the image if enabled if ($crop_enabled && null !== $crop) { $file = $this->transformImage($original_file, $type_config, $crop, $rotate); } else { $file = $original_file; } // Check if there is no resize of files if (count($type_config['sizes'])) { $job = new ResizeImages($file, $type_config); // Check if we have to queue the resize of the image if ($this->config['queue']) { \Queue::pushOn($this->config['queue_name'], $job); } else { $job->handle(); } } return $file; }