PluginProbe
WP-Stateless – Google Cloud Storage / 2.2.6
WP-Stateless – Google Cloud Storage v2.2.6
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / static / scripts / wp-stateless.js

wp-stateless.js in WP-Stateless – Google Cloud Storage 2.2.6, at static/scripts/wp-stateless.js

807 lines 22.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 *
3 *
4 */
5
6 // Application
7 var wpStatelessApp = angular.module('wpStatelessApp', [])
8
9 // Controller
10 .controller('wpStatelessTools', ['$scope', '$http', function ($scope, $http) {
11
12 var WP_DEBUG = wp_stateless_configs.WP_DEBUG || false;
13 $scope.action = 'regenerate_images';
14 $scope.method = 'start';
15 $scope.bulk_size = 1;
16
17 /**
18 * Counters
19 * @type {number}
20 */
21 $scope.objectsCounter = 0;
22 $scope.objectsTotal = 0;
23
24 /**
25 * Error storage
26 * @type {boolean}
27 */
28 $scope.error = false;
29
30 /**
31 * Flags
32 * @type {boolean}
33 */
34 $scope.isRunning = false;
35 $scope.isLoading = false;
36 $scope.continue = true;
37
38 /**
39 *
40 * @type {{images: boolean, other: boolean}}
41 */
42 $scope.progresses = {
43 images: false,
44 other: false
45 };
46
47 /**
48 *
49 * @type {{images: boolean, other: boolean}}
50 */
51 $scope.fails = {
52 images: false,
53 other: false
54 }
55
56 /**
57 * IDs storage
58 * @type {Array}
59 */
60 $scope.objectIDs = [];
61
62 /**
63 *
64 * @type {Array}
65 */
66 $scope.chunkIDs = [];
67
68 /**
69 * Log
70 * @type {Array}
71 */
72 $scope.log = [];
73
74 /**
75 * Status message
76 * @type {String}
77 */
78 $scope.status = '';
79
80 /**
81 * Status message
82 * @type {String}
83 */
84 $scope.extraStatus = '';
85
86 /**
87 * Init
88 */
89 $scope.init = function() {
90 jQuery("#regenthumbs-bar").progressbar();
91 }
92
93 /**
94 * Get error message
95 */
96 $scope.getError = function(response, message) {
97 if(response.data && typeof response.data.data !== 'undefined' && typeof response.data.success !== 'undefined' && response.data.success == false){
98 $scope.extraStatus = response.data.data;
99 return message;
100 }
101
102 if(response.data && typeof response.data.data !== 'undefined'){
103 return response.data.data;
104 }
105
106 if(response.data && typeof response.data == 'string'){
107 $scope.extraStatus = response.data;
108 return message;
109 }
110
111 if(!response.data && response.statusText){
112 return response.statusText + " (" + stateless_l10n.response_code + response.status + ")";
113 }
114
115 if(!response.data && response.status == -1){
116 return stateless_l10n.unable_to_connect_to_the_server;
117 }
118
119 return message;
120 }
121
122 /**
123 *
124 * @param callback
125 */
126 $scope.getCurrentProgresses = function( callback ) {
127 $scope.isLoading = true;
128
129 $http({
130 method: 'GET',
131 url: ajaxurl,
132 params: {
133 action: 'stateless_get_current_progresses'
134 }
135 }).then(function(response){
136 var data = response.data || {};
137
138 if ( data.success ) {
139 if ( typeof data.data !== 'undefined' ) {
140 $scope.progresses.images = data.data.images;
141 $scope.progresses.other = data.data.other;
142 $scope.startFrom = null;
143 if($scope.action == 'regenerate_images' && typeof $scope.progresses.images[1] == "number"){
144 // Subtracting 1 so user get where from the sync will start instead of where it ended. We will add 1 in class-ajax.php.
145 $scope.startFrom = $scope.progresses.images[1] - 1;
146 }
147 else if($scope.action == 'sync_non_images' && typeof $scope.progresses.other[1] == "number"){
148 // Subtracting 1 so user get where from the sync will start instead of where it ended. We will add 1 in class-ajax.php.
149 $scope.startFrom = $scope.progresses.other[1] - 1;
150 }
151
152 if ( 'function' === typeof callback ) {
153 callback();
154 }
155 } else {
156 console.error( stateless_l10n.could_not_retrieve_progress );
157 }
158 } else {
159 console.error( stateless_l10n.could_not_retrieve_progress );
160 }
161
162 $scope.isLoading = false;
163 }, function(response) {
164 console.error( stateless_l10n.could_not_retrieve_progress );
165
166 $scope.isLoading = false;
167 });
168 };
169
170 /**
171 *
172 */
173 $scope.getCurrentProgresses();
174
175 /**
176 *
177 * @param callback
178 */
179 function getAllFails( callback ) {
180 $scope.isLoading = true;
181
182 $http({
183 method: 'GET',
184 url: ajaxurl,
185 params: {
186 action: 'stateless_get_all_fails'
187 }
188 }).then(function(response){
189 var data = response.data || {};
190
191 if ( data.success ) {
192 if ( typeof data.data !== 'undefined' ) {
193
194 $scope.fails.images = data.data.images;
195 $scope.fails.other = data.data.other;
196
197 if ( 'function' === typeof callback ) {
198 callback();
199 }
200 } else {
201 console.error( stateless_l10n.could_not_get_fails );
202 }
203 } else {
204 console.error( stateless_l10n.could_not_get_fails );
205 }
206
207 $scope.isLoading = false;
208 }, function(response) {
209 console.error( stateless_l10n.could_not_get_fails );
210
211 $scope.isLoading = false;
212 });
213 };
214
215 getAllFails();
216
217 /**
218 * Form submit handler
219 * @param e
220 * @returns {boolean}
221 */
222 $scope.processStart = function(e) {
223
224 $scope.error = false;
225 $scope.status = '';
226 $scope.extraStatus = '';
227 $scope.objectsCounter = 0;
228 $scope.objectsTotal = 0;
229 $scope.objectIDs = [];
230 $scope.chunkIDs = [];
231
232 if ( $scope.method === 'fix' ) {
233
234 if ( $scope.action ) {
235 switch( $scope.action ) {
236 case 'regenerate_images':
237 $scope.objectIDs = $scope.fails.images;
238 $scope.regenerateImages();
239 break;
240 case 'sync_non_images':
241 $scope.objectIDs = $scope.fails.other;
242 $scope.syncFiles();
243 break;
244 default: break;
245 }
246 }
247
248 return false;
249 }
250
251 var cont = 0;
252 if ( 'continue' === $scope.method ) {
253 cont = 1;
254 }
255
256 if ( $scope.action ) {
257 switch( $scope.action ) {
258 case 'regenerate_images':
259 $scope.getImagesMedia( $scope.regenerateImages, cont );
260 break;
261 case 'sync_non_images':
262 $scope.getOtherMedia( $scope.syncFiles, cont );
263 break;
264 case 'sync_non_library_files':
265 $scope.getNonLibraryFiles( $scope.syncNonLibraryFiles, cont );
266 break;
267 default: break;
268 }
269 }
270
271 return false;
272 };
273
274 /**
275 * Stop process
276 */
277 $scope.processStop = function() {
278 $scope.status = stateless_l10n.stopping;
279 $scope.continue = false;
280 };
281
282 function array_bulk( arr, bulk_size ) {
283 var groups = [];
284 var i;
285
286 for ( i = 0; i < bulk_size; i++ ) {
287 groups[ i ] = [];
288 }
289
290 for ( i = 0; i < arr.length; i ++ ) {
291 groups[ i % bulk_size ].push( arr[ i ] );
292 }
293
294 return groups;
295 }
296
297 $scope.finishProcess = function( chunk_id ) {
298 var mode = 'images';
299 if ( 'sync_non_images' === $scope.action ) {
300 mode = 'other';
301 }
302
303 if ( $scope.objectsCounter >= $scope.objectsTotal ) {
304 // process finished
305
306 $http({
307 method: 'GET',
308 url: ajaxurl,
309 params: {
310 action: 'stateless_reset_progress',
311 mode: mode
312 }
313 }).then(function(response){
314 $scope.progresses[ mode ] = false;
315
316 $scope.status = stateless_l10n.finished;
317 $scope.isLoading = false;
318 $scope.isRunning = false;
319 }, function(response) {
320 console.error( stateless_l10n.could_not_reset_progress );
321 });
322 } else if ( 'undefined' !== typeof chunk_id ) {
323 // process cancelled, but this is only a chunk finishing request
324
325 $scope.chunkIDs[ chunk_id ] = false;
326 var all_done = true;
327 for ( var i in $scope.chunkIDs ) {
328 if ( false !== $scope.chunkIDs[ i ] ) {
329 all_done = false;
330 break;
331 }
332 }
333 if ( all_done ) {
334 $scope.getCurrentProgresses( function() {
335 $scope.status = stateless_l10n.cancelled;
336 $scope.isRunning = false;
337 });
338 }
339 } else {
340 // process cancelled
341
342 $scope.getCurrentProgresses( function() {
343 $scope.status = stateless_l10n.cancelled;
344 $scope.isRunning = false;
345 });
346 }
347 };
348
349 /**
350 * Load images IDs
351 * @param callback
352 */
353 $scope.getImagesMedia = function( callback, cont ) {
354
355 $scope.continue = true;
356 $scope.isLoading = true;
357 $scope.status = stateless_l10n.loading_images_media_objects;
358
359 $http({
360 method: 'GET',
361 url: ajaxurl,
362 params: {
363 action: 'get_images_media_ids',
364 start_from: $scope.startFrom,
365 continue: cont
366 }
367 }).then(function(response){
368 var data = response.data || {};
369
370 if ( data.success ) {
371 if ( typeof callback === 'function' ) {
372 if ( typeof data.data !== 'undefined' ) {
373 $scope.objectIDs = data.data;
374 callback();
375 } else {
376 $scope.status = stateless_l10n.ids_are_malformed;
377 $scope.error = true;
378 }
379 }
380 } else {
381 $scope.status = $scope.getError(response, stateless_l10n.unable_to_get_images_media_id);
382 $scope.error = true;
383 }
384
385 $scope.isLoading = false;
386
387 if(WP_DEBUG){
388 console.log(stateless_l10n.wp_stateless_get_images_media_id, response);
389 }
390
391 }, function(response) {
392 $scope.error = true;
393 $scope.status = $scope.getError(response, get_images_media_id + ": " + stateless_l10n.request_failed);
394 $scope.isLoading = false;
395
396 if(WP_DEBUG){
397 console.log(stateless_l10n.wp_stateless_get_images_media_id + ": " + stateless_l10n.request_failed, response, typeof response.headers === 'function'?response.headers() : '');
398 }
399 });
400
401 };
402
403 /**
404 * Load non-images media files
405 * @param callback
406 */
407 $scope.getOtherMedia = function( callback, cont ) {
408
409 $scope.continue = true;
410 $scope.isLoading = true;
411 $scope.status = stateless_l10n.loading_non_image_media_objects;
412
413 $http({
414 method: 'GET',
415 url: ajaxurl,
416 params: {
417 action: 'get_other_media_ids',
418 start_from: $scope.startFrom,
419 continue: cont
420 }
421 }).then(function(response){
422 var data = response.data || {};
423
424 if ( data.success ) {
425 if ( typeof callback === 'function' ) {
426 if ( typeof data.data !== 'undefined' ) {
427 $scope.objectIDs = data.data;
428 callback();
429 } else {
430 $scope.status = $scope.getError(response, stateless_l10n.ids_are_malformed);
431 $scope.error = true;
432 }
433 }
434 } else {
435 $scope.status = $scope.getError(response, stateless_l10n.unable_to_get_non_images_media_id);
436 $scope.error = true;
437 }
438
439 $scope.isLoading = false;
440
441 if(WP_DEBUG){
442 console.log("WP-Stateless get non Images Media ID:", response, typeof response.headers === 'function'?response.headers(): "");
443 }
444 }, function(response) {
445 $scope.error = true;
446 $scope.status = $scope.getError(response, stateless_l10n.get_non_images_media_id_request_failed);
447 $scope.isLoading = false;
448 if(WP_DEBUG){
449 console.log("WP-Stateless get non Images Media ID: Request failed", response, typeof response.headers === 'function'?response.headers(): "");
450 }
451 });
452
453 };
454
455 /**
456 * Load non-images media files
457 * @param callback
458 */
459 $scope.getNonLibraryFiles = function( callback, cont ) {
460
461 $scope.continue = true;
462 $scope.isLoading = true;
463 $scope.status = stateless_l10n.loading_non_library_objects;
464
465 $http({
466 method: 'GET',
467 url: ajaxurl,
468 params: {
469 action: 'get_non_library_files_id',
470 continue: cont
471 }
472 }).then(function(response){
473 var data = response.data || {};
474
475 if ( data.success ) {
476 if ( typeof callback === 'function' ) {
477 if ( typeof data.data !== 'undefined' ) {
478 $scope.objectIDs = data.data;
479 callback();
480 } else {
481 $scope.status = $scope.getError(response, stateless_l10n.ids_are_malformed);
482 $scope.error = true;
483 }
484 }
485 } else {
486 $scope.error = true;
487 $scope.status = $scope.getError(response, stateless_l10n.non_libraries_files_are_not_found);
488 }
489
490 $scope.isLoading = false;
491
492 if(WP_DEBUG){
493 console.log("WP-Stateless get non library files:", response, typeof response.headers === 'function'?response.headers(): "");
494 }
495 }, function(response) {
496 $scope.error = true;
497 $scope.status = $scope.getError(response, stateless_l10n.get_non_library_files_request_failed);
498 $scope.isLoading = false;
499
500 if(WP_DEBUG){
501 console.log("WP-Stateless get non library files: Request failed", response, typeof response.headers === 'function'?response.headers(): "");
502 }
503 });
504
505 };
506
507 /**
508 * Run sync for files
509 */
510 $scope.syncNonLibraryFiles = function() {
511 $scope.isRunning = true;
512 $scope.objectsTotal = $scope.objectIDs.length;
513 $scope.objectsCounter = 0;
514 $scope.status = stateless_l10n.processing_files + $scope.objectsTotal + stateless_l10n._total___;
515
516 jQuery("#regenthumbs-bar").progressbar("value", 0);
517 jQuery("#regenthumbs-bar-percent").html( "0%" );
518
519 if ( $scope.objectIDs.length ) {
520 //$scope.syncSingleNonLibraryFile( $scope.objectIDs.shift() );
521 $scope.chunkIDs = array_bulk( $scope.objectIDs, $scope.bulk_size );
522 for ( var i in $scope.chunkIDs ) {
523 $scope.syncSingleNonLibraryFile( $scope.chunkIDs[ i ].shift(), i );
524 }
525 }
526 }
527
528 /**
529 * Run sync for files
530 */
531 $scope.syncFiles = function() {
532 $scope.isRunning = true;
533 $scope.objectsTotal = $scope.objectIDs.length;
534 $scope.objectsCounter = 0;
535 $scope.status = stateless_l10n.processing_files + $scope.objectsTotal + stateless_l10n._total___;
536
537 jQuery("#regenthumbs-bar").progressbar("value", 0);
538 jQuery("#regenthumbs-bar-percent").html( "0%" );
539
540 if ( $scope.objectIDs.length ) {
541 //$scope.syncSingleFile( $scope.objectIDs.shift() );
542 $scope.chunkIDs = array_bulk( $scope.objectIDs, $scope.bulk_size );
543 for ( var i in $scope.chunkIDs ) {
544 $scope.syncSingleFile( $scope.chunkIDs[ i ].shift(), i );
545 }
546 }
547 }
548
549 /**
550 * Run images regeneration
551 * @param ids
552 */
553 $scope.regenerateImages = function() {
554 $scope.isRunning = true;
555 $scope.objectsTotal = $scope.objectIDs.length;
556 $scope.objectsCounter = 0;
557 $scope.status = stateless_l10n.processing_images + $scope.objectsTotal + stateless_l10n._total___;
558
559 jQuery("#regenthumbs-bar").progressbar("value", 0);
560 jQuery("#regenthumbs-bar-percent").html( "0%" );
561
562 if ( $scope.objectIDs.length ) {
563 //$scope.regenerateSingle( $scope.objectIDs.shift() );
564 $scope.chunkIDs = array_bulk( $scope.objectIDs, $scope.bulk_size );
565 for ( var i in $scope.chunkIDs ) {
566 $scope.regenerateSingle( $scope.chunkIDs[ i ].shift(), i );
567 }
568 }
569 };
570
571 /**
572 * Process Single Image
573 * @param id
574 */
575 $scope.regenerateSingle = function( id, chunk_id ) {
576
577 $http({
578 method: 'GET',
579 url: ajaxurl,
580 params: {
581 action: "stateless_process_image",
582 id: id
583 }
584 }).then(
585 function(response) {
586 var data = response.data || {};
587 $scope.log.push({message:data.data || stateless_l10n.regenerate_single_image_failed});
588
589 jQuery("#regenthumbs-bar").progressbar( "value", ( ++$scope.objectsCounter / $scope.objectsTotal ) * 100 );
590 jQuery("#regenthumbs-bar-percent").html( Math.round( ( $scope.objectsCounter / $scope.objectsTotal ) * 1000 ) / 10 + "%" );
591
592 if(typeof response.data.success == 'undefined' || response.data.success == false){
593 $scope.error = true;
594 $scope.status = $scope.getError(response, stateless_l10n.regenerate_single_image_failed);
595 // $scope.isRunning = false;
596 }
597
598 if ( 'undefined' !== typeof chunk_id ) {
599 if ( $scope.chunkIDs[ chunk_id ].length && $scope.continue ) {
600 $scope.regenerateSingle( $scope.chunkIDs[ chunk_id ].shift(), chunk_id );
601 } else {
602 $scope.finishProcess( chunk_id );
603 }
604 } else {
605 if ( $scope.objectIDs.length && $scope.continue ) {
606 $scope.regenerateSingle( $scope.objectIDs.shift() );
607 } else {
608 $scope.finishProcess();
609 }
610 }
611 if(WP_DEBUG){
612 console.log("WP-Stateless regenerate single image:", response, typeof response.headers === 'function'?response.headers(): "");
613 }
614 },
615 function(response) {
616 $scope.error = true;
617 $scope.status = $scope.getError(response, stateless_l10n.regenerate_single_image_request_failed);
618 $scope.isRunning = false;
619 if(WP_DEBUG){
620 console.log("WP-Stateless regenerate single image: Request failed", response, typeof response.headers === 'function'?response.headers(): "");
621 }
622 }
623 );
624
625 }
626
627 /**
628 * Process single file
629 * @param id
630 */
631 $scope.syncSingleFile = function( id, chunk_id ) {
632
633 $http({
634 method: 'GET',
635 url: ajaxurl,
636 params: {
637 action: "stateless_process_file",
638 id: id
639 }
640 }).then(
641 function(response) {
642 var data = response.data || {};
643 $scope.log.push({message: $scope.getError(response, stateless_l10n.sync_single_file_failed)});
644
645 jQuery("#regenthumbs-bar").progressbar( "value", ( ++$scope.objectsCounter / $scope.objectsTotal ) * 100 );
646 jQuery("#regenthumbs-bar-percent").html( Math.round( ( $scope.objectsCounter / $scope.objectsTotal ) * 1000 ) / 10 + "%" );
647
648 if(typeof response.data.success == 'undefined' || response.data.success == false){
649 $scope.error = true;
650 $scope.status = $scope.getError(response, stateless_l10n.sync_single_file_failed);
651 // $scope.isRunning = false;
652 }
653
654 if ( 'undefined' !== typeof chunk_id ) {
655 if ( $scope.chunkIDs[ chunk_id ].length && $scope.continue ) {
656 $scope.syncSingleFile( $scope.chunkIDs[ chunk_id ].shift(), chunk_id );
657 } else {
658 $scope.finishProcess( chunk_id );
659 }
660 } else {
661 if ( $scope.objectIDs.length && $scope.continue ) {
662 $scope.syncSingleFile( $scope.objectIDs.shift() );
663 } else {
664 $scope.finishProcess();
665 }
666 }
667
668 if(WP_DEBUG){
669 console.log("WP-Stateless sync single file:", response, typeof response.headers === 'function'?response.headers(): "");
670 }
671 },
672 function(response) {
673 $scope.error = true;
674 $scope.status = $scope.getError(response, stateless_l10n.sync_single_file_request_failed);
675 $scope.isRunning = false;
676
677 if(WP_DEBUG){
678 console.log("WP-Stateless sync single file: Request failed", response, typeof response.headers === 'function'?response.headers(): "");
679 }
680 }
681 );
682
683 }
684
685 /**
686 * Process single file
687 * @param id
688 */
689 $scope.syncSingleNonLibraryFile = function( id, chunk_id ) {
690
691 $http({
692 method: 'GET',
693 url: ajaxurl,
694 params: {
695 action: "stateless_process_non_library_file",
696 file_path: id
697 }
698 }).then(
699 function(response) {
700 var data = response.data || {};
701 $scope.log.push({message: $scope.getError(response, stateless_l10n.failed_to_sync + id)});
702
703 jQuery("#regenthumbs-bar").progressbar( "value", ( ++$scope.objectsCounter / $scope.objectsTotal ) * 100 );
704 jQuery("#regenthumbs-bar-percent").html( Math.round( ( $scope.objectsCounter / $scope.objectsTotal ) * 1000 ) / 10 + "%" );
705
706 if(typeof response.data.success == 'undefined' || response.data.success == false){
707 $scope.error = true;
708 $scope.status = $scope.getError(response, stateless_l10n.sync_non_library_file_failed);
709 // $scope.isRunning = false;
710 }
711
712 if ( 'undefined' !== typeof chunk_id ) {
713 if ( $scope.chunkIDs[ chunk_id ].length && $scope.continue ) {
714 $scope.syncSingleNonLibraryFile( $scope.chunkIDs[ chunk_id ].shift(), chunk_id );
715 } else {
716 $scope.finishProcess( chunk_id );
717 }
718 } else {
719 if ( $scope.objectIDs.length && $scope.continue ) {
720 $scope.syncSingleNonLibraryFile( $scope.objectIDs.shift() );
721 } else {
722 $scope.finishProcess();
723 }
724 }
725
726 if(WP_DEBUG){
727 console.log("WP-Stateless sync non library file:", response, typeof response.headers === 'function'?response.headers(): "");
728 }
729 },
730 function(response) {
731 $scope.error = true;
732 $scope.status = $scope.getError(response, stateless_l10n.sync_non_library_file_request_failed);
733 $scope.isRunning = false;
734
735 if(WP_DEBUG){
736 console.log("WP-Stateless sync non library file: Request failed", response, typeof response.headers === 'function'?response.headers():{});
737 }
738 }
739 );
740
741 }
742
743 }])
744 .controller('wpStatelessSettings', function($scope, $filter) {
745 $scope.backup = {};
746 $scope.sm = wp_stateless_settings || {};
747
748 $scope.$watch('sm.mode', function(value) {
749 if(value == 'stateless'){
750 $scope.backup.hashify_file_name = $scope.sm.hashify_file_name;
751 $scope.sm.hashify_file_name = 'true';
752 // $scope.apply();
753 }
754 else{
755 if($scope.backup.hashify_file_name){
756 $scope.sm.hashify_file_name = $scope.backup.hashify_file_name;
757 // $scope.apply();
758 }
759 }
760 });
761
762 $scope.sm.showNotice = function(option){
763 if($scope.sm.readonly && $scope.sm.readonly[option]){
764 var slug = $scope.sm.readonly[option];
765 return $scope.sm.strings[slug];
766 }
767 }
768
769 $scope.sm.generatePreviewUrl = function() {
770 $scope.sm.is_custom_domain = false;
771 var host = 'https://storage.googleapis.com/';
772 var rootdir = $scope.sm.root_dir ? $scope.sm.root_dir + '/' : '';
773 var subdir = $scope.sm.organize_media == '1' ? $filter('date')(Date.now(), 'yyyy/MM') + '/' : '';
774 var hash = $scope.sm.hashify_file_name == 'true' ? Date.now().toString(36) + '-' : '';
775 var is_ssl = $scope.sm.custom_domain.indexOf('https://');
776 var custom_domain = $scope.sm.custom_domain.toString();
777
778 custom_domain = custom_domain.replace(/\/+$/, ''); // removing trailing slashes
779 custom_domain = custom_domain.replace(/https?:\/\//, ''); // removing http:// or https:// from the beginning.
780 host += $scope.sm.bucket ? $scope.sm.bucket : '{bucket-name}';
781
782 if ( custom_domain !== 'storage.googleapis.com' && $scope.sm.bucket && custom_domain && ( is_ssl === 0 || custom_domain == $scope.sm.bucket ) ) {
783 $scope.sm.is_custom_domain = true;
784 $scope.sm.is_ssl = is_ssl === 0 ? true : false;
785 host = is_ssl === 0 ? 'https://' : 'http://'; // bucketname will be host
786 host += custom_domain;
787 }
788
789 $scope.sm.preview_url = host + "/" + rootdir + subdir + hash + "your-image-name.jpeg";
790 }
791
792 $scope.sm.generatePreviewUrl();
793
794 })
795 .controller('wpStatelessCompatibility', function($scope, $filter) {
796 $scope.modules = wp_stateless_compatibility || {};
797 })
798 .controller('noJSWarning', function($scope, $filter) {
799 $scope.jsLoaded = true;
800 });
801
802 wpStatelessApp.filter("trust", ['$sce', function($sce) {
803 return function(htmlCode){
804 return $sce.trustAsHtml(htmlCode);
805 }
806 }]);
807