From 2711ac4afcd8ea9e0cd840a37250acd928e10ba1 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 16 Nov 2026 17:24:59 +0000 Subject: [PATCH 1/6] Build Dune shop catalogue and repair shared menu publication --- website/node/integration-shop-profile.mjs | 5 ++ website/node/integration-sso.mjs | 9 +-- website/ops/oscommerce/DuneAccount.php | 25 +++++-- website/ops/oscommerce/DuneProductRules.php | 35 ++++++++++ website/ops/oscommerce/DuneShopController.php | 40 +++++++++++ website/ops/oscommerce/dune-shop-cards.css | 30 ++++++++ .../ops/oscommerce/finish-catalog-edging.py | 12 ++++ website/ops/oscommerce/import-shop-catalog.py | 70 +++++++++++++++++++ website/ops/oscommerce/install-sash-rules.py | 18 +++++ .../oscommerce/publish-oscommerce-portal.py | 6 +- website/scripts/main-menu.mjs | 11 ++- website/scripts/menu-updates.mjs | 3 +- website/scripts/portal-navigation.mjs | 2 +- website/tests/shop-menu-stability.test.mjs | 17 +++++ website/tests/shop-profile.test.mjs | 8 +++ website/web/oscommerce-inner.js | 2 +- website/web/portal-navigation.js | 24 +++---- website/web/shop-oscommerce.html | 2 +- 18 files changed, 286 insertions(+), 33 deletions(-) create mode 100644 website/node/integration-shop-profile.mjs create mode 100644 website/ops/oscommerce/DuneProductRules.php create mode 100644 website/ops/oscommerce/DuneShopController.php create mode 100644 website/ops/oscommerce/dune-shop-cards.css create mode 100644 website/ops/oscommerce/finish-catalog-edging.py create mode 100644 website/ops/oscommerce/import-shop-catalog.py create mode 100644 website/ops/oscommerce/install-sash-rules.py create mode 100644 website/tests/shop-menu-stability.test.mjs create mode 100644 website/tests/shop-profile.test.mjs diff --git a/website/node/integration-shop-profile.mjs b/website/node/integration-shop-profile.mjs new file mode 100644 index 00000000..afe57c3a --- /dev/null +++ b/website/node/integration-shop-profile.mjs @@ -0,0 +1,5 @@ +export async function shopAccountProfile(db,userId,client){ + if(client!=='oscommerce')return {}; + const contact=await db.prepare('SELECT address,verified_at FROM site_contact_emails WHERE user_id=?').bind(userId).first(); + return {email:contact?.verified_at?contact.address:null,emailVerified:!!contact?.verified_at}; +} diff --git a/website/node/integration-sso.mjs b/website/node/integration-sso.mjs index 3b145b56..2edfe52a 100644 --- a/website/node/integration-sso.mjs +++ b/website/node/integration-sso.mjs @@ -1,3 +1,4 @@ +import {shopAccountProfile} from './integration-shop-profile.mjs'; import {nativeAgentIdentity} from './organisation-native-projection.mjs'; import {communityBadgeVisible} from './community-badges.mjs'; import {publicProfileFor} from './profile.mjs'; @@ -30,7 +31,7 @@ export function createIntegrationSSO(db,settings={}){ if(url.pathname.endsWith('/identity')){ if(!/^[0-9a-f]{64}$/.test(body.sessionRef||''))return json({message:'Unauthorized'},401); const user=await db.prepare('SELECT a.id,a.username,a.display_name,a.role FROM site_sessions s JOIN site_accounts a ON a.id=s.user_id WHERE s.token_hash=? AND s.expires_at>?').bind(body.sessionRef,Date.now()).first(); - return user?describe(user,body.sessionRef):json({message:'Session expired'},401); + return user?describe(user,body.sessionRef,body.client):json({message:'Session expired'},401); } if(!Object.hasOwn(clients,body.client)||!/^[A-Za-z0-9_-]{43}$/.test(body.code||''))return json({message:'Invalid request'},400); const codeHash=hash(body.code),record=await db.prepare('SELECT user_id,session_ref FROM integration_sso_codes WHERE code_hash=? AND client_id=? AND expires_at>?').bind(codeHash,body.client,Date.now()).first(); @@ -39,13 +40,13 @@ export function createIntegrationSSO(db,settings={}){ if(!removed.meta.changes)return json({message:'Expired or already used'},401); const user=await db.prepare('SELECT a.id,a.username,a.display_name,a.role FROM site_sessions s JOIN site_accounts a ON a.id=s.user_id WHERE s.token_hash=? AND s.expires_at>?').bind(record.session_ref,Date.now()).first(); if(!user)return json({message:'Account unavailable'},401); - return describe(user,record.session_ref); - async function describe(user,sessionRef){ + return describe(user,record.session_ref,body.client); + async function describe(user,sessionRef,client){ const access=await accessFor(db,user),link=await db.prepare('SELECT minecraft_uuid FROM site_game_links WHERE user_id=?').bind(user.id).first(); const age=await db.prepare('SELECT age_band FROM site_age_declarations WHERE user_id=?').bind(user.id).first(); const policy=await db.prepare('SELECT service_uuid,game_link_exempt FROM site_account_policies WHERE user_id=?').bind(user.id).first(); const native=nativeAgentIdentity(user,access); - return json({id:user.id,username:user.username,displayName:user.display_name,publicProfile:await publicProfileFor(db,user.id,settings.CP_ORIGIN||'https://cp.dunerealms.com'),role:access.rank,ranks:access.ranks,rankLabel:access.label,rankLevel:access.level,communityBadges:(await badgesFor(db,user.id)).filter(k=>communityBadgeVisible(k,access.ranks)),linked:!!link?.minecraft_uuid,gameLinkExempt:!!policy?.service_uuid&&Number(policy.game_link_exempt)===1,forumAllowed:age?.age_band!=='under15',permissions:native.permissions,...(native.nativePermissionManagement===false?{nativePermissionManagement:false}:{}),sessionRef}); + return json({...await shopAccountProfile(db,user.id,client),id:user.id,username:user.username,displayName:user.display_name,publicProfile:await publicProfileFor(db,user.id,settings.CP_ORIGIN||'https://cp.dunerealms.com'),role:access.rank,ranks:access.ranks,rankLabel:access.label,rankLevel:access.level,communityBadges:(await badgesFor(db,user.id)).filter(k=>communityBadgeVisible(k,access.ranks)),linked:!!link?.minecraft_uuid,gameLinkExempt:!!policy?.service_uuid&&Number(policy.game_link_exempt)===1,forumAllowed:age?.age_band!=='under15',permissions:native.permissions,...(native.nativePermissionManagement===false?{nativePermissionManagement:false}:{}),sessionRef}); } }; } diff --git a/website/ops/oscommerce/DuneAccount.php b/website/ops/oscommerce/DuneAccount.php index 81930418..7a90f7da 100644 --- a/website/ops/oscommerce/DuneAccount.php +++ b/website/ops/oscommerce/DuneAccount.php @@ -2,6 +2,10 @@ namespace frontend\components; use Yii; final class DuneAccount { + private static function email(array $identity):string { + $email=$identity['email']??null; + return ($identity['emailVerified']??false)===true&&is_string($email)&&strlen($email)<=254&&filter_var($email,FILTER_VALIDATE_EMAIL)?$email:$identity['id'].'@accounts.dunerealms.invalid'; + } private static function token(): string { return rtrim(strtr(base64_encode(random_bytes(32)), '+/', '-_'), '='); } private static function cookie(string $name,string $value,int $expires):void { setcookie($name,$value,['expires'=>$expires,'path'=>'/','secure'=>true,'httponly'=>true,'samesite'=>'Lax']); } private static function api(string $operation,array $payload):array { @@ -35,7 +39,9 @@ final class DuneAccount { $db=$app->db;$transaction=$db->beginTransaction(); try{ $id=$db->createCommand('SELECT customer_id FROM dune_account_links WHERE account_id=:id FOR UPDATE',[':id'=>$identity['id']])->queryScalar(); - $email=$identity['id'].'@accounts.dunerealms.invalid'; + $email=self::email($identity); + $collision=$db->createCommand('SELECT customers_id FROM customers WHERE customers_email_address=:email AND customers_id<>:id',[':email'=>$email,':id'=>(int)$id])->queryScalar(); + if($collision)throw new \yii\web\HttpException(409,'This email is linked to another shop customer. Please contact support to link the accounts.'); if(!$id){ $db->createCommand("SET SESSION sql_mode=''")->execute(); $db->createCommand()->insert('customers',['customers_firstname'=>mb_substr($identity['username']??'Player',0,32),'customers_lastname'=>'','customers_email_address'=>$email,'customers_password'=>password_hash(bin2hex(random_bytes(32)),PASSWORD_BCRYPT),'customers_status'=>1,'platform_id'=>\common\classes\platform::currentId()])->execute(); @@ -43,13 +49,18 @@ final class DuneAccount { $db->createCommand()->insert('dune_account_links',['account_id'=>$identity['id'],'customer_id'=>$id])->execute(); $db->createCommand()->insert('customers_info',['customers_info_id'=>$id,'customers_info_date_account_created'=>gmdate('Y-m-d H:i:s')])->execute(); } - $db->createCommand()->update('customers',['customers_firstname'=>mb_substr($identity['username']??'Player',0,32)],['customers_id'=>$id])->execute(); + $db->createCommand()->update('customers',['customers_firstname'=>mb_substr($identity['username']??'Player',0,32),'customers_email_address'=>$email],['customers_id'=>$id])->execute(); $transaction->commit();return (int)$id; }catch(\Throwable $e){$transaction->rollBack();throw $e;} } private static function handle($app):void { $app->response->headers->set('Referrer-Policy','no-referrer'); $path=parse_url($_SERVER['REQUEST_URI']??'/',PHP_URL_PATH); + if(empty($_GET['action'])&&preg_match('#^/catalog/(?:[A-Z]{3}/)?$#',$path)){ + $currency=$_GET['currency']??'EUR'; + if(!is_string($currency)||!in_array($currency,['EUR','GBP','USD'],true))$currency='EUR'; + self::redirect($app,'/catalog/dune-shop?currency='.$currency); + } if($path==='/dune-login.php'){ if(!isset($_GET['code']))self::start($app); $state=$_GET['state']??'';$nonce=$_COOKIE['__Host-dune_osc_state']??''; @@ -68,7 +79,7 @@ final class DuneAccount { if(is_string($token)&&preg_match('/^[A-Za-z0-9_-]{43}$/',$token)){ $row=$app->db->createCommand('SELECT account_id,session_ref FROM dune_sso_sessions WHERE token_hash=:token AND expires_at>:now',[':token'=>hash('sha256',$token),':now'=>time()])->queryOne(); if($row){ - try{$identity=self::api('identity',['sessionRef'=>$row['session_ref']]);}catch(\yii\web\HttpException $e){if($e->statusCode!==401)throw $e;} + try{$identity=self::api('identity',['sessionRef'=>$row['session_ref'],'client'=>'oscommerce']);}catch(\yii\web\HttpException $e){if($e->statusCode!==401)throw $e;} if(($identity['id']??null)!==$row['account_id'])$identity=null; } } @@ -78,11 +89,11 @@ final class DuneAccount { if(!$app->user->isGuest){$app->user->logout(false);global $cart;if(is_object($cart)&&is_callable([$cart,'reset']))$cart->reset();} $app->session->regenerateID(true); $customer=new \common\components\Customer(\common\components\Customer::LOGIN_WITHOUT_CHECK); - if(!$customer->loginCustomer($identity['id'].'@accounts.dunerealms.invalid',$id))throw new \yii\web\ForbiddenHttpException('Account link failed'); + if(!$customer->loginCustomer(self::email($identity),$id))throw new \yii\web\ForbiddenHttpException('Account link failed'); } }elseif(!$app->user->isGuest){$app->user->logout(false);self::cookie('__Host-dune_oscommerce','',time()-3600);} - if(preg_match('#^/catalog/account/(login|create|password|password-forgotten)#',$path))self::start($app); - if(preg_match('#^/catalog/account/?$#',$path))self::redirect($app,'https://cp.dunerealms.com/'); - if(preg_match('#^/catalog/checkout#',$path)&&!$identity)self::start($app,$path); + if(preg_match('#^/catalog/(?:[A-Z]{3}/)?account/(login|create|password|password-forgotten)#',$path))self::start($app); + if(preg_match('#^/catalog/(?:[A-Z]{3}/)?account/?$#',$path))self::redirect($app,'https://cp.dunerealms.com/'); + if(preg_match('#^/catalog/(?:[A-Z]{3}/)?checkout#',$path)&&!$identity)self::start($app,$path); } } diff --git a/website/ops/oscommerce/DuneProductRules.php b/website/ops/oscommerce/DuneProductRules.php new file mode 100644 index 00000000..e7270fbf --- /dev/null +++ b/website/ops/oscommerce/DuneProductRules.php @@ -0,0 +1,35 @@ +80 || preg_match('/[\x00-\x1F\x7F<>]/u',$value)) { + throw new \InvalidArgumentException('Enter a preferred name of 1–80 characters, without markup or control characters.'); + } + return $value; + } + public static function validateCartRequest(): void { + if ((\Yii::$app->controller->action->id??'')==='error') return; + $action=$_GET['action']??''; + if (!in_array($action,['add_product','add_all','add_quote','add_quote_all','add_sample','buy_now'],true)) return; + $rows=\Yii::$app->db->createCommand('SELECT products_id,option_id,preview_only FROM dune_product_requirements')->queryAll(); + foreach($rows as $row) { + $id=(int)$row['products_id']; + $single=(int)($_POST['products_id']??$_GET['products_id']??0)===$id; + $listed=isset($_POST['listqty'][$id]) || isset($_POST['listid'][$id]); + if (!$single && !$listed) continue; + $value=$single?($_POST['attr_text'][$row['option_id']]??null):($_POST['listattr_text'][$id][$row['option_id']]??null); + try { self::preferredName($value); } + catch(\InvalidArgumentException $e) { self::reject(422,$e->getMessage()); } + if($row['preview_only']) self::reject(409,'Collection preview: ordering is currently unavailable.'); + } + } + private static function reject(int $status,string $message): never { + $response=\Yii::$app->response; + $response->statusCode=$status; + $response->format=\yii\web\Response::FORMAT_JSON; + $response->data=['error'=>$message]; + $response->send();\Yii::$app->end();exit; + } +} diff --git a/website/ops/oscommerce/DuneShopController.php b/website/ops/oscommerce/DuneShopController.php new file mode 100644 index 00000000..9899c358 --- /dev/null +++ b/website/ops/oscommerce/DuneShopController.php @@ -0,0 +1,40 @@ +view->title='DuneRealms Shop'; + $rows=Yii::$app->db->createCommand("SELECT p.products_id,p.products_price,p.products_tax_class_id,pd.products_name,pd.products_description_short,d.kind FROM products p JOIN platforms_products pp ON pp.products_id=p.products_id AND pp.platform_id=7 JOIN products_description pd ON pd.products_id=p.products_id AND pd.language_id=1 AND pd.platform_id=7 LEFT JOIN dune_catalog_import d ON d.products_id=p.products_id WHERE p.products_status=1 ORDER BY p.products_date_added DESC,p.products_id DESC")->queryAll(); + $saleIds=Yii::$app->db->createCommand("SELECT DISTINCT products_id FROM specials WHERE status=1 AND (start_date IS NULL OR start_date='0000-00-00 00:00:00' OR start_date<=NOW()) AND (expires_date IS NULL OR expires_date='0000-00-00 00:00:00' OR expires_date>NOW())")->queryColumn(); + $featuredIds=Yii::$app->db->createCommand("SELECT DISTINCT products_id FROM featured WHERE status=1 AND (start_date IS NULL OR start_date='0000-00-00 00:00:00' OR start_date<=NOW()) AND (expires_date IS NULL OR expires_date='0000-00-00 00:00:00' OR expires_date>NOW())")->queryColumn(); + $sashes=count(array_filter($rows,fn($r)=>$r['kind']==='sash'));$ranks=count(array_filter($rows,fn($r)=>$r['kind']==='rank')); + $base=fn($route)=>Html::encode(\yii\helpers\Url::to([$route])); + $out='
THE DUNEREALMS EMPORIUM

Carry a piece of the realms.

Ceremonial sashes, personal keepsakes and ways to support the community.

Browse the collection
'; + $tiles=[['Ceremonial sashes',$sashes.' designs · made to order','catalog/all-products','nav-clan-v2.webp','sash'],['Donor ranks',$ranks.' ways to support the realms','catalog/all-products','nav-account-v2.webp','rank'],['Sale',count($saleIds)?'Explore current offers':'No sales active right now','catalog/sales','nav-exchange-v2.webp','']]; + $out.=''; + foreach([['New arrivals','Recently added to the collection',array_slice($rows,0,6),'catalog/products-new'],['Featured','Selected pieces from the realms',array_values(array_filter($rows,fn($r)=>in_array($r['products_id'],$featuredIds))),'catalog/featured-products'],['Sale','Current offers from the emporium',array_values(array_filter($rows,fn($r)=>in_array($r['products_id'],$saleIds))),'catalog/sales']] as [$title,$sub,$items,$route]){ + $out.='

'.$title.'

'.$sub.'

View all ↗
'; + if(!$items)$out.='
'.($title==='Sale'?'There are no active sale offers.':'Featured products have not been selected yet.').'
'; + else{ + $out.='
'; + foreach(array_slice($items,0,6) as $p){ + $url=Html::encode(\yii\helpers\Url::to(['catalog/product','products_id'=>$p['products_id']])); + $image=Html::encode(\common\classes\Images::getImageUrl($p['products_id'],'Small',1)); + $price=Yii::$container->get('currencies')->display_price(\common\helpers\Product::get_products_price($p['products_id'],1,$p['products_price']),\common\helpers\Tax::get_tax_rate($p['products_tax_class_id'])); + $out.=''; + } + $out.='
'; + } + $out.='
'; + } + $out.=''; + return $this->renderContent($out); + } +} diff --git a/website/ops/oscommerce/dune-shop-cards.css b/website/ops/oscommerce/dune-shop-cards.css new file mode 100644 index 00000000..fc80cc0d --- /dev/null +++ b/website/ops/oscommerce/dune-shop-cards.css @@ -0,0 +1,30 @@ +/* DuneRealms dev alpha storefront: readable framed cards and specification rows. */ +html,body{height:auto!important;min-height:0!important}.main-content{min-height:280px!important} +.w-logo,.warrantyProduct,.tripleBanner,#box-110187{display:none!important} +.main-content .title,.main-content .heading,.main-content .categories-title,.main-content strong{color:#e8d39b!important} +.w-product-model,.w-product-description-short,.w-product-description,.w-product-properties,.productNavigation{background:linear-gradient(135deg,#1b3d30,#102a21)!important;border:1px solid #8e7b48!important;border-radius:13px!important;box-shadow:0 7px 22px #0002!important;padding:20px!important;margin-bottom:16px!important;box-sizing:border-box!important} +.productNavigation{border-top:3px solid #c5a65a!important}.productNavigation .block{background:transparent!important} +.w-product-description-short{line-height:1.7!important}.w-product-model{font-size:13px!important;letter-spacing:.025em;color:#c4cfbc!important} +.w-product-attributes .select-box{display:block!important;padding:0 0 18px!important;margin:0 0 18px!important;border-bottom:1px solid #526341!important}.w-product-attributes .attr-title{display:block!important;font-size:14px!important;font-weight:600!important;color:#e7d7b0!important;margin-bottom:10px!important;line-height:1.5!important} +.w-product-attributes input[type=text],.w-product-attributes select:not([style*="display:none"]){width:100%!important;min-height:46px!important;padding:12px 14px!important;box-sizing:border-box!important;background:#091f18!important;border:1px solid #9f8c55!important;border-radius:8px!important;color:#fff0cb!important;font-size:15px!important}.w-product-attributes input::placeholder{color:#a3b6a5!important}.w-product-attributes input:focus{outline:2px solid #d8b65e!important;outline-offset:3px} +.w-product-price,.w-product-price *,.product-price-current,.price-current,#product-price-current,#product-price-current *{color:#f1d58a!important;opacity:1!important}.w-product-price{font-size:30px!important;font-weight:700!important;margin:12px 0!important}.w-product-stock{color:#e4c890!important}.w-product-quantity input{color:#f4ead2!important} +.w-product-properties{max-width:none!important;padding:0!important;overflow:hidden!important}.product-properties{width:100%!important;max-width:none!important;font-size:14px!important;line-height:1.65!important} +.product-properties .properties-table,.product-properties .property-ul{display:grid!important;grid-template-columns:minmax(140px,28%) minmax(0,1fr)!important;gap:0!important;width:100%!important;margin:0!important;padding:0!important;list-style:none!important;border-bottom:1px solid #3b5745!important;background:#143227!important;box-sizing:border-box!important} +.product-properties .property-ul:nth-child(even),.product-properties .properties-table:nth-child(even){background:#193a2c!important}.product-properties li{float:none!important;display:block!important;width:auto!important;max-width:none!important;padding:13px 18px!important;margin:0!important;box-sizing:border-box!important;text-align:left!important}.product-properties li:first-child{background:#0d251d80!important;border-right:1px solid #3b5745!important}.product-properties a,.product-properties span{color:#dce6d3!important;text-decoration:none!important}.product-properties strong,.product-properties strong span{color:#ddc586!important;font-weight:600!important} +.w-product-images{padding:18px!important;background:radial-gradient(ellipse,#274b35,#10271e 75%)!important;border:1px solid #746943!important;border-radius:14px!important;box-sizing:border-box!important}.w-product-images .img-holder,.w-product-images .produst-image{height:380px!important;max-height:380px!important;padding-top:0!important;overflow:hidden!important}.w-product-images img{height:360px!important;max-height:360px!important;width:auto!important;max-width:100%!important;object-fit:contain!important;cursor:zoom-in}.w-product-images .additional-images img{height:64px!important;max-height:64px!important}.w-product-images a[data-fancybox-group]{display:flex!important;justify-content:center;align-items:center;height:100%!important} +.w-product-images:after{content:'Click image to view full size';display:block;text-align:center;font-size:11px;color:#b9c9ad;padding-top:12px;letter-spacing:.035em}.main-content .btn,.main-content button{min-height:38px!important;font-size:13px!important} +@media(max-width:680px){.product-properties .properties-table,.product-properties .property-ul{grid-template-columns:1fr!important}.product-properties li:first-child{border-right:0!important;padding-bottom:4px!important}.product-properties li+li{padding-top:4px!important}.w-product-images .img-holder,.w-product-images .produst-image{height:300px!important}.w-product-images img{height:280px!important;max-height:280px!important}} +/* Balanced product columns with independent, consistently spaced cards. */ +#box-110822{display:grid!important;grid-template-columns:minmax(250px,30%) minmax(0,1fr)!important;gap:24px!important;max-width:1200px!important;margin:24px auto!important;padding:0!important;align-items:start!important}#box-110822>.block,#box-110830>.block{float:none!important;width:auto!important;min-width:0!important;padding:0!important;margin:0!important}#box-110830{display:grid!important;grid-template-columns:minmax(190px,1fr) minmax(270px,1.25fr)!important;gap:24px!important;padding:0!important;align-items:start!important}#box-110838,#box-110841{padding:0!important}#box-110839{width:100%!important;margin:0!important;padding:22px!important}.w-product-model,.w-product-description-short{text-align:center!important;margin:0 0 18px!important}.w-product-images{margin:0!important}.w-product-name{text-align:center!important}#product-attributes{display:flex!important;flex-direction:column!important;gap:18px!important}.w-product-attributes .select-box{float:none!important;clear:both!important;width:100%!important;min-width:0!important;margin:0!important;padding:0 0 18px!important;box-sizing:border-box!important}.w-product-attributes .textinput,.w-product-attributes .js-attr-text-input{display:block!important;width:100%!important;max-width:none!important}.w-product-attributes select{width:100%!important;max-width:none!important}.w-product-price,.w-product-stock,.w-product-quantity,.w-product-buttons{text-align:center!important}.main-content:has(input[name="products_id"][value="76"]) .w-product-quantity{display:none!important}.main-content:has(input[name="products_id"][value="76"]) .productNavigation:after{content:'Collection preview · ordering is not open';display:block;margin-top:18px;padding:12px;border:1px solid #6f7149;border-radius:8px;background:#253f2d;color:#e4d6ad;font-size:12px;line-height:1.5;text-align:center} +@media(max-width:1050px){#box-110822{grid-template-columns:minmax(220px,35%) minmax(0,1fr)!important;gap:20px!important}#box-110830{grid-template-columns:1fr!important;gap:0!important}}@media(max-width:650px){#box-110822{grid-template-columns:1fr!important;gap:20px!important}.w-product-images{max-width:340px!important;width:100%!important;margin:auto!important}#box-110839{padding:18px!important}} +/* Dev alpha table rhythm: alternating rows and a restrained hover highlight. */ +.main-content table{border:1px solid #756b45!important;border-collapse:separate!important;border-spacing:0!important;border-radius:11px!important;overflow:hidden!important;width:100%!important}.main-content table th{background:#244b36!important;color:#e8cd87!important;font-size:12px!important;letter-spacing:.035em!important;padding:13px 16px!important;text-align:left!important}.main-content table tbody tr:nth-child(odd){background:#102b21!important}.main-content table tbody tr:nth-child(even){background:#1b3a2c!important}.main-content table td{color:#e0e7d6!important;padding:13px 16px!important;border-bottom:1px solid #355340!important}.main-content table tbody tr:hover{background:#294a34!important}.product-properties .property-ul:nth-child(odd),.product-properties>.properties-table:nth-child(odd){background:#102b21!important}.product-properties .property-ul:nth-child(even),.product-properties>.properties-table:nth-child(even){background:#1b3a2c!important}.product-properties .property-ul:hover,.product-properties .properties-table:hover{background:#294a34!important;transition:background .15s} +/* Product tabs use the same dev-alpha card treatment, including every state. */ +.w-tabs>.tab-navigation{display:flex!important;gap:12px!important;padding:0 0 16px!important;background:transparent!important;border:0!important}.w-tabs>.tab-navigation>.tab-li{flex:1!important;float:none!important;margin:0!important;border:0!important;background:transparent!important}.w-tabs .tab-navigation .tab-a,.w-tabs .accordion-heading{display:block!important;padding:16px 20px!important;border:1px solid #756c45!important;border-radius:10px!important;background:linear-gradient(135deg,#1c3e2e,#10291f)!important;color:#d8c391!important;font-size:15px!important;font-weight:600!important;line-height:1.4!important;text-align:center!important;box-shadow:0 4px 14px #0002!important}.w-tabs .tab-navigation .active .tab-a,.w-tabs .tab-navigation .tab-li.active .tab-a,.w-tabs .tab-navigation .tab-a.active,.w-tabs .accordion-heading.active{background:linear-gradient(135deg,#315238,#1a3828)!important;border-color:#cfaf59!important;color:#fff0c4!important;box-shadow:inset 0 2px #d6b35c,0 4px 14px #0002!important}.w-tabs .tab-navigation .tab-a:hover{background:#294b34!important;color:#fff0c4!important}.w-tabs>.block{background:transparent!important;border:0!important;padding:0!important}.w-tabs .tab-navigation .tab-a:focus-visible{outline:2px solid #e2c06c!important;outline-offset:3px}@media(max-width:500px){.w-tabs>.tab-navigation{gap:8px!important}.w-tabs .tab-navigation .tab-a{padding:12px 8px!important;font-size:13px!important}} +/* Catalogue cards keep tall artwork at thumbnail scale. */ +.products-listing{display:grid!important;grid-template-columns:repeat(auto-fill,minmax(235px,1fr))!important;gap:22px!important;align-items:start!important}.products-listing>.item{float:none!important;clear:none!important;width:auto!important;max-width:340px!important;margin:0 auto!important;padding:0!important;box-sizing:border-box!important;border:1px solid #7a7047!important;border-radius:13px!important;overflow:hidden!important;background:linear-gradient(140deg,#1e402f,#10281f)!important;box-shadow:0 8px 22px #0002!important}.products-listing .item-holder,.products-listing .item-wrapper,.products-listing .item-content{background:transparent!important}.products-listing .item-content{padding:18px!important;text-align:center!important}.products-listing .image{height:270px!important;display:flex!important;align-items:center!important;justify-content:center!important;margin:0 0 16px!important;background:radial-gradient(ellipse,#294b35,transparent 75%)!important}.products-listing .image a,.products-listing .image picture{display:flex!important;align-items:center!important;justify-content:center!important;height:100%!important;width:100%!important}.products-listing .image img{height:250px!important;max-height:250px!important;max-width:100%!important;width:auto!important;object-fit:contain!important}.products-listing .price,.products-listing .price *{color:#f1d58a!important;font-size:24px!important;font-weight:700!important;opacity:1!important}.products-listing .name h2{font-size:18px!important;line-height:1.4!important;margin:12px 0!important}.products-listing .description{color:#bdcfbb!important;font-size:13px!important;line-height:1.6!important}.products-listing .item-nav{display:flex!important;align-items:center!important;justify-content:center!important;gap:14px!important;background:#10291f!important;padding:14px!important;border-top:1px solid #465d41!important}.products-listing .compare{font-size:11px!important;color:#bac9ae!important}.products-listing .out-stock{color:#c9b779!important;font-size:12px!important}.w-catalog-title h1{font-size:28px!important}.leftCategories,.leftCategories a,.w-catalog-counts-items{color:#d9d6ba!important} +.header-middle .w-image{display:none!important}.header-middle{background:linear-gradient(110deg,#102d22ec,#153629de),url('https://www.dunerealms.com/assets/sietch.webp') center 45%/cover!important;padding:22px!important;border:1px solid #7a7047!important;border-radius:12px!important}.header-middle>.block{gap:22px!important}.header-middle .w-search{flex:1!important;min-width:180px!important}.header-middle .search-input{background:#0a2019!important;border:1px solid #8f8050!important;border-radius:8px!important;color:#eee4c9!important;min-height:44px!important}.w-cart .cart-icon,.w-account .account-icon{background:#294a32!important;color:#e0c47a!important}.header-menu-holder a{font-size:13px!important;letter-spacing:.04em!important;color:#e1cc94!important}.header-menu-holder a:hover{background:#294a32!important}.footer-bottom{background:#10271e!important;color:#9db39e!important}.w-catalog-view .active{background:#34563b!important;color:#f0d692!important}.w-catalog-view a{color:#dac381!important}.w-search input{color:#f3e8cc!important}.w-languages,.w-currencies{color:#dfd5b9!important} +/* Commercial storefront home, using real catalogue data. */ +.dune-store-welcome{display:flex;align-items:center;justify-content:space-between;gap:28px;border:1px solid #9a8349;border-radius:16px;padding:40px;margin:0 auto 24px;background:linear-gradient(100deg,#0b261aec,#173c2cc7),url('https://www.dunerealms.com/assets/sietch.webp') center/cover;box-shadow:0 12px 30px #0003}.dune-store-welcome small{color:#ceb36e;letter-spacing:.16em;font-size:11px}.dune-store-welcome h1{font-size:clamp(28px,3vw,43px);line-height:1.15;margin:14px 0!important;max-width:600px}.dune-store-welcome p{font-size:15px;line-height:1.7;color:#ccd9c4;max-width:570px;margin-bottom:24px}.dune-store-welcome>img{width:155px;height:155px;object-fit:contain;filter:drop-shadow(0 8px 18px #0008)}.dune-store-button{display:inline-flex!important;align-items:center;justify-content:center;padding:11px 18px;border:1px solid #b79a53;border-radius:8px;background:linear-gradient(#385b39,#23422c);color:#f5e1ad!important;font-size:13px;font-weight:600;text-decoration:none!important;box-shadow:0 4px 12px #0003}.dune-store-button:hover{background:#416345;transform:translateY(-1px)} +.dune-store-categories{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;margin-bottom:34px}.dune-store-categories>a{display:flex;align-items:center;gap:16px;padding:22px;border:1px solid #6e7046;border-radius:12px;background:linear-gradient(130deg,#21412e,#112b20);text-decoration:none!important;transition:border-color .15s,transform .15s}.dune-store-categories>a:hover{border-color:#d4b369;transform:translateY(-2px)}.dune-store-categories img{width:58px;height:58px;object-fit:contain}.dune-store-categories h2{font-size:17px!important;margin:0 0 6px!important}.dune-store-categories p{margin:0;color:#afc2aa;font-size:12px;line-height:1.5}.dune-store-categories span{margin-left:auto;color:#dfc37f;font-size:20px}.dune-store-section{margin:0 0 32px;border:1px solid #486143;border-radius:13px;padding:24px;background:#102a20}.dune-store-section>header{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-bottom:22px;padding-bottom:16px;border-bottom:1px solid #425b40}.dune-store-section h2{font-size:23px!important;margin:0 0 7px!important}.dune-store-section header p{margin:0;color:#aabea5;font-size:12px}.dune-store-section header>a{font-size:12px;color:#d9be7b!important;white-space:nowrap}.dune-store-products{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px}.dune-store-products article{display:flex;flex-direction:column;align-items:center;text-align:center;border:1px solid #536a47;border-radius:11px;background:linear-gradient(145deg,#1b3b29,#0c251b);padding:18px;box-sizing:border-box}.dune-store-product-art{display:flex;align-items:center;justify-content:center;width:100%;height:230px;margin-bottom:16px;background:radial-gradient(ellipse,#2f5033,transparent 72%)}.dune-store-product-art img{display:block!important;height:220px!important;max-height:220px!important;max-width:100%!important;width:auto!important;object-fit:contain}.dune-store-products small{font-size:9px;letter-spacing:.12em;color:#b8a66e}.dune-store-products h3{font-size:16px!important;line-height:1.45;margin:10px 0!important}.dune-store-products h3 a{color:#e6d5a3!important;text-decoration:none}.dune-store-price{font-size:23px;font-weight:700;color:#f1d28a;margin:auto 0 16px;padding-top:8px}.dune-store-products .dune-store-button{width:100%;box-sizing:border-box}.dune-store-empty{border:1px dashed #566849;border-radius:9px;padding:26px;color:#afc1a5;text-align:center;font-size:13px;background:#183223}.dune-store-preview{border-left:3px solid #b99850;border-radius:9px;background:#243c28;padding:20px 24px;color:#cad5ba;font-size:13px;line-height:1.7}.dune-store-preview strong{color:#e1c785}.dune-store-preview p{margin:6px 0 0} +@media(min-width:1500px){.dune-store-products{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(max-width:900px){.dune-store-categories{grid-template-columns:1fr}.dune-store-products{grid-template-columns:repeat(2,minmax(0,1fr))}.dune-store-welcome{padding:28px}.dune-store-welcome>img{width:110px;height:110px}}@media(max-width:550px){.dune-store-welcome{padding:24px;gap:12px}.dune-store-welcome>img{display:none}.dune-store-products{grid-template-columns:1fr}.dune-store-section{padding:18px}.dune-store-section>header{align-items:flex-start}.dune-store-product-art{height:210px}.dune-store-product-art img{height:200px!important}.header-middle>.block{flex-wrap:wrap!important;justify-content:center!important}.header-middle .w-search{flex-basis:100%!important}} diff --git a/website/ops/oscommerce/finish-catalog-edging.py b/website/ops/oscommerce/finish-catalog-edging.py new file mode 100644 index 00000000..611a7e47 --- /dev/null +++ b/website/ops/oscommerce/finish-catalog-edging.py @@ -0,0 +1,12 @@ +import subprocess +def q(s):return subprocess.check_output(['mysql','-N','dunerealms_oscommerce','-e',s],text=True).strip() +def run(s):subprocess.run(['mysql','dunerealms_oscommerce'],input=s,text=True,check=True,capture_output=True) +oid=int(q("SELECT products_options_id FROM products_options WHERE products_options_name IN ('Ribbon finish','Side edging') LIMIT 1")) +gold=q("SELECT products_options_values_id FROM products_options_values WHERE products_options_values_name='Gold side edging' LIMIT 1") +if not gold: + gold=int(q('SELECT MAX(products_options_values_id)+1 FROM products_options_values')) + run(f"INSERT INTO products_options_values(products_options_values_id,language_id,products_options_values_name,custom_input_type) VALUES({gold},1,'Gold side edging',0);INSERT INTO products_options_values_to_products_options(products_options_id,products_options_values_id) VALUES({oid},{gold});") +run(f"UPDATE products_options SET products_options_name='Side edging' WHERE products_options_id={oid};UPDATE products_options_values SET products_options_values_name='Standard side edging (included)' WHERE products_options_values_name='Standard finish (included)';UPDATE products_options_values SET products_options_values_name='Silver side edging' WHERE products_options_values_name='Silver edges';INSERT INTO products_attributes(products_id,options_id,options_values_id,options_values_price) SELECT d.products_id,{oid},{gold},62.5 FROM dune_catalog_import d WHERE d.kind='sash' AND NOT EXISTS(SELECT 1 FROM products_attributes a WHERE a.products_id=d.products_id AND a.options_values_id={gold} AND a.options_id={oid});") +run("INSERT IGNORE INTO products_attributes_prices(products_attributes_id,groups_id,currencies_id,attributes_group_price) SELECT a.products_attributes_id,g.g,c.c,a.options_values_price FROM products_attributes a JOIN dune_catalog_import d ON d.products_id=a.products_id CROSS JOIN (SELECT 0 g UNION SELECT groups_id FROM `groups`) g CROSS JOIN (SELECT 0 c UNION SELECT currencies_id FROM currencies) c;") +run("UPDATE properties_values v JOIN properties_to_products p ON p.values_id=v.values_id AND p.properties_id=v.properties_id JOIN properties_description d ON d.properties_id=v.properties_id AND d.language_id=v.language_id JOIN dune_catalog_import i ON i.products_id=p.products_id AND i.kind='sash' SET v.values_text='Made to order. Collection preview: ordering is not open.' WHERE d.properties_name='Availability';UPDATE properties_values v JOIN properties_to_products p ON p.values_id=v.values_id AND p.properties_id=v.properties_id JOIN properties_description d ON d.properties_id=v.properties_id AND d.language_id=v.language_id SET v.values_text='Standard side edging included; silver sides +€50, gold sides +€75. Bottom fringe unchanged.' WHERE p.products_id=76 AND d.properties_name IN ('Trim','Finish');") +print('All 12 sashes: required preferred name; standard/silver +50/gold +75 side edging. Bottom fringe retained.') diff --git a/website/ops/oscommerce/import-shop-catalog.py b/website/ops/oscommerce/import-shop-catalog.py new file mode 100644 index 00000000..a30f52f7 --- /dev/null +++ b/website/ops/oscommerce/import-shop-catalog.py @@ -0,0 +1,70 @@ +from pathlib import Path +import subprocess,json,re,html,shutil,decimal +def q(s,db='dunerealms_oscommerce'): + return subprocess.check_output(['mysql','-N','--raw',db,'-e',"SET SESSION sql_mode='';"+s],text=True).strip() +def h(s):return "CONVERT(0x"+str(s).encode().hex()+" USING utf8mb4)" if str(s) else "''" +def run(s):subprocess.run(['mysql','dunerealms_oscommerce'],input="SET SESSION sql_mode='';"+s,text=True,check=True,capture_output=True) +rows=json.loads(q("SELECT JSON_ARRAYAGG(JSON_OBJECT('id',p.id,'name',p.name,'price',p.price,'description',p.description,'short',p.short_description,'image',p.image,'rank',p.dune_website_rank)) FROM shop_packages p WHERE p.name LIKE '%Sash%' OR p.id IN (SELECT package_id FROM dune_supporter_packages)",'dunerealms_store')) +run('CREATE TABLE IF NOT EXISTS dune_catalog_import(source_package_id INT PRIMARY KEY,products_id INT NOT NULL UNIQUE,kind VARCHAR(16) NOT NULL,source_rank VARCHAR(64) NOT NULL DEFAULT \'\');') +def category(name,slug): + old=q('SELECT c.categories_id FROM categories c JOIN categories_description d ON d.categories_id=c.categories_id WHERE d.language_id=1 AND d.categories_name='+h(name)+' LIMIT 1') + if old:return int(old) + return int(q('INSERT INTO categories(parent_id,categories_status,categories_seo_page_name,date_added,created_by_platform_id) VALUES(0,1,'+h(slug)+',NOW(),7);SET @c=LAST_INSERT_ID();INSERT INTO categories_description(categories_id,language_id,categories_name,categories_heading_title,categories_seo_page_name) VALUES(@c,1,'+h(name)+','+h(name)+','+h(slug)+');INSERT INTO platforms_categories VALUES(7,@c);SELECT @c;')) +cats={'sash':category('Ceremonial Sashes','ceremonial-sashes'),'rank':category('Donor Ranks','donor-ranks')} +mid=q("SELECT manufacturers_id FROM manufacturers WHERE manufacturers_name='DuneRealms' LIMIT 1") +if not mid:mid=q("INSERT INTO manufacturers(manufacturers_name,date_added) VALUES('DuneRealms',NOW());SELECT LAST_INSERT_ID();") +cols=[x.split('\t')[0] for x in q('DESCRIBE products').splitlines() if not x.startswith('products_id\t')] +colsql=','.join('`'+x+'`' for x in cols) +def prop(pid,name,value,sort): + x=q('SELECT properties_id FROM properties_description WHERE language_id=1 AND properties_name='+h(name)+' LIMIT 1') + if not x:x=q("INSERT INTO properties(properties_type,display_product,sort_order,date_added) VALUES('text',1,"+str(sort)+",NOW());SET @p=LAST_INSERT_ID();INSERT INTO properties_description(properties_id,language_id,properties_name) VALUES(@p,1,"+h(name)+");SELECT @p;") + x=int(x) + if q(f'SELECT values_id FROM properties_to_products WHERE products_id={pid} AND properties_id={x} LIMIT 1'):return + v=int(q('SELECT COALESCE(MAX(values_id),0)+1 FROM properties_values')) + run(f'INSERT INTO properties_values(values_id,properties_id,language_id,values_text) VALUES({v},{x},1,{h(value)});INSERT INTO properties_to_products(products_id,properties_id,values_id) VALUES({pid},{x},{v});') +for row in rows: + kind='sash' if 'sash' in row['name'].lower() else 'rank' + existing=q('SELECT products_id FROM dune_catalog_import WHERE source_package_id='+str(row['id'])) + if existing:continue + slug=re.sub('[^a-z0-9]+','-',row['name'].lower()).strip('-') + if row['id']==64:pid=76 + else: + pid=int(q(f'INSERT INTO products({colsql}) SELECT {colsql} FROM products WHERE products_id=76;SELECT LAST_INSERT_ID();')) + # Each imported record is independently editable through the native backend. + dcols=[x.split('\t')[0] for x in q('DESCRIBE products_description').splitlines() if not x.startswith('products_id\t')] + dc=','.join('`'+x+'`' for x in dcols) + run(f'INSERT INTO products_description(products_id,{dc}) SELECT {pid},{dc} FROM products_description WHERE products_id=76;INSERT INTO platforms_products VALUES(7,{pid});') + note='

Collection preview: ordering is not open yet.

' + if kind=='sash': + intro=re.search(r'

(.*?)

',row['description'],re.S) + intro=html.unescape(re.sub('<[^>]+>','',intro[1])) if intro else row['short'] + details={html.unescape(re.sub('<[^>]+>','',a)):html.unescape(re.sub('<[^>]+>','',b)) for a,b in re.findall(r'
(.*?)
\s*
(.*?)
',row['description'],re.S)} + desc='

'+html.escape(intro)+'

'+note+'

Made to order. Enter the preferred name to embroider. Standard side edging is included, without metallic side lining. Silver side edging adds €50; gold side edging adds €75. These upgrades do not change the bottom fringe.

This physical sash does not grant a rank or honour.

' + values={'Eligibility':details.get('Eligibility',''),'Embroidery':details.get('Embroidery',''),'Ribbon size':details.get('Ribbon','').split(' · ')[0],'Cord and bottom fringe':details.get('Ribbon','').split(' · ')[-1],'Side edging':'Standard included · Silver +€50 · Gold +€75. Bottom fringe unchanged.','Maker':details.get('Maker','Julla Studentenlinten'),'Shipping':'€20 once per order when ordering opens.','Availability':'Made to order · collection preview.','Honour':'The physical sash does not grant a rank or honour.'} + for i,(name,value) in enumerate(values.items()): + if value:prop(pid,name,value,i) + if pid!=76: + ac=[x.split('\t')[0] for x in q('DESCRIBE products_attributes').splitlines() if not x.startswith(('products_attributes_id\t','products_id\t'))] + aa=','.join(ac) + run(f'INSERT INTO products_attributes(products_id,{aa}) SELECT {pid},{aa} FROM products_attributes WHERE products_id=76;INSERT INTO dune_product_requirements SELECT {pid},option_id,1 FROM dune_product_requirements WHERE products_id=76;') + else: + desc=row['description']+note+'

Rank purchases will become available after payment and automatic delivery integration is ready.

' + for i,(name,value) in enumerate({'Delivery':'Digital · linked DuneRealms account','Availability':'Preview · purchasing is not open yet','Manufacturer':'DuneRealms'}.items()):prop(pid,name,value,i) + price=decimal.Decimal(str(row['price']))/decimal.Decimal('1.2') + # Preserve the existing store tax configuration while retaining the source's displayed EUR price. + run(f"UPDATE products SET products_model={h('DR-'+kind.upper()+'-'+str(row['id']))},products_price={price:.6f},products_seo_page_name={h(slug)},cart_button=0,products_quantity=0,manual_stock_unlimited={1 if kind=='sash' else 0},is_virtual={1 if kind=='rank' else 0},manufacturers_id={int(mid) if kind=='rank' else '(SELECT manufacturers_id FROM (SELECT manufacturers_id FROM products WHERE products_id=76) base)'},products_status=1,products_image={h(row['image'] or '')},products_last_modified=NOW() WHERE products_id={pid};UPDATE products_description SET products_name={h(row['name'])},products_description={h(desc)},products_description_short={h((intro if kind=='sash' else row['short'])[:240])},products_seo_page_name={h(slug)},products_head_title_tag={h(row['name'][:60]+' | DuneRealms')} WHERE products_id={pid};INSERT IGNORE INTO products_to_categories VALUES({pid},{cats[kind]},0);INSERT INTO dune_catalog_import VALUES({row['id']},{pid},{h(kind)},{h(row['rank'] or '')});") + if pid!=76: + run(f'INSERT INTO products_prices(products_id,groups_id,products_group_price,currencies_id) VALUES({pid},0,{price:.6f},0);') + # Keep the user-edited Aerdrecht artwork; register the originals for new imports. + if pid!=76 and row['image']: + sources=[Path('/home/dunerealms/apps/azuriom/public/assets/img/merch')/row['image'],Path('/home/dunerealms/apps/azuriom/storage/app/public/packages')/row['image']] + src=next((x for x in sources if x.exists()),None) + if src: + iid=int(q(f'INSERT INTO products_images(products_id,default_image,image_status) VALUES({pid},1,1);SELECT LAST_INSERT_ID();')) + run(f'INSERT INTO products_images_description(products_images_id,language_id,image_title,image_alt,orig_file_name,hash_file_name,file_name,no_watermark) VALUES({iid},1,{h(row["name"])},{h(row["name"])},{h(src.name)},{h(src.name)},{h(src.name)},1);') + for dims in q("SELECT CONCAT(image_types_x,'x',image_types_y) FROM image_types").splitlines()+['originals']: + folder=Path('/home/dunerealms/apps/oscommerce/images/products')/str(pid)/str(iid)/dims/'en';folder.mkdir(parents=True,exist_ok=True);shutil.copyfile(src,folder/src.name) + print('Imported',row['id'],pid,kind,row['name']) +run("INSERT IGNORE INTO products_attributes_prices(products_attributes_id,groups_id,currencies_id,attributes_group_price) SELECT a.products_attributes_id,g.g,c.c,a.options_values_price FROM products_attributes a JOIN dune_catalog_import d ON d.products_id=a.products_id CROSS JOIN (SELECT 0 g UNION SELECT groups_id FROM `groups`) g CROSS JOIN (SELECT 0 c UNION SELECT currencies_id FROM currencies) c;") +subprocess.run(['chown','-R','dunerealms:dunerealms','/home/dunerealms/apps/oscommerce/images/products'],check=True) +print(q('SELECT kind,COUNT(*) FROM dune_catalog_import GROUP BY kind')) diff --git a/website/ops/oscommerce/install-sash-rules.py b/website/ops/oscommerce/install-sash-rules.py new file mode 100644 index 00000000..823b5d06 --- /dev/null +++ b/website/ops/oscommerce/install-sash-rules.py @@ -0,0 +1,18 @@ +from pathlib import Path +import subprocess +app=Path('/home/dunerealms/apps/oscommerce') +p=app/'lib/frontend/components/CartFactory.php';s=p.read_text() +needle=' public static function work() {' +if 'DuneProductRules::validateCartRequest' not in s: + s=s.replace(needle,needle+"\n require_once __DIR__.'/DuneProductRules.php';\n DuneProductRules::validateCartRequest();",1) +s=s.replace(' DuneProductRules::validateCartRequest();',' \\frontend\\components\\DuneProductRules::validateCartRequest();') +p.write_text(s) +p=app/'lib/frontend/themes/basic/boxes/product/attributes/select.tpl';s=p.read_text() +needle='name="attr_text[{$item.id}]"' +if 'maxlength="80"' not in s: + s=s.replace(needle,needle+'{if $item.title == \'Preferred name\'} required maxlength="80" aria-label="Preferred name for embroidery (required)" placeholder="Enter the name to embroider"{/if}',1) +p.write_text(s) +for f in [app/'lib/frontend/components/CartFactory.php',app/'lib/frontend/components/DuneProductRules.php']: + subprocess.run(['php','-l',str(f)],check=True) +subprocess.run(['chown','dunerealms:dunerealms',str(p),str(app/'lib/frontend/components/CartFactory.php'),str(app/'lib/frontend/components/DuneProductRules.php')],check=True) +print('Native embroidery text attribute is required; server rejects missing names and preview purchases.') diff --git a/website/ops/oscommerce/publish-oscommerce-portal.py b/website/ops/oscommerce/publish-oscommerce-portal.py index 83babe40..d3243462 100644 --- a/website/ops/oscommerce/publish-oscommerce-portal.py +++ b/website/ops/oscommerce/publish-oscommerce-portal.py @@ -2,7 +2,7 @@ from pathlib import Path import re,subprocess,urllib.request,urllib.parse app=Path('/home/dunerealms/apps/oscommerce');target=Path('/var/www/dunerealms-shop-portal');target.mkdir(exist_ok=True) html=urllib.request.urlopen('https://www.dunerealms.com/shop.html',timeout=30).read().decode() -html=re.sub(r'(]*\bsrc=")[^"]+',r'\1https://shop.dunerealms.com/catalog/',html,count=1) +html=re.sub(r'(]*\bsrc=")[^"]+',r'\1https://shop.dunerealms.com/catalog/dune-shop?currency=EUR',html,count=1) html=html.replace('src="/shop-embed.js"','src="https://shop.dunerealms.com/oscommerce-embed.js"') def absolute(m): attr,value=m.group(1),m.group(2) @@ -13,11 +13,11 @@ html=re.sub(r'\b(src|href)="([^"]*)"',absolute,html) (target/'index.html').write_text(html) layout=app/'lib/frontend/themes/basic/layouts/main.tpl' original=subprocess.check_output(['runuser','-u','dunerealms','--','git','-C',str(app),'show','HEAD:lib/frontend/themes/basic/layouts/main.tpl'],text=True) -layout.write_text(original.replace('','\n')) +original=original.replace('{$this->title}','DuneRealms Shop') +layout.write_text(original.replace('','\n')) sql="""UPDATE dunerealms_oscommerce.platforms SET is_default=0,status=0 WHERE platform_id IN (1,7,8,9,10); UPDATE dunerealms_oscommerce.platforms SET is_default=1,status=1,platform_name='DuneRealms Shop',platform_owner='DuneRealms',platform_url='shop.dunerealms.com/catalog',platform_url_secure='shop.dunerealms.com/catalog',ssl_enabled=2 WHERE platform_id=7; UPDATE dunerealms_oscommerce.configuration SET configuration_value='DuneRealms Shop' WHERE configuration_key='STORE_NAME'; -UPDATE dunerealms_oscommerce.products SET products_status=0; """ subprocess.run(['mysql'],input=sql,text=True,check=True,capture_output=True) subprocess.run(['chown','dunerealms:dunerealms',str(layout)],check=True) diff --git a/website/scripts/main-menu.mjs b/website/scripts/main-menu.mjs index 4c58c663..b593b6a0 100644 --- a/website/scripts/main-menu.mjs +++ b/website/scripts/main-menu.mjs @@ -1,9 +1,14 @@ -export const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://www.dunerealms.com/shop.html","nav-exchange-full-v2.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kits","https://www.dunerealms.com/kits.html","items/office_water.png"],["Politics","https://www.dunerealms.com/government.html","seals/office-landsraad.png"],["Clans","https://clans.dunerealms.com/","nav-clan-v2.webp"],["Companies","https://corp.dunerealms.com/","guild.webp"],["CP","https://cp.dunerealms.com/","nav-account-v2.webp"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Dunopedia","https://wiki.dunerealms.com/","nav-manual-v2.webp"]]; -export function canonicalMenuHref(value){const u=new URL(value,'https://www.dunerealms.com');if(u.hostname==='dunerealms.com')u.hostname='www.dunerealms.com';if(u.hostname==='www.dunerealms.com'&&/^\/(manual|wiki)\.html$/.test(u.pathname))return'https://wiki.dunerealms.com/';if(u.hostname==='cp.dunerealms.com'&&u.pathname==='/'){if(u.hash==='#shop')return'https://www.dunerealms.com/shop.html';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','corp','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';return u.origin+(u.pathname==='/index.html'?'/':u.pathname);} +export const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://shop.dunerealms.com/","nav-shop-v1.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kits","https://www.dunerealms.com/kits.html","items/office_water.png"],["Politics","https://www.dunerealms.com/government.html","seals/office-landsraad.png"],["Clans","https://clans.dunerealms.com/","nav-clan-v2.webp"],["Companies","https://corp.dunerealms.com/","guild.webp"],["CP","https://cp.dunerealms.com/","nav-account-v2.webp"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Dunopedia","https://wiki.dunerealms.com/","nav-manual-v2.webp"]]; +export function canonicalMenuHref(value){const u=new URL(value,'https://www.dunerealms.com');if(u.hostname==='dunerealms.com')u.hostname='www.dunerealms.com';if(u.hostname==='www.dunerealms.com'&&/^\/(manual|wiki)\.html$/.test(u.pathname))return'https://wiki.dunerealms.com/';if(u.hostname==='cp.dunerealms.com'&&u.pathname==='/'){if(u.hash==='#shop')return'https://shop.dunerealms.com/';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','corp','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';return u.origin+(u.pathname==='/index.html'?'/':u.pathname);} export function normalizeMainMenus(doc,currentUrl,links=MAIN_MENU){let changes=0;const set=(node,key,value)=>{if(node.getAttribute(key)!==value){node.setAttribute(key,value);changes++;}}; for(const nav of doc.querySelectorAll('header nav[aria-label="Main navigation"]')){const old=[...nav.querySelectorAll('a')],ordered=[];for(const[name,href,icon]of links){let a=old.find(x=>!ordered.includes(x)&&canonicalMenuHref(x.href)===href);if(!a){a=doc.createElement('a');changes++;}set(a,'href',href);let image=a.querySelector('img');if(!image){image=doc.createElement('img');a.insertBefore(image,a.firstChild);changes++;}set(image,'src','https://www.dunerealms.com/assets/'+icon);set(image,'alt','');set(image,'width','34');set(image,'height','34');let label=[...a.children].find(x=>x.tagName==='SPAN'&&!x.classList.contains('dune-new-overlay')&&!x.classList.contains('dune-sales-overlay'));if(!label){label=doc.createElement('span');a.append(label);changes++;}set(label,'data-dune-nav-label','1');if(label.textContent!==name){label.textContent=name;changes++;}for(const n of [...a.childNodes])if(n.nodeType===3){n.remove();changes++;}const active=canonicalMenuHref(currentUrl)===href;if(active)set(a,'aria-current','page');else if(a.hasAttribute('aria-current')){a.removeAttribute('aria-current');changes++;}ordered.push(a);} for(const a of old)if(!ordered.includes(a)){a.remove();changes++;}let cursor=nav.firstElementChild;for(const a of ordered){if(a!==cursor){nav.insertBefore(a,cursor);changes++;}cursor=a.nextElementSibling;}} return changes; } export const CANONICAL_MENU_SCRIPT='\n/* Dune canonical menu begin */\n(()=>{if(window.top!==window.self)return;const MAIN_MENU='+JSON.stringify(MAIN_MENU)+';const canonicalMenuHref='+canonicalMenuHref.toString()+';const normalizeMainMenus='+normalizeMainMenus.toString()+';const sync=()=>normalizeMainMenus(document,location.href,MAIN_MENU);sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});})();\n/* Dune canonical menu end */\n'; -export function withCanonicalMenu(script){return script.replace(/\n?\/\* Dune canonical menu begin \*\/[^]*?\/\* Dune canonical menu end \*\/\n?/g,'')+CANONICAL_MENU_SCRIPT;} +export function withCanonicalMenu(script){ + // Older published assets may contain a generated controller without its marker comments. + // Remove both forms before installing the single current controller. + return script.replace(/\n?\/\* Dune canonical menu begin \*\/[^]*?\/\* Dune canonical menu end \*\/\n?/g,'') + .replace(/\(\(\)=>\{if\(window\.top!==window\.self\)return;const MAIN_MENU=[^]*?const sync=\(\)=>normalizeMainMenus\(document,location\.href,MAIN_MENU\);sync\(\);new MutationObserver\(sync\)\.observe\(document\.body,\{childList:true,subtree:true\}\);\}\)\(\);/g,'')+CANONICAL_MENU_SCRIPT; +} diff --git a/website/scripts/menu-updates.mjs b/website/scripts/menu-updates.mjs index e3bfefa6..f11b3be6 100644 --- a/website/scripts/menu-updates.mjs +++ b/website/scripts/menu-updates.mjs @@ -3,6 +3,7 @@ import{existsSync,readFileSync,writeFileSync}from'node:fs';import{execFileSync}f export function pagesForChanges(paths){const pages=new Set();for(let p of paths){p=p.replaceAll('\\','/');if(!p.includes('/tests/')){if(/^website\/(?:web\/portal-navigation\.(?:css|js)|scripts\/(?:portal-navigation|main-menu)\.mjs)$/.test(p))for(const [,href]of MAIN_MENU)pages.add(href);const scopes=[[/postbank|bank-rates/,'bank'],[/politic|election|charter/,'politics'],[/internal-mail|mail-service|post-pages/,'post'],[/organisation-|citizen-directory|account-admin|honours|permissions/,'bureau'],[/forge-pages|dev-request|git-identity/,'forge'],[/exchange-public|commodity/,'market'],[/passport|personal-records|user-pages/,'realm']];for(const [pattern,scope]of scopes)if(pattern.test(p)){pages.add('https://cp.dunerealms.com/');pages.add('https://cp.dunerealms.com/#'+scope);}}if(/website\/node\/staff-roster\.mjs$/.test(p))pages.add('https://www.dunerealms.com/staff.html');if(/website\/node\/memorials\.mjs$|website\/node\/public\/memorial\./.test(p))pages.add('https://www.dunerealms.com/');if(/website\/control-panel\//.test(p)||/website\/node\/(auth|permissions|account-admin|account-archive|honours|profile)\.mjs$/.test(p))pages.add('https://cp.dunerealms.com/');if(/website\/integrations\/azuriom\//.test(p))pages.add('https://www.dunerealms.com/shop.html');if(/website\/integrations\/osticket\//.test(p))pages.add('https://support.dunerealms.com/');if(/website\/web\/([a-z-]+)\.html$/.test(p)){const name=p.match(/([^/]+)\.html$/)[1];pages.add('https://www.dunerealms.com/'+(['index','portal'].includes(name)?'':name+'.html'));}}return[...pages].sort();} export function recordPageUpdates({root=fileURLToPath(new URL('../',import.meta.url)),paths,newPages=[],version=RELEASE_VERSION}={}){if(!/^\d+(?:\.\d+){3}$/.test(version))throw Error('Invalid release');const repo=path.resolve(root,'..');const publication=path.join(root,'publication-changes.json');if(paths===undefined&&existsSync(publication)){const change=JSON.parse(readFileSync(publication,'utf8'));if(!Array.isArray(change.paths)||!Array.isArray(change.added))throw Error('Invalid publication change record.');paths=change.paths;newPages=pagesForChanges(change.added).filter(href=>!href.startsWith('https://cp.dunerealms.com/'));}if(paths===undefined){let changed='';try{const gitRoot=execFileSync('git',['rev-parse','--show-toplevel'],{cwd:repo,encoding:'utf8',stdio:['ignore','pipe','ignore']}).trim();if(path.resolve(gitRoot)===repo)changed=execFileSync('git',['diff','--name-only','HEAD'],{cwd:repo,encoding:'utf8'}).trim();}catch(error){if(error?.status!==128&&error?.status!==129&&error?.code!=='ENOENT')throw error;}paths=changed?changed.split('\n'):[];}const file=path.join(root,'web/menu-new-items.json'),data=JSON.parse(readFileSync(file,'utf8'));const pages=pagesForChanges(paths);if(paths.includes('website/web/release.json')){const releaseFile=path.join(root,'web/release.json');if(existsSync(releaseFile)){const release=JSON.parse(readFileSync(releaseFile,'utf8'));if(release.version===version&&Array.isArray(release.menuUpdates)){const allowed=new Set([...MAIN_MENU.map(([,href])=>href),...['realm','bureau','forge','politics','post','bank','market'].map(id=>'https://cp.dunerealms.com/#'+id)]);for(const update of release.menuUpdates){if(!allowed.has(update.href)||!['NEW','UPDATE'].includes(update.badge))throw Error('Invalid release menu highlight.');if(!pages.includes(update.href))pages.push(update.href);if(update.badge==='NEW'&&!newPages.includes(update.href))newPages.push(update.href);}}}}if(paths.length||existsSync(publication)){for(const item of data.items)delete item.badge;}for(const href of pages){let entry=data.items.find(x=>x.href===href);if(!entry){entry={href};data.items.push(entry);}entry.updatedIn=version;entry.badge=newPages.includes(href)?'NEW':'UPDATE';}if(data.headerBadges){for(const item of data.items){if(!item.href.includes('/#')){delete item.badge;if(['NEW','UPDATE'].includes(data.headerBadges[item.href]))item.badge=data.headerBadges[item.href];}}}writeFileSync(file,JSON.stringify(data,null,2)+'\n');return pages;} export function menuBadgeScript(){const data=JSON.parse(readFileSync(new URL('../web/menu-new-items.json',import.meta.url),'utf8'));return `\n/* Central automatic release menu badges */\n(()=>{let items=${JSON.stringify(data.items)};function mark(){const release=document.querySelector('.dune-release-badge')?.textContent.match(/\\d+(?:\\.\\d+){3}/)?.[0];for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a,#portals .portal[data-id]')){const href=a.matches('#portals .portal')?(document.body.dataset.cpMode==='clan'?'https://clans.dunerealms.com/#':'https://cp.dunerealms.com/#')+a.dataset.id:a.href;const item=items.find(x=>x.href===href),label=['NEW','UPDATE'].includes(item?.badge)?item.badge:null;let tag=a.querySelector('.dune-new-overlay');if(label){if(!tag){tag=document.createElement('span');tag.className='dune-new-overlay';a.append(tag);}if(tag.textContent!==label)tag.textContent=label;tag.classList.toggle('dune-update-overlay',label==='UPDATE');tag.setAttribute('aria-label',label==='NEW'?'New this release':'Updated this release');}else if(tag)tag.remove();}}fetch('https://cp.dunerealms.com/api/menu-badges',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(Array.isArray(data?.items)){items=data.items;mark();}}).catch(()=>{});mark();new MutationObserver(mark).observe(document.body,{childList:true,subtree:true,characterData:true});})();\n`;} -export function withMenuBadges(s){return s.replace(/\n?\/\* Central automatic release menu badges \*\/[\s\S]*?(?=\n\/\*|$)/,'').replace(/\(\(\)=>\{const items=\[[\s\S]*?new MutationObserver\(mark\)\.observe\(document.body,\{childList:true,subtree:true,characterData:true\}\);\}\)\(\);/,'')+menuBadgeScript();} +const legacyMenuBadges=/\(\(\)=>\{(?:let|const) items=\[[^]*?new MutationObserver\(mark\)\.observe\(document.body,\{childList:true,subtree:true,characterData:true\}\);\}\)\(\);/g; +export function withMenuBadges(s){return s.replace(legacyMenuBadges,'').replace(/\n?\/\* Central automatic release menu badges \*\/[\s\S]*?(?=\n\/\*|$)/,'').replace(/\(\(\)=>\{const items=\[[\s\S]*?new MutationObserver\(mark\)\.observe\(document.body,\{childList:true,subtree:true,characterData:true\}\);\}\)\(\);/,'')+menuBadgeScript();} export function patchMenuBadges(root=fileURLToPath(new URL('../',import.meta.url))){const file=path.join(root,'web/portal-navigation.js');writeFileSync(file,withMenuBadges(readFileSync(file,'utf8')));} if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){const pages=recordPageUpdates();patchMenuBadges();console.log('Central release badges updated for '+pages.length+' changed pages.');} diff --git a/website/scripts/portal-navigation.mjs b/website/scripts/portal-navigation.mjs index 3faeccd2..b9a636ee 100644 --- a/website/scripts/portal-navigation.mjs +++ b/website/scripts/portal-navigation.mjs @@ -28,7 +28,7 @@ export function updatePortalNavigation(html){ return updated.replace('',SHARED_HEAD+''); } export function pageContextFor(value,links=PORTAL_LINKS){ - const url=new URL(value),host=url.hostname;if(host==='corp.dunerealms.com')return {label:'Company CP',icon:'clans/vaerkring-v1.png'};if(url.pathname==='/dunemark-collection.html')return {label:'Dunemark Collection',icon:'imperial-postbank-v2.png'};if(url.pathname==='/government.html')return {label:'Realm & Politics',icon:'seals/office-landsraad.png'};if(url.pathname==='/kits.html')return {label:'Kit Exchange',icon:'items/office_water.png'};if(url.pathname==='/shop.html')return {label:'Shop',icon:'nav-exchange-full-v2.webp'}; if(host==='wiki.dunerealms.com')return {label:'Manual/wiki',icon:'nav-manual-full-v2.webp'}; + const url=new URL(value),host=url.hostname;if(host==='shop.dunerealms.com')return {label:'Shop',icon:'nav-shop-v1.webp'};if(host==='corp.dunerealms.com')return {label:'Company CP',icon:'clans/vaerkring-v1.png'};if(url.pathname==='/dunemark-collection.html')return {label:'Dunemark Collection',icon:'imperial-postbank-v2.png'};if(url.pathname==='/government.html')return {label:'Realm & Politics',icon:'seals/office-landsraad.png'};if(url.pathname==='/kits.html')return {label:'Kit Exchange',icon:'items/office_water.png'};if(url.pathname==='/shop.html')return {label:'Shop',icon:'nav-exchange-full-v2.webp'}; if(host==='wiki.dunerealms.com')return {label:'Manual/wiki',icon:'nav-manual-full-v2.webp'}; if(url.pathname.startsWith('/git/'))return {label:'DuneGit',icon:'nav-manual-full-v2.webp'}; if(url.pathname.startsWith('/news/'))return {label:'News dispatch',icon:'nav-discord-full-v2.webp'}; if(url.pathname==='/news-archive.html')return {label:url.searchParams.has('post')?'News dispatch':'News archive',icon:'nav-discord-full-v2.webp'}; diff --git a/website/tests/shop-menu-stability.test.mjs b/website/tests/shop-menu-stability.test.mjs new file mode 100644 index 00000000..849454bc --- /dev/null +++ b/website/tests/shop-menu-stability.test.mjs @@ -0,0 +1,17 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import {readFileSync} from 'node:fs'; +import {withCanonicalMenu,CANONICAL_MENU_SCRIPT,MAIN_MENU} from '../scripts/main-menu.mjs'; +import {withMenuBadges} from '../scripts/menu-updates.mjs'; +test('publication leaves exactly one menu controller, including old unmarked assets',()=>{ + const unmarked=CANONICAL_MENU_SCRIPT.replace(/\/\*[^]*?\*\//g,''); + const source=readFileSync(new URL('../web/portal-navigation.js',import.meta.url),'utf8'); + for(const input of [source,source+unmarked,unmarked+CANONICAL_MENU_SCRIPT]){ + const output=withCanonicalMenu(withMenuBadges(input)); + assert.equal(output.match(/const MAIN_MENU=/g)?.length,1); + assert.equal(output.match(/new MutationObserver\(mark\)/g)?.length,1); + assert.equal(withCanonicalMenu(output),output); + } + assert.equal(MAIN_MENU.find(([name])=>name==='Shop')[1],'https://shop.dunerealms.com/'); + assert.ok(MAIN_MENU.some(([name])=>name==='Companies')); +}); diff --git a/website/tests/shop-profile.test.mjs b/website/tests/shop-profile.test.mjs new file mode 100644 index 00000000..9a5b0c93 --- /dev/null +++ b/website/tests/shop-profile.test.mjs @@ -0,0 +1,8 @@ +import test from 'node:test';import assert from 'node:assert/strict';import {shopAccountProfile}from '../node/integration-shop-profile.mjs'; +test('only the account-linked shop receives the verified contact email, never credentials',async()=>{ + let queried=false;const db={prepare(sql){assert.ok(!/password/i.test(sql));return{bind(id){assert.equal(id,'account');return this},async first(){queried=true;return{address:'person@example.test',verified_at:123}}}}}; + assert.deepEqual(await shopAccountProfile(db,'account','mybb'),{});assert.equal(queried,false); + assert.deepEqual(await shopAccountProfile(db,'account','oscommerce'),{email:'person@example.test',emailVerified:true}); + const missing={prepare(){return{bind(){return this},async first(){return{address:'pending@example.test',verified_at:null}}}}}; + assert.deepEqual(await shopAccountProfile(missing,'account','oscommerce'),{email:null,emailVerified:false}); +}); diff --git a/website/web/oscommerce-inner.js b/website/web/oscommerce-inner.js index d1745a97..810f9d5b 100644 --- a/website/web/oscommerce-inner.js +++ b/website/web/oscommerce-inner.js @@ -1 +1 @@ -(()=>{if(window.parent===window)return;const allowed=new Set(['https://shop.dunerealms.com','https://www.dunerealms.com','https://dunerealms.com','https://cp.dunerealms.com']);let origin;try{origin=new URL(document.referrer).origin;}catch{}if(!allowed.has(origin))return;const send=()=>parent.postMessage({type:'dune-shop-size',height:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)},origin);window.addEventListener('message',e=>{if(e.origin===origin&&e.source===parent&&e.data?.type==='dune-shop-measure')send();});window.addEventListener('load',send);new ResizeObserver(send).observe(document.body);})(); +(()=>{if(window.parent===window)return;const allowed=new Set(['https://shop.dunerealms.com','https://www.dunerealms.com','https://dunerealms.com','https://cp.dunerealms.com']);let origin;try{origin=new URL(document.referrer).origin;}catch{}if(!allowed.has(origin))return;let queued=false,last=0;const send=()=>{if(queued)return;queued=true;requestAnimationFrame(()=>{queued=false;const height=Math.ceil(document.body.getBoundingClientRect().height);if(height>=100&&Math.abs(height-last)>2){last=height;parent.postMessage({type:'dune-shop-size',height},origin);}});};window.addEventListener('message',e=>{if(e.origin===origin&&e.source===parent&&e.data?.type==='dune-shop-measure')send();});window.addEventListener('load',send);new ResizeObserver(send).observe(document.body);})(); diff --git a/website/web/portal-navigation.js b/website/web/portal-navigation.js index 50e7b65d..845c7c64 100644 --- a/website/web/portal-navigation.js +++ b/website/web/portal-navigation.js @@ -48,23 +48,23 @@ /* DuneGit repository footer link */ (()=>{function link(){const foot=document.querySelector('.dune-shared-footer');if(!foot)return;const nav=foot.querySelector('nav');if(!nav)return;let a=nav.querySelector('[data-dune-git-footer]');if(!a){a=document.createElement('a');a.dataset.duneGitFooter='1';nav.append(a);}a.href='https://www.dunerealms.com/git/unimatrix/MC';a.textContent='DuneGit';}link();new MutationObserver(link).observe(document.body,{childList:true});addEventListener('hashchange',link);})(); -/* Dune canonical menu begin */ -(()=>{if(window.top!==window.self)return;const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://shop.dunerealms.com/","nav-shop-v1.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Staff roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kit Exchange","https://www.dunerealms.com/kits.html","items/office_water.png"],["Support center","https://support.dunerealms.com/","nav-support-v2.webp"],["Account center","https://cp.dunerealms.com/","nav-account-v2.webp"],["Clan center","https://clans.dunerealms.com/","nav-clan-v2.webp"],["Dunopedia","https://wiki.dunerealms.com/","nav-manual-v2.webp"]];const canonicalMenuHref=function canonicalMenuHref(value){const u=new URL(value,'https://www.dunerealms.com');if(u.hostname==='dunerealms.com')u.hostname='www.dunerealms.com';if(u.hostname==='www.dunerealms.com'&&/^\/(manual|wiki)\.html$/.test(u.pathname))return'https://wiki.dunerealms.com/';if(u.hostname==='cp.dunerealms.com'&&u.pathname==='/'){if(u.hash==='#shop')return'https://shop.dunerealms.com/';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';return u.origin+(u.pathname==='/index.html'?'/':u.pathname);};const normalizeMainMenus=function normalizeMainMenus(doc,currentUrl,links=MAIN_MENU){let changes=0;const set=(node,key,value)=>{if(node.getAttribute(key)!==value){node.setAttribute(key,value);changes++;}}; - for(const nav of doc.querySelectorAll('header nav[aria-label="Main navigation"]')){const old=[...nav.querySelectorAll('a')],ordered=[];for(const[name,href,icon]of links){let a=old.find(x=>!ordered.includes(x)&&canonicalMenuHref(x.href)===href);if(!a){a=doc.createElement('a');changes++;}set(a,'href',href);let image=a.querySelector('img');if(!image){image=doc.createElement('img');a.insertBefore(image,a.firstChild);changes++;}set(image,'src','https://www.dunerealms.com/assets/'+icon);set(image,'alt','');set(image,'width','34');set(image,'height','34');let label=[...a.children].find(x=>x.tagName==='SPAN'&&!x.classList.contains('dune-new-overlay')&&!x.classList.contains('dune-sales-overlay'));if(!label){label=doc.createElement('span');a.append(label);changes++;}set(label,'data-dune-nav-label','1');if(label.textContent!==name){label.textContent=name;changes++;}for(const n of [...a.childNodes])if(n.nodeType===3){n.remove();changes++;}const active=canonicalMenuHref(currentUrl)===href;if(active)set(a,'aria-current','page');else if(a.hasAttribute('aria-current')){a.removeAttribute('aria-current');changes++;}ordered.push(a);} - for(const a of old)if(!ordered.includes(a)){a.remove();changes++;}let cursor=nav.firstElementChild;for(const a of ordered){if(a!==cursor){nav.insertBefore(a,cursor);changes++;}cursor=a.nextElementSibling;}} - return changes; -};const sync=()=>normalizeMainMenus(document,location.href,MAIN_MENU);sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});})(); -/* Dune canonical menu end */ - /* Public developer API portal link in the shared footer */ (()=>{function sync(){const nav=document.querySelector('.dune-shared-footer nav');if(!nav)return;let a=nav.querySelector('[data-dune-api-footer]');if(!a){a=document.createElement('a');a.dataset.duneApiFooter='1';nav.append(a);}a.href='https://www.dunerealms.com/api.html';a.textContent='Developer API';}sync();new MutationObserver(sync).observe(document.body,{childList:true});})(); (()=>{function sync(){const nav=document.querySelector('.dune-shared-footer nav');if(!nav||nav.querySelector('[data-bank-rates]'))return;const a=document.createElement('a');a.dataset.bankRates='1';a.href='https://www.dunerealms.com/rates-and-charges.html';a.textContent='Rates & Charges';nav.append(a);}sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});})(); -/* Central automatic release menu badges */ -(()=>{let items=[{"href":"https://cp.dunerealms.com/#shop","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://wiki.dunerealms.com/","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://clans.dunerealms.com/","introducedIn":"1.0.0.2","badge":"NEW"},{"href":"https://cp.dunerealms.com/","badge":"NEW","updatedIn":"1.0.1.0","introducedIn":"1.0.1.0"},{"href":"https://cp.dunerealms.com/#exchange","updatedIn":"1.0.0.2","badge":"UPDATE"},{"href":"https://support.dunerealms.com/","updatedIn":"1.0.0.3","badge":"UPDATE"},{"href":"https://www.dunerealms.com/staff.html","updatedIn":"1.0.0.5","badge":"UPDATE"},{"href":"https://www.dunerealms.com/","badge":"NEW","introducedIn":"1.0.0.3","updatedIn":"1.0.0.3"},{"href":"https://shop.dunerealms.com/","updatedIn":"1.0.0.5","badge":"UPDATE"},{"href":"https://www.dunerealms.com/kits.html","introducedIn":"1.0.0.5","badge":"NEW"},{"href":"https://cp.dunerealms.com/#kits-exchange","introducedIn":"1.0.0.5","badge":"NEW"},{"href":"https://cp.dunerealms.com/#realm","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#bureau","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#forge","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#politics","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#post","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#bank","badge":"NEW","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#market","badge":"NEW","introducedIn":"v2-api"},{"href":"https://www.dunerealms.com/rates-and-charges.html","updatedIn":"1.0.1.0","badge":"UPDATE"}];function mark(){const release=document.querySelector('.dune-release-badge')?.textContent.match(/\d+(?:\.\d+){3}/)?.[0];for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a,#portals .portal[data-id]')){const href=a.matches('#portals .portal')?(document.body.dataset.cpMode==='clan'?'https://clans.dunerealms.com/#':'https://cp.dunerealms.com/#')+a.dataset.id:a.href;const item=items.find(x=>x.href===href),label=['NEW','UPDATE'].includes(item?.badge)?item.badge:null;let tag=a.querySelector('.dune-new-overlay');if(label){if(!tag){tag=document.createElement('span');tag.className='dune-new-overlay';a.append(tag);}if(tag.textContent!==label)tag.textContent=label;tag.classList.toggle('dune-update-overlay',label==='UPDATE');tag.setAttribute('aria-label',label==='NEW'?'New this release':'Updated this release');}else if(tag)tag.remove();}}fetch('https://cp.dunerealms.com/api/menu-badges',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(Array.isArray(data?.items)){items=data.items;mark();}}).catch(()=>{});mark();new MutationObserver(mark).observe(document.body,{childList:true,subtree:true,characterData:true});})(); - /* Shared contextual page banner */ (()=>{if(window.top!==window.self)return;const titles={'dunemark-collection.html':['IMPERIAL POSTBANK','The Dunemark Collection'],'staff.html':['STAFF & ORGANISATION','The people behind the realms'],'government.html':['REALM & POLITICS','Government, Houses and elected offices'],'rates-and-charges.html':['IMPERIAL POSTBANK','Rates & Charges'],'shop.html':['DUNEFORGE SHOP','Goods and services for your journey'],'kits.html':['KIT EXCHANGE','Equip your next adventure'],'exchange.html':['CHOAM EXCHANGE','Trade across the realms'],'discord.html':['COMMUNITY DISCORD','The caravan frequency'],'news.html':['NEWS FROM THE REALM','The Imperial Dispatch'],'news-archive.html':['NEWS ARCHIVE','Dispatches from across the realms']}; -function sync(){const marker=document.querySelector('.dune-page-marker');if(!marker)return;if(document.querySelector('.command-banner')){document.querySelector('.dune-context-banner')?.remove();return;}let banner=document.querySelector('.dune-context-banner');if(!banner){banner=document.createElement('section');banner.className='dune-context-banner';const brand=document.createElement('strong');brand.textContent='✦ DuneRealms';const copy=document.createElement('div'),title=document.createElement('span'),sub=document.createElement('small');copy.append(title,sub);banner.append(brand,copy);marker.after(banner);}const file=location.pathname.split('/').pop(),host=location.hostname.split('.')[0],welcome=marker.getAttribute('aria-label')?.replace('Welcome to ','')||'The realms';let context=titles[file]||(['','index.html'].includes(file)&&host==='www'?['HOME','Your journey begins here']:host==='forums'?['COMMUNITY BOARDS','Stories, discussions and community life']:host==='support'?['SUPPORT CENTER','Help for your journey']:host==='clans'?['CLANS & ALLIANCES','Raise your banner']:host==='wiki'?['DUNOPEDIA','Your guide to the realms']:location.pathname.startsWith('/people/')?['CITIZEN PROFILE','The Imperial Citizen Register']:location.pathname.startsWith('/memorial/')?['IN REMEMBRANCE','The community memorial']:['DUNEREALMS',welcome]);const title=banner.children[1].children[0],sub=banner.children[1].children[1];if(title.textContent!==context[0])title.textContent=context[0];if(sub.textContent!==context[1])sub.textContent=context[1];if(marker.nextElementSibling!==banner)marker.after(banner);} +function sync(){const marker=document.querySelector('.dune-page-marker');if(!marker)return;if(document.querySelector('.command-banner')){document.querySelector('.dune-context-banner')?.remove();return;}let banner=document.querySelector('.dune-context-banner');if(!banner){banner=document.createElement('section');banner.className='dune-context-banner';const brand=document.createElement('strong');brand.textContent='✦ DuneRealms';const copy=document.createElement('div'),title=document.createElement('span'),sub=document.createElement('small');copy.append(title,sub);banner.append(brand,copy);marker.after(banner);}const file=location.pathname.split('/').pop(),host=location.hostname.split('.')[0],welcome=marker.getAttribute('aria-label')?.replace('Welcome to ','')||'The realms';let context=titles[file]||(['','index.html'].includes(file)&&host==='www'?['HOME','Your journey begins here']:host==='shop'?['DUNEREALMS SHOP','Ceremonial goods and community support']:host==='forums'?['COMMUNITY BOARDS','Stories, discussions and community life']:host==='support'?['SUPPORT CENTER','Help for your journey']:host==='clans'?['CLANS & ALLIANCES','Raise your banner']:host==='wiki'?['DUNOPEDIA','Your guide to the realms']:location.pathname.startsWith('/people/')?['CITIZEN PROFILE','The Imperial Citizen Register']:location.pathname.startsWith('/memorial/')?['IN REMEMBRANCE','The community memorial']:['DUNEREALMS',welcome]);const title=banner.children[1].children[0],sub=banner.children[1].children[1];if(title.textContent!==context[0])title.textContent=context[0];if(sub.textContent!==context[1])sub.textContent=context[1];if(marker.nextElementSibling!==banner)marker.after(banner);} sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});addEventListener('hashchange',sync);})(); + +/* Central automatic release menu badges */ +(()=>{let items=[{"href":"https://cp.dunerealms.com/#shop","introducedIn":"1.0.0.2"},{"href":"https://wiki.dunerealms.com/","introducedIn":"1.0.0.2","updatedIn":"1.0.0.7"},{"href":"https://clans.dunerealms.com/","introducedIn":"1.0.0.2","updatedIn":"1.0.0.7","badge":"NEW"},{"href":"https://cp.dunerealms.com/","updatedIn":"1.0.0.7","introducedIn":"1.0.1.0","badge":"UPDATE"},{"href":"https://cp.dunerealms.com/#exchange","updatedIn":"1.0.0.2"},{"href":"https://support.dunerealms.com/","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/staff.html","updatedIn":"1.0.0.7","badge":"NEW"},{"href":"https://www.dunerealms.com/","introducedIn":"1.0.0.3","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/shop.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/kits.html","introducedIn":"1.0.0.5","updatedIn":"1.0.0.7"},{"href":"https://cp.dunerealms.com/#kits-exchange","introducedIn":"1.0.0.5"},{"href":"https://cp.dunerealms.com/#realm","introducedIn":"v2-api","updatedIn":"1.0.0.7"},{"href":"https://cp.dunerealms.com/#bureau","introducedIn":"v2-api","updatedIn":"1.0.0.7"},{"href":"https://cp.dunerealms.com/#forge","introducedIn":"v2-api"},{"href":"https://cp.dunerealms.com/#politics","introducedIn":"v2-api","updatedIn":"1.0.0.5"},{"href":"https://cp.dunerealms.com/#post","introducedIn":"v2-api","updatedIn":"1.0.0.7"},{"href":"https://cp.dunerealms.com/#bank","introducedIn":"v2-api","updatedIn":"1.0.0.7"},{"href":"https://cp.dunerealms.com/#market","introducedIn":"v2-api"},{"href":"https://www.dunerealms.com/rates-and-charges.html","updatedIn":"1.0.0.7"},{"href":"https://forums.dunerealms.com/","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/discord.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/exchange.html","updatedIn":"1.0.0.7","badge":"UPDATE"},{"href":"https://www.dunerealms.com/government.html","updatedIn":"1.0.0.7","badge":"NEW"},{"href":"https://www.dunerealms.com/patch-notes.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/account.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/admin.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/api.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/armoury.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/arrakis.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/bans.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/corrino-group.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/diplomacy.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/donate.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/equipment.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/forums.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/install.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/manual.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/news-archive.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/news.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/profile.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/races.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/smugglers.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/tickets.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/wiki.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/account-bans.html","updatedIn":"1.0.0.7"},{"href":"https://www.dunerealms.com/link-account.html","updatedIn":"1.0.0.7"}];function mark(){const release=document.querySelector('.dune-release-badge')?.textContent.match(/\d+(?:\.\d+){3}/)?.[0];for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a,#portals .portal[data-id]')){const href=a.matches('#portals .portal')?(document.body.dataset.cpMode==='clan'?'https://clans.dunerealms.com/#':'https://cp.dunerealms.com/#')+a.dataset.id:a.href;const item=items.find(x=>x.href===href),label=['NEW','UPDATE'].includes(item?.badge)?item.badge:null;let tag=a.querySelector('.dune-new-overlay');if(label){if(!tag){tag=document.createElement('span');tag.className='dune-new-overlay';a.append(tag);}if(tag.textContent!==label)tag.textContent=label;tag.classList.toggle('dune-update-overlay',label==='UPDATE');tag.setAttribute('aria-label',label==='NEW'?'New this release':'Updated this release');}else if(tag)tag.remove();}}fetch('https://cp.dunerealms.com/api/menu-badges',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(Array.isArray(data?.items)){items=data.items;mark();}}).catch(()=>{});mark();new MutationObserver(mark).observe(document.body,{childList:true,subtree:true,characterData:true});})(); + +/* Dune canonical menu begin */ +(()=>{if(window.top!==window.self)return;const MAIN_MENU=[["Home","https://www.dunerealms.com/","nav-home-v2.webp"],["Shop","https://shop.dunerealms.com/","nav-shop-v1.webp"],["Boards","https://forums.dunerealms.com/","nav-boards-v2.webp"],["Roster","https://www.dunerealms.com/staff.html","nav-staff-v2.webp"],["Discord","https://www.dunerealms.com/discord.html","nav-discord-v2.webp"],["Exchange","https://www.dunerealms.com/exchange.html","nav-exchange-v2.webp"],["Kits","https://www.dunerealms.com/kits.html","items/office_water.png"],["Politics","https://www.dunerealms.com/government.html","seals/office-landsraad.png"],["Clans","https://clans.dunerealms.com/","nav-clan-v2.webp"],["Companies","https://corp.dunerealms.com/","guild.webp"],["CP","https://cp.dunerealms.com/","nav-account-v2.webp"],["Support","https://support.dunerealms.com/","nav-support-v2.webp"],["Dunopedia","https://wiki.dunerealms.com/","nav-manual-v2.webp"]];const canonicalMenuHref=function canonicalMenuHref(value){const u=new URL(value,'https://www.dunerealms.com');if(u.hostname==='dunerealms.com')u.hostname='www.dunerealms.com';if(u.hostname==='www.dunerealms.com'&&/^\/(manual|wiki)\.html$/.test(u.pathname))return'https://wiki.dunerealms.com/';if(u.hostname==='cp.dunerealms.com'&&u.pathname==='/'){if(u.hash==='#shop')return'https://shop.dunerealms.com/';if(u.hash==='#exchange')return'https://www.dunerealms.com/exchange.html';}if(['forums','support','cp','clans','corp','wiki'].some(h=>u.hostname===h+'.dunerealms.com'))return u.origin+'/';return u.origin+(u.pathname==='/index.html'?'/':u.pathname);};const normalizeMainMenus=function normalizeMainMenus(doc,currentUrl,links=MAIN_MENU){let changes=0;const set=(node,key,value)=>{if(node.getAttribute(key)!==value){node.setAttribute(key,value);changes++;}}; + for(const nav of doc.querySelectorAll('header nav[aria-label="Main navigation"]')){const old=[...nav.querySelectorAll('a')],ordered=[];for(const[name,href,icon]of links){let a=old.find(x=>!ordered.includes(x)&&canonicalMenuHref(x.href)===href);if(!a){a=doc.createElement('a');changes++;}set(a,'href',href);let image=a.querySelector('img');if(!image){image=doc.createElement('img');a.insertBefore(image,a.firstChild);changes++;}set(image,'src','https://www.dunerealms.com/assets/'+icon);set(image,'alt','');set(image,'width','34');set(image,'height','34');let label=[...a.children].find(x=>x.tagName==='SPAN'&&!x.classList.contains('dune-new-overlay')&&!x.classList.contains('dune-sales-overlay'));if(!label){label=doc.createElement('span');a.append(label);changes++;}set(label,'data-dune-nav-label','1');if(label.textContent!==name){label.textContent=name;changes++;}for(const n of [...a.childNodes])if(n.nodeType===3){n.remove();changes++;}const active=canonicalMenuHref(currentUrl)===href;if(active)set(a,'aria-current','page');else if(a.hasAttribute('aria-current')){a.removeAttribute('aria-current');changes++;}ordered.push(a);} + for(const a of old)if(!ordered.includes(a)){a.remove();changes++;}let cursor=nav.firstElementChild;for(const a of ordered){if(a!==cursor){nav.insertBefore(a,cursor);changes++;}cursor=a.nextElementSibling;}} + return changes; +};const sync=()=>normalizeMainMenus(document,location.href,MAIN_MENU);sync();new MutationObserver(sync).observe(document.body,{childList:true,subtree:true});})(); +/* Dune canonical menu end */ diff --git a/website/web/shop-oscommerce.html b/website/web/shop-oscommerce.html index 6246161c..a01ad209 100644 --- a/website/web/shop-oscommerce.html +++ b/website/web/shop-oscommerce.html @@ -1 +1 @@ -Shop · DuneRealms

Prices are in euro. Available payment methods are shown at checkout. Looking for player-designed kits? Visit the Kit Exchange.

\ No newline at end of file +Shop · DuneRealms

Prices are in euro. Available payment methods are shown at checkout. Looking for player-designed kits? Visit the Kit Exchange.

\ No newline at end of file From 2cc164d06b9e54913495f1d4a12f700e96db09eb Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 16 Nov 2026 17:29:59 +0000 Subject: [PATCH 2/6] Build Dune shop catalogue and repair shared menu publication --- website/ops/oscommerce/DuneProductRules.php | 6 ++-- website/ops/oscommerce/DuneShopController.php | 4 +-- website/ops/oscommerce/README.md | 15 +++++++++ website/ops/oscommerce/dune-shop-cards.css | 2 ++ website/ops/oscommerce/final-shop-settings.py | 31 +++++++++++++++++++ website/ops/oscommerce/install-sash-rules.py | 2 ++ 6 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 website/ops/oscommerce/final-shop-settings.py diff --git a/website/ops/oscommerce/DuneProductRules.php b/website/ops/oscommerce/DuneProductRules.php index e7270fbf..8f6b8e95 100644 --- a/website/ops/oscommerce/DuneProductRules.php +++ b/website/ops/oscommerce/DuneProductRules.php @@ -20,8 +20,10 @@ final class DuneProductRules { $listed=isset($_POST['listqty'][$id]) || isset($_POST['listid'][$id]); if (!$single && !$listed) continue; $value=$single?($_POST['attr_text'][$row['option_id']]??null):($_POST['listattr_text'][$id][$row['option_id']]??null); - try { self::preferredName($value); } - catch(\InvalidArgumentException $e) { self::reject(422,$e->getMessage()); } + if((int)$row['option_id']>0){ + try { self::preferredName($value); } + catch(\InvalidArgumentException $e) { self::reject(422,$e->getMessage()); } + } if($row['preview_only']) self::reject(409,'Collection preview: ordering is currently unavailable.'); } } diff --git a/website/ops/oscommerce/DuneShopController.php b/website/ops/oscommerce/DuneShopController.php index 9899c358..dd8a4228 100644 --- a/website/ops/oscommerce/DuneShopController.php +++ b/website/ops/oscommerce/DuneShopController.php @@ -6,8 +6,8 @@ final class DuneShopController extends Sceleton { public function actionIndex() { $this->view->title='DuneRealms Shop'; $rows=Yii::$app->db->createCommand("SELECT p.products_id,p.products_price,p.products_tax_class_id,pd.products_name,pd.products_description_short,d.kind FROM products p JOIN platforms_products pp ON pp.products_id=p.products_id AND pp.platform_id=7 JOIN products_description pd ON pd.products_id=p.products_id AND pd.language_id=1 AND pd.platform_id=7 LEFT JOIN dune_catalog_import d ON d.products_id=p.products_id WHERE p.products_status=1 ORDER BY p.products_date_added DESC,p.products_id DESC")->queryAll(); - $saleIds=Yii::$app->db->createCommand("SELECT DISTINCT products_id FROM specials WHERE status=1 AND (start_date IS NULL OR start_date='0000-00-00 00:00:00' OR start_date<=NOW()) AND (expires_date IS NULL OR expires_date='0000-00-00 00:00:00' OR expires_date>NOW())")->queryColumn(); - $featuredIds=Yii::$app->db->createCommand("SELECT DISTINCT products_id FROM featured WHERE status=1 AND (start_date IS NULL OR start_date='0000-00-00 00:00:00' OR start_date<=NOW()) AND (expires_date IS NULL OR expires_date='0000-00-00 00:00:00' OR expires_date>NOW())")->queryColumn(); + $saleIds=Yii::$app->db->createCommand("SELECT DISTINCT products_id FROM specials WHERE EXISTS(SELECT 1 FROM products active JOIN platforms_products pp ON pp.products_id=active.products_id AND pp.platform_id=7 WHERE active.products_id=specials.products_id AND active.products_status=1 AND specials.specials_new_products_priceNOW())")->queryColumn(); + $featuredIds=Yii::$app->db->createCommand("SELECT DISTINCT products_id FROM featured WHERE EXISTS(SELECT 1 FROM products active JOIN platforms_products pp ON pp.products_id=active.products_id AND pp.platform_id=7 WHERE active.products_id=featured.products_id AND active.products_status=1) AND status=1 AND (start_date IS NULL OR start_date='0000-00-00 00:00:00' OR start_date<=NOW()) AND (expires_date IS NULL OR expires_date='0000-00-00 00:00:00' OR expires_date>NOW())")->queryColumn(); $sashes=count(array_filter($rows,fn($r)=>$r['kind']==='sash'));$ranks=count(array_filter($rows,fn($r)=>$r['kind']==='rank')); $base=fn($route)=>Html::encode(\yii\helpers\Url::to([$route])); $out='
THE DUNEREALMS EMPORIUM

Carry a piece of the realms.

Ceremonial sashes, personal keepsakes and ways to support the community.

Browse the collection
'; diff --git a/website/ops/oscommerce/README.md b/website/ops/oscommerce/README.md index 966a273c..429eee37 100644 --- a/website/ops/oscommerce/README.md +++ b/website/ops/oscommerce/README.md @@ -12,3 +12,18 @@ Frontend account linking uses the existing API with a dedicated oscommerce SSO c PHP-FPM pool and TLS vhost are separate from Azuriom. Installer paths, .git, configuration, SQL and downloads are denied at the web server. No credentials belong in this directory. Backend theme proposal: Tabler (https://tabler.io), MIT licensed. This requires an adapter; it has not been installed over the native backend. + + +## Catalogue and storefront update + +The portal now embeds `/catalog/dune-shop?currency=EUR`. `DuneShopController.php` belongs in `lib/frontend/controllers/`; `dune-shop-cards.css` is served at the app root and linked by the portal publisher's native layout adapter. + +`import-shop-catalog.py` imports the 12 original sash products and the four mapped donor packages from the preserved Azuriom schema. `dune_catalog_import` records source package IDs and prevents duplicates. The user's existing Aerdrecht product is retained as product 76, including its artwork. Donor manufacturer is DuneRealms; existing rank delivery mappings are recorded, but this importer never grants ranks. + +Sashes are made to order with unlimited stock, a required preferred embroidery name, and standard/silver (+EUR50)/gold (+EUR75) SIDE edging. These options do not alter the bottom cord/fringe. Prices use the installation's current 20% tax setup and source EUR display prices; review real tax and shipping configuration before enabling checkout. All imported products remain previews: no purchasing or fulfillment is enabled. + +`DuneProductRules.php` belongs in `lib/frontend/components/`; `install-sash-rules.py` hooks validation into native cart handling. `finish-catalog-edging.py` and `final-shop-settings.py` complete native option/stock setup. These are controlled, existing-installation migrations, not automatic scripts to run against an arbitrary osCommerce database. + +Shop customers map by central UUID. Verified contact email and username are synchronized after central sign-in; passwords are never retrieved, exposed or copied. Missing verified addresses retain a non-deliverable internal placeholder until a contact email is verified. Email collisions require support rather than silently merging customers. Native customer registration and password pages redirect to central sign-in, including currency-prefixed routes. Native backend roles remain untouched. + +The shared menu and badge publisher strips legacy unmarked controllers before appending the current one. Regression coverage checks both publication idempotence and a single controller/observer. diff --git a/website/ops/oscommerce/dune-shop-cards.css b/website/ops/oscommerce/dune-shop-cards.css index fc80cc0d..c04c2e76 100644 --- a/website/ops/oscommerce/dune-shop-cards.css +++ b/website/ops/oscommerce/dune-shop-cards.css @@ -28,3 +28,5 @@ html,body{height:auto!important;min-height:0!important}.main-content{min-height: .dune-store-welcome{display:flex;align-items:center;justify-content:space-between;gap:28px;border:1px solid #9a8349;border-radius:16px;padding:40px;margin:0 auto 24px;background:linear-gradient(100deg,#0b261aec,#173c2cc7),url('https://www.dunerealms.com/assets/sietch.webp') center/cover;box-shadow:0 12px 30px #0003}.dune-store-welcome small{color:#ceb36e;letter-spacing:.16em;font-size:11px}.dune-store-welcome h1{font-size:clamp(28px,3vw,43px);line-height:1.15;margin:14px 0!important;max-width:600px}.dune-store-welcome p{font-size:15px;line-height:1.7;color:#ccd9c4;max-width:570px;margin-bottom:24px}.dune-store-welcome>img{width:155px;height:155px;object-fit:contain;filter:drop-shadow(0 8px 18px #0008)}.dune-store-button{display:inline-flex!important;align-items:center;justify-content:center;padding:11px 18px;border:1px solid #b79a53;border-radius:8px;background:linear-gradient(#385b39,#23422c);color:#f5e1ad!important;font-size:13px;font-weight:600;text-decoration:none!important;box-shadow:0 4px 12px #0003}.dune-store-button:hover{background:#416345;transform:translateY(-1px)} .dune-store-categories{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:18px;margin-bottom:34px}.dune-store-categories>a{display:flex;align-items:center;gap:16px;padding:22px;border:1px solid #6e7046;border-radius:12px;background:linear-gradient(130deg,#21412e,#112b20);text-decoration:none!important;transition:border-color .15s,transform .15s}.dune-store-categories>a:hover{border-color:#d4b369;transform:translateY(-2px)}.dune-store-categories img{width:58px;height:58px;object-fit:contain}.dune-store-categories h2{font-size:17px!important;margin:0 0 6px!important}.dune-store-categories p{margin:0;color:#afc2aa;font-size:12px;line-height:1.5}.dune-store-categories span{margin-left:auto;color:#dfc37f;font-size:20px}.dune-store-section{margin:0 0 32px;border:1px solid #486143;border-radius:13px;padding:24px;background:#102a20}.dune-store-section>header{display:flex;align-items:center;justify-content:space-between;gap:18px;margin-bottom:22px;padding-bottom:16px;border-bottom:1px solid #425b40}.dune-store-section h2{font-size:23px!important;margin:0 0 7px!important}.dune-store-section header p{margin:0;color:#aabea5;font-size:12px}.dune-store-section header>a{font-size:12px;color:#d9be7b!important;white-space:nowrap}.dune-store-products{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px}.dune-store-products article{display:flex;flex-direction:column;align-items:center;text-align:center;border:1px solid #536a47;border-radius:11px;background:linear-gradient(145deg,#1b3b29,#0c251b);padding:18px;box-sizing:border-box}.dune-store-product-art{display:flex;align-items:center;justify-content:center;width:100%;height:230px;margin-bottom:16px;background:radial-gradient(ellipse,#2f5033,transparent 72%)}.dune-store-product-art img{display:block!important;height:220px!important;max-height:220px!important;max-width:100%!important;width:auto!important;object-fit:contain}.dune-store-products small{font-size:9px;letter-spacing:.12em;color:#b8a66e}.dune-store-products h3{font-size:16px!important;line-height:1.45;margin:10px 0!important}.dune-store-products h3 a{color:#e6d5a3!important;text-decoration:none}.dune-store-price{font-size:23px;font-weight:700;color:#f1d28a;margin:auto 0 16px;padding-top:8px}.dune-store-products .dune-store-button{width:100%;box-sizing:border-box}.dune-store-empty{border:1px dashed #566849;border-radius:9px;padding:26px;color:#afc1a5;text-align:center;font-size:13px;background:#183223}.dune-store-preview{border-left:3px solid #b99850;border-radius:9px;background:#243c28;padding:20px 24px;color:#cad5ba;font-size:13px;line-height:1.7}.dune-store-preview strong{color:#e1c785}.dune-store-preview p{margin:6px 0 0} @media(min-width:1500px){.dune-store-products{grid-template-columns:repeat(4,minmax(0,1fr))}}@media(max-width:900px){.dune-store-categories{grid-template-columns:1fr}.dune-store-products{grid-template-columns:repeat(2,minmax(0,1fr))}.dune-store-welcome{padding:28px}.dune-store-welcome>img{width:110px;height:110px}}@media(max-width:550px){.dune-store-welcome{padding:24px;gap:12px}.dune-store-welcome>img{display:none}.dune-store-products{grid-template-columns:1fr}.dune-store-section{padding:18px}.dune-store-section>header{align-items:flex-start}.dune-store-product-art{height:210px}.dune-store-product-art img{height:200px!important}.header-middle>.block{flex-wrap:wrap!important;justify-content:center!important}.header-middle .w-search{flex-basis:100%!important}} +/* Catalogue navigation, filtering and pagination share the framed dev-alpha system. */ +#box-110903{padding:0!important;background:transparent!important}#box-110904{padding:20px!important;border:1px solid #6b7048!important;border-radius:12px!important;background:linear-gradient(145deg,#1a3b2b,#10291f)!important;box-sizing:border-box!important}#box-110904 h2,#box-110904 h3,#box-110904 .title,.leftCategories .title{color:#e5ce8e!important;font-size:16px!important;font-weight:600!important}.leftCategories ul{list-style:none!important;padding:0!important}.leftCategories a,.w-categories a,.w-menu-simple a{display:block;padding:10px 12px!important;border-radius:7px;color:#d5dfca!important;font-size:13px!important;text-decoration:none!important}.leftCategories a:hover,.w-categories a:hover,.w-menu-simple a:hover{background:#2c4c34!important;color:#f3dd9d!important}.w-catalog-sorting,.w-catalog-items-on-page,.w-catalog-listing-look,.w-catalog-compare-button{padding:10px 12px!important;background:#112b20!important;border:1px solid #4f6544!important;border-radius:8px!important;color:#bfcfb5!important;font-size:12px!important;box-sizing:border-box!important}.w-catalog-sorting select,.w-catalog-items-on-page select{padding:8px 10px!important;border:1px solid #8b7b4b!important;border-radius:7px!important;min-height:36px!important;background:#0b2119!important;color:#eadbb2!important}.w-catalog-counts-items{padding:12px 0!important;font-size:12px!important;color:#aabfa4!important}.w-catalog-paging a,.w-catalog-paging span{border-color:#687146!important;border-radius:6px!important;color:#dfca90!important;background:#163223!important}.w-catalog-paging .active,.w-catalog-paging .current{background:#355237!important;border-color:#bea058!important;color:#fff0c4!important}.w-catalog-listing-look a{color:#e1cb8e!important}.products-listing .item-nav,.products-listing .compare label{color:#bfccb3!important;background:#10291f!important}.products-listing .view-button{min-width:85px!important}.products-listing .instock,.products-listing .in-stock{color:#b6d6ad!important;font-size:12px!important}.w-catalog-b2b-add-button{display:none!important}.w-catalog-title h1{color:#eed99e!important;padding:4px 0!important}.main-content .filter-box,.main-content .filters{border:1px solid #4b6241!important;border-radius:9px!important;padding:14px!important;background:#102b20!important;color:#d3dec7!important}.main-content input[type=checkbox]{accent-color:#b59a53!important}.products-listing .item{transition:border-color .15s,box-shadow .15s}.products-listing .item:hover{border-color:#c5a75c!important;box-shadow:0 10px 28px #0004!important} diff --git a/website/ops/oscommerce/final-shop-settings.py b/website/ops/oscommerce/final-shop-settings.py new file mode 100644 index 00000000..2e05337b --- /dev/null +++ b/website/ops/oscommerce/final-shop-settings.py @@ -0,0 +1,31 @@ +from pathlib import Path +import subprocess,shutil,re +app=Path('/home/dunerealms/apps/oscommerce');repo=Path('/home/dunerealms/oscommerce-integration/website') +sql="""INSERT INTO products_stock_indication(sort_order,is_default,stock_code,allow_out_of_stock_checkout,allow_out_of_stock_add_to_cart,allow_in_stock_notify,display_price_options) +SELECT 10,0,'made-to-order',0,0,0,0 WHERE NOT EXISTS(SELECT 1 FROM products_stock_indication WHERE stock_code='made-to-order'); +INSERT IGNORE INTO products_stock_indication_text(stock_indication_id,language_id,stock_indication_text,stock_indication_short_text) +SELECT stock_indication_id,1,'Made to order','Made to order' FROM products_stock_indication WHERE stock_code='made-to-order'; +UPDATE products p JOIN dune_catalog_import d ON d.products_id=p.products_id AND d.kind='sash' SET p.stock_indication_id=(SELECT stock_indication_id FROM products_stock_indication WHERE stock_code='made-to-order' LIMIT 1),p.manual_stock_unlimited=1; +INSERT IGNORE INTO dune_product_requirements SELECT products_id,0,1 FROM dune_catalog_import WHERE kind='rank'; +UPDATE meta_tags SET meta_tags_value='The collection' WHERE meta_tags_key='HEAD_H1_TAG_PRODUCTS_ALL' AND language_id=1 AND platform_id=7; +UPDATE meta_tags SET meta_tags_value='New arrivals' WHERE meta_tags_key='HEAD_H1_TAG_WHATS_NEW' AND language_id=1 AND platform_id=7; +UPDATE meta_tags SET meta_tags_value='Featured products' WHERE meta_tags_key='HEAD_H1_TAG_FEATURED' AND language_id=1 AND platform_id=7; +""" +subprocess.run(['mysql','dunerealms_oscommerce'],input=sql,text=True,check=True,capture_output=True) +# Use a visible label for native selectable options as well as the custom-name field. +p=app/'lib/frontend/themes/basic/boxes/product/attributes/select.tpl';s=p.read_text() +needle=' 0)}{$item.title|escape:'html'}{/if}\n