Coder Social home page Coder Social logo

lektor-gae's Introduction

lektor-gae

lektor-gae publishes your Lektor project to Google App Engine.

Getting started

You need to have a Google App Engine instance ready, and you need to know the application id. Ideally, the instance will be new or empty, since the generated site will completely replace any existing application.

You also need to have the Google App Engine Python/PHP SDK installed, and appcfg.py needs to be in the system PATH environment variable.

Refer to the Google App Engine Documentation for more details about how to get up and running.

Installation and Usage

The plugin can be installed in the usual manner. In your project folder, run

lektor plugins add lektor-gae

Then, add an app to your project. In its project file, add the following:

[servers.gae]
name = Some Descriptive Name
enabled = yes
target = gae://YOUR-APP-ID[/VERSION]

Replace YOUR-APP-ID with your particular app id; optionally, specify a version. If no version is specified, it will default to 1.

Now, lektor deploy will generate the necessary app.yaml and call appcfg.py to deploy your application.

Scripting

Any files with .php extension will be uploaded and executable. It is therefore possible to add PHP scripts to either the assets folder or to add Lektor pages with .php extension for dynamic generation.

Two special cases (below) provide some rudimentary HTTP response codes.

Page not found

If 404.php exists in the root of your site, then it will be invoked as the final fallback (i.e. when the requested path doesn't match any of your published pages). Note that if you don't provide a 404.php, then you will have GAE's default behavior, which is a 404 HTTP code without any page content. Below is a simple 404 script which could be placed under assets. It includes 404.html, which could presumably be generated by Lektor:

<?php http_response_code(404); require('404.html'); ?>

Canonical URLs

If 301.php exists in the root of your site, then it will be invoked when a trailing slash is not included in the request for a page. This helps provide consistent URLs for all pages on the site. Below is a simple 301 script which provides the redirect. Note that it needs to be a template, as currently written; it could be placed under assets if the site base URL were hard-coded.

<?php
$url = '{{ ('/'|url(external=True))[:-1] }}'.strtok($_SERVER['REQUEST_URI'],'?').'/';
header('Location: '.$url, TRUE, 301);
?>

Contributing

Pull requests are encouraged! Once accepted, changes are published using lektor with lektor dev publish-plugin.

lektor-gae's People

Contributors

isotherm avatar

Stargazers

Ali Rathore avatar

Watchers

 avatar

lektor-gae's Issues

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.