Code Monkey home page Code Monkey logo

grow-ext-google-cloud-images's Introduction

Grow.dev

PyPi GitHub Actions Downloads Code Coverage

Grow is a declarative tool for rapidly building, launching, and maintaining high-quality static HTML.

  • Easy installation
  • Jinja template engine
  • Content managed in YAML and JSON files
  • Data-binding between content and templates
  • Configuration-based site architecture
  • Easy URL changes
  • Flexible internationalization and translation
  • Integration with external CMSes
  • Integration with Google Sheets
  • Fast builds

Quick start

One time only: install Pipenv and libyaml.

# On Mac with Homebrew (https://brew.sh/).
brew install pipenv libyaml

# On Ubuntu.
sudo apt install -y pipenv libyaml-dev

# On other distributions.
sudo apt install python-pip; pip install pipenv

Next: install and run Grow using a starter.

git clone https://github.com/grow/starter
cd starter
pipenv install
pipenv run grow install
pipenv run grow run

Documentation

Visit https://grow.dev to read the documentation.

grow-ext-google-cloud-images's People

Contributors

jeremydw avatar stevenle avatar zoramite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grow-ext-google-cloud-images's Issues

Store cache data outside of podcache

I think we should consider moving the gcs cache data outside of podcache since that file often has merge conflicts in a multi-developer project. Should consider choosing a storage method that has fast/efficient serialization and minimizes merge conflicts.

Add asset uploader pipeline support

One internal project I've worked on has an asset pipeline that automatically uploads files from Google Drive to Google Cloud Storage, keyed by folder title and folder modification time.

We should:

  • Add official support for this type of pipeline to the extension.
  • Remove dependency on objectcache.json for files uploaded by the pipeline (auto-uploaded assets generate objectcache data on the server rather than the client, so the cache data can be pulled offline and stored locally in cache files keyed by folder title).
  • Add support for locale groups when working with localized assets (so [email protected] will work, where foo is the name of a Grow locale group defined in podspec.yaml)

Add retries

Sometimes the backend throws TransformationError when subsequent requests work. We should make the backend retry 1-3 times before giving up to avoid broken builds.

Image collection + management workflow

We should enhance the functionality of this extension with a few new workflow items. The goal of this project is to increase developer efficiency and empower stakeholders to replace and upload images immediately in the staging environment.

Developer changes

First, we should allow developers to refer to Google Cloud Images by an ID. This removes the need for a developer to decide upon or care about a filename in advance. The IDs should be be usable in either YAML or Jinja templates.

Example syntax (open to other suggestions, this overloads the current syntax which is a full bucket path).

image: !google_cloud_image product1.hero.bg
# Where bucket/product1.hero.bg is some identifier decided upon by the developer.
{{google_cloud_image('bucket/product1.hero.bg')}}

These would return a GoogleCloudImage object, say image.

Now, in templates, consistent with current functionality:

{# Returns a URL that serves `bucket/product1.hero` with `=s1440` suffixed. #}
{{image.url(['s1440']}}

The catch, though, is the following: in development and staging, we want the URL to point to the Google Cloud Images backend, which returns a 302 redirect to the correct image's serving_url. In production, we want the URL to point to the production serving URL generated by Google.

We want to do this in order to enable live uploads + replaces in development and staging without having to rebuild the page. Each reupload of an asset would then create a new serving URL in the backend, and the backend would be able to redirect requests in the proxy to the serving URL.

Example in development/staging

{{image.url(['s1440']}}

Renders to ->
https://gci.grow.io/redirect/bucket/product1.hero.bg=s1440

Requests to that URL 302 redirect to ->
https://lh3.googleusercontent.com/UN7taQ_uv67DQ2BO_WAc5i-b_KHPl4hWXQYG9dj_8FesTSruE_k-AyPId2Jc1DujAMP_kFpD413i8T4TK-O_=s1440

This can be achieved by a theoretical new configuration option proxy in podspec.yaml:

preprocessors:
- kind: google_cloud_images
  backend: https://gci.grow.io
  proxy: true
  [email protected]: false

Changes to uploader

We have an incredibly minimal uploader now which simply uploads images to Google Cloud Storage and generates a serving URL for them. We should enhance this uploader to actually store a mapping in Datastore (or GCS - if desired) that will store metadata about the image, so it can be displayed in the UI, and so that we have a mapping of image ID to serving URL.

Some metadata to store:

  • Image format
  • Image dimensions
  • Uploaded time
  • Image ID

Changes to UI

At render time (if proxy is true and if the UI tools are on) โ€“ we should collect all of the google_cloud_image dependencies so we can produce a UI allowing stakeholders to audit all the Google Cloud Images on a page and have a way to drag and drop replace them.

New UI tool button

image

Images modal dialog

image

Hover states in dialog

image

Add support for localized image fallback

  • If the requested path is suffixed with @{locale}, the system should use the image corresponding to the current document's locale.
  • In the absence of a matching @{locale} file, @{locale} should be stripped and the system should use the root image.

Example:

# On /de/page.html ->
{{google_image("/bucket/folder/path@{locale}.jpg").url()}}

# If /bucket/folder/[email protected] exists -> serve it.
# If not -> /bucket/folder/path.jpg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.