Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
artemsites committed Jun 1, 2024
0 parents commit c0abf0c
Show file tree
Hide file tree
Showing 102 changed files with 13,888 additions and 0 deletions.
100 changes: 100 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
# https://symfony.com/doc/current/configuration/secrets.html
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration



SHORTCODE_START_REGEXP="\[\["
SHORTCODE_END_REGEXP="\]\]"



APP_GOOGLE_APP_SCRIPTS_TOKEN="9832yc983c0923yv3y#%r9N83983YR93285-3N89C532984CYN&#%rTC379872C"



APP_DEBUG=1



###> symfony/framework-bundle ###
APP_ENV=dev
# APP_ENV=prod

APP_SECRET=093y2032357vny20934v9823yn545v02
###< symfony/framework-bundle ###


###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"



DATABASE_URL="mysql://name:[email protected]:3306/dbname"
# DATABASE_URL="mysql://name:[email protected]:3306/dbname?serverVersion=5.7.21"

# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8.0.32&charset=utf8mb4"
# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"

# to use mariadb:
# Before doctrine/dbal < 3.7
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=mariadb-10.5.8"
# Since doctrine/dbal 3.7
# DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=10.5.8-MariaDB"

# DATABASE_URL="postgresql://app:[email protected]:5432/app?serverVersion=16&charset=utf8"
###< doctrine/doctrine-bundle ###

###> symfony/messenger ###
# Choose one of the transports below
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###< symfony/messenger ###

###> symfony/mailer ###
# MAILER_DSN=null://null
###< symfony/mailer ###



###> symfony/mercure-bundle ###
# See https://symfony.com/doc/current/mercure.html#configuration
# The URL of the Mercure hub, used by the app to publish updates (can be a local URL)
MERCURE_URL=https://example.com/.well-known/mercure
# The public URL of the Mercure hub, used by the browser to connect
MERCURE_PUBLIC_URL=https://example.com/.well-known/mercure
# The secret used to sign the JWTs
MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
###< symfony/mercure-bundle ###



###> google/apiclient ###
# GOOGLE_API_KEY=
# GOOGLE_CLIENT_ID=
# GOOGLE_CLIENT_SECRET=
# GOOGLE_AUTH_CONFIG=%kernel.project_dir%/path/to/file.json
###< google/apiclient ###



# GOOGLE_CLIENT_ID=your-client-id
# GOOGLE_CLIENT_SECRET=your-client-secret
# GOOGLE_REDIRECT_URI=your-redirect-uri
# GOOGLE_SCOPES=Google_Service_Drive::DRIVE_METADATA_READONLY
6 changes: 6 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.lh
.env


###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public_hyml/bundles/
/var/
/vendor/
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

###> symfony/asset-mapper ###
/public_html/assets/
/assets/vendor/
###< symfony/asset-mapper ###
22 changes: 22 additions & 0 deletions .google-scripts/autocreateId.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function autocreateId(e) {
var idColumn = 1;
var startRow = 2;

var range = e.range;
var sheet = range.getSheet();
var editedRow = range.getRow();
var editedColumn = range.getColumn();

if (editedColumn === idColumn || editedRow < startRow) {
return;
}

var idCell = sheet.getRange(editedRow, idColumn);
if (idCell.getValue() !== '') {
return;
}

var uniqueId = new Date().getTime();

idCell.setValue(uniqueId);
}
2 changes: 2 additions & 0 deletions .google-scripts/config.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var host = 'https://some-site.com/';
secretToken = '9832yc983c0923yv3y#%r9N83983YR93285-3N89C532984CYN&#%rTC379872C';
3 changes: 3 additions & 0 deletions .google-scripts/onEdit.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function onEdit(e) {
autocreateId(e);
}
10 changes: 10 additions & 0 deletions .google-scripts/onOpen.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('CMS Sheets')
.addItem('Send to CMS Sheets', 'sendEntireRowToSymfonyWithColumnNames')
.addToUi();

// protectColumnA();
}


65 changes: 65 additions & 0 deletions .google-scripts/protectColumnA.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// function protectColumnA() {
// var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// var range = sheet.getRange('A:A');

// var protection = range.protect().setDescription('Protected Column');

// var me = Session.getEffectiveUser();
// protection.addEditor(me);
// protection.removeEditors(protection.getEditors().filter(function(editor) {
// return editor.getEmail() !== me.getEmail();
// }));

// protection.setWarningOnly(true);
// }



// var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// var range = sheet.getRange('A:A');

// var validationRule = SpreadsheetApp.newDataValidation()
// .requireTextEqualTo('LOCKED COLUMN A')
// .setAllowInvalid(false)
// .setHelpText('This column is protected and cannot be edited!')
// .build();

// range.setDataValidation(validationRule);






// function protectColumnA() {
// var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// var rangeToProtect = sheet.getRange('A:A');
// var protections = sheet.getProtections(SpreadsheetApp.ProtectionType.RANGE);
// var isAlreadyProtected = protections.some(function(protection) {
// var protectedRange = protection.getRange();
// // Check if the new range to protect is fully within an existing protected range
// return rangeToProtect.getRowIndex() >= protectedRange.getRowIndex() &&
// rangeToProtect.getLastRow() <= protectedRange.getLastRow() &&
// rangeToProtect.getColumn() == protectedRange.getColumn() &&
// rangeToProtect.getLastColumn() == protectedRange.getLastColumn();
// });

