Skip to content

Commit

Permalink
Merge pull request #21 from openizr/prerenderer
Browse files Browse the repository at this point in the history
Prerenderer v3
  • Loading branch information
matthieujabbour authored Mar 16, 2022
2 parents 456d57d + 6c73932 commit 092eb8e
Show file tree
Hide file tree
Showing 83 changed files with 14,446 additions and 284 deletions.
58 changes: 58 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
257 changes: 257 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
# Created by https://www.gitignore.io/api/composer,node,vim,sublimetext,phpstorm,linux,macos,notepadpp,windows

### Composer ###
composer.phar
/vendor/

# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env


### NotepadPP ###
# Notepad++ backups #
*.bak

### PhpStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# custom modification: ignore all .idea folder
.idea/

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### PhpStorm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

### SublimeText ###
# cache files for sublime text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache

# workspace files are user-specific
*.sublime-workspace

# project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using SublimeText
# *.sublime-project

# sftp configuration file
sftp-config.json

# Package control specific files
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Package Control.merged-ca-bundle
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt
bh_unicode_properties.cache

# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings

### Vim ###
# swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# session
Session.vim
# temporary
.netrwhist
# auto-generated tag files
tags

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/composer,node,vim,sublimetext,phpstorm,linux,macos,notepadpp,windows

# Additional rules

# Documentation
doc

# Testing
coverage
report.html

# Builds
dist
**/public/assets

# Misc
rsync.sh
.awcache
23 changes: 23 additions & 0 deletions prerenderer/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Environment (development|preproduction|production)
ENV=development

# Nginx port
NGINX_PORT=5000

# Prerenderer port
BACKEND_PORT=9001

# Which network interface should expose app's ports
HOST_IP=127.0.0.1

# List of trusted proxies CIDRs
TRUSTED_PROXIES=127.0.0.1/32

# Used to uniquely identify your Docker project
PROJECT_NAME=prerenderer

# Nginx server environment variables (see `openizr/nginx` image)
BOT_USER_AGENTS=(bot|googlebot|crawler|spider|robot|crawling|postman|curl)
FRONTEND_PORT=5000
FRONTEND_HOST=nginx
PRERENDERER_URI=http://prerenderer:9001
13 changes: 13 additions & 0 deletions prerenderer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,16 @@ You should run this container either along with a front server like Nginx, or wi

- *`ENV`*: environment (development|preproduction|production)
- *`BACKEND_PORT`*: listening port for Docker container


## Notifying prerenderer that your page is ready

In order to let prerenderer know that your page has been completely and successfully rendered, you need to insert a special HTML tag with the `prerender` id in the DOM.
For instance:

```html
<meta id="prerender" data-status="200" data-redirect="http://test.com" />
```

Prerender will observe that tag and send back the raw HTML as soon as it is present in the page. The `data-status` allows you to specify the HTTP status code to send back to the robot (200 by default),
and the `data-redirect` lets your define any redirection (HTTP 301) that should be performed by the robot (prerender will insert the `Location` header with that value in its response).
Loading

0 comments on commit 092eb8e

Please sign in to comment.