// if (!isAlreadyProtected) {
// var protection = rangeToProtect.protect().setDescription('Protected Column');

// // Ensure the current user is an editor before removing others.
// var me = Session.getEffectiveUser();
// protection.addEditor(me);
// protection.removeEditors(protection.getEditors().filter(function(editor) {
// return editor.getEmail() !== me.getEmail();
// }));

// // Optionally set as warning only, will show a warning when editing the protected range
// // but not fully prevent the edit.
// protection.setWarningOnly(true);

// // Uncomment the above line if you want to show a warning instead of blocking edits.
// } else {
// Logger.log('Column A is already protected.');
// }
// }
6 changes: 6 additions & 0 deletions .google-scripts/removeProtectionColumnA.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// function removeProtectionColumnA() {
// var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// var range = sheet.getRange('A:A');

// range.clearDataValidations();
// }
49 changes: 49 additions & 0 deletions .google-scripts/sendRowWithColumnNamesToBackend.gs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* domain, secretToken - from config.gs
*/
function sendRowWithColumnNamesToBackend() {
// var ui = SpreadsheetApp.getUi();
// ui.alert(JSON.stringify(sheet.getActiveRange().getNumRows()));



var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

var range = sheet.getActiveRange();
var startRow = range.getRow();
var numRows = range.getNumRows();



for (var i = 0; i < numRows; i++) {
var currentRow = startRow + i;

var numColumns = sheet.getLastColumn();
var headers = sheet.getRange(1, 1, 1, numColumns).getValues()[0];
var valuesToSend = sheet.getRange(currentRow, 1, 1, numColumns).getValues()[0];

var sheetRowData = headers.reduce(function(dataObject, columnName, index) {
dataObject[columnName] = valuesToSend[index];
return dataObject;
}, {});

var requestOptions = {
'method': 'post',
'contentType': 'application/json',
'payload': JSON.stringify({sheetRowData: sheetRowData}),
'headers': {
'Authorization': 'Bearer ' + secretToken
},
};

var sheetName = sheet.getName();
if (sheetName==='Pages') {
UrlFetchApp.fetch(host+'cms-sheets/page-update', requestOptions);
}
else if (sheetName==='Menu') {
UrlFetchApp.fetch(host+'cms-sheets/menu-update', requestOptions);
}
else throw new Error('There is no handler for this sheet!');
}

}
35 changes: 35 additions & 0 deletions .symfony.local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Sets domain1.wip and domain2.wip for the current project
# proxy:
# domains:
# - domain1
# - domain2

http:
# document_root: public/ # Path to the project document root
# passthru: index.php # Project passthru index
port: 8000 # Force the port that will be used to run the server
preferred_port: 8001 # Preferred HTTP port [default: 8000]
# p12: path/to/p12_cert # Name of the file containing the TLS certificate to use in p12 format
# allow_http: true # Prevent auto-redirection from HTTP to HTTPS
# no_tls: true # Use HTTP instead of HTTPS
# daemon: true # Run the server in the background
# use_gzip: true # Toggle GZIP compression

# workers:
# built-in command that builds and watches front-end assets
# npm_encore_watch:
# cmd: ['npx', 'encore', 'dev', '--watch']
# npm_encore_watch: ~

# built-in command that starts messenger consumer
# messenger_consume_async:
# cmd: ['symfony', 'console', 'messenger:consume', 'async']
# watch: ['config', 'src', 'templates', 'vendor']
# messenger_consume_async: ~

# you can also add your own custom commands
# build_spa:
# cmd: ['npm', '--cwd', './spa/', 'dev']

# auto start Docker compose when starting server (available since Symfony CLI 5.7.0)
# docker_compose: ~
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# CMS Sheets - a site management system based on Symfony and Google Tables

---

# Installation

## Clone cms-sheets:
```
git clone [email protected]:artemsites/cms-sheets.git
```

## Copy and rename `.env.example -> .env`




---

# Features

## Fill in the content as HTML or MD
## Insert shortcodes like [[youtube id="7c238trc"]] into the content (HTML or MD)

--

# Configuration

## Vue the type of interpolation brackets is specified in .env:
SHORTCODE_START_REGEXP
SHORTCODE_END_REGEXP
> It shouldn't be {{ }} - it's twig
> It shouldn't be [ ] - this is md content
> Probably better [[ ]]
> ! It is important to specify in REGEXP format, that is, special characters should be escaped \[\[ - otherwise they will be incorrectly read in REGEXP and will not be used
---

# Shortcodes

Double brackets are selected as in MODx: [[shortcodename]],
because there is a conflict with md parsing
(there links look like [name](http://...))

## [[youtube id="7c238trc"]] - YouTube video output
Parameters:
id is the ID of a YouTube video

## [[code code="some code"]] - code block output
Parameters:
code - if this is a link, then we will get the content that is located on the link

## [[articles]] - output of all child articles for this url in the form of links
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1. Make a field in the cms-sheet for sorting positions in navigation
Loading

0 comments on commit c0abf0c

Please sign in to comment.