Add google_site_verification support for namespaces
- Add google_site_verification column to rb_namespace table - Add settings form field in Stand-alone Mode Settings - Render meta tag on root path when set - Update CLAUDE.md with Alembic migration workflow - Fix development.ini alembic paths
This commit is contained in:
parent
9936b21467
commit
a6c04d565a
7 changed files with 61 additions and 2 deletions
10
CLAUDE.md
10
CLAUDE.md
|
|
@ -24,3 +24,13 @@ Commit message here.
|
|||
- Any fake corporate entities as co-authors
|
||||
|
||||
**Only attribute real humans** as co-authors when collaborating.
|
||||
|
||||
## Database Migrations (Alembic)
|
||||
|
||||
When adding new columns or modifying the database schema:
|
||||
|
||||
1. **Backup SQLite first**: `cp data/remarkbox.sqlite data/remarkbox.sqlite.bak`
|
||||
2. **Add the column to the model** in `remarkbox/models/`
|
||||
3. **Generate migration**: `alembic -c development.ini revision --autogenerate -m "description"`
|
||||
4. **Clean up migration**: Remove extra autogenerated changes, keep only the new field
|
||||
5. **Run migration**: `alembic -c development.ini upgrade head`
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
|
||||
|
||||
[alembic]
|
||||
script_location = remarkbox:scripts/alembic
|
||||
sqlalchemy.url = sqlite:///%(here)s/remarkbox.sqlite
|
||||
script_location = remarkbox/scripts/alembic
|
||||
sqlalchemy.url = sqlite:///%(here)s/data/remarkbox.sqlite
|
||||
|
||||
[app:main]
|
||||
use = egg:remarkbox
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ class Namespace(RBase, Base):
|
|||
owner_request_timestamp = Column(BigInteger, nullable=True)
|
||||
# optional google analytics id for stand alone mode.
|
||||
google_analytics_id = Column(Unicode(18), nullable=True)
|
||||
# optional google site verification code for stand alone mode.
|
||||
google_site_verification = Column(Unicode(128), nullable=True)
|
||||
# allow anyone to edit the root node. (not implemented yet)
|
||||
wiki = Column(Boolean, default=False)
|
||||
# by default we show all nodes but a Namespace can change this behavior.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
"""add google_site_verification column to namespace
|
||||
|
||||
Revision ID: d1213344ca99
|
||||
Revises: 108519de76ac
|
||||
Create Date: 2026-01-11 09:06:53.272415
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'd1213344ca99'
|
||||
down_revision = '108519de76ac'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.add_column('rb_namespace', sa.Column('google_site_verification', sa.Unicode(length=128), nullable=True))
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_column('rb_namespace', 'google_site_verification')
|
||||
|
|
@ -9,6 +9,9 @@
|
|||
<!-- this makes mobile pretty... -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="theme-color" content="#D40000">
|
||||
{% if request.path == '/' and request.namespace.google_site_verification %}
|
||||
<meta name="google-site-verification" content="{{ request.namespace.google_site_verification }}" />
|
||||
{% endif %}
|
||||
|
||||
{% include 'snippets/stylesheet-includes.j2' %}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,12 @@ You can host your own CSS file and link it here.
|
|||
<br>
|
||||
<br>
|
||||
|
||||
<label>Google Site Verification:</label>
|
||||
<input type="text" name="google-site-verification" id="google-site-verification" value="{% if request.namespace.google_site_verification %}{{ request.namespace.google_site_verification }}{% endif %}" class="common-text-input" placeholder="Google Site Verification code for Stand-alone Mode"></input>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
{% set submit_button_classes = 'button-right green-button' %}
|
||||
{% set submit_button_value = 'save changes' %}
|
||||
{% include 'snippets/submit.j2' %}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,9 @@ def namespace_settings(request):
|
|||
google_analytics_id = p.get(
|
||||
"google-analytics-id", request.namespace.google_analytics_id
|
||||
)
|
||||
google_site_verification = p.get(
|
||||
"google-site-verification", request.namespace.google_site_verification
|
||||
)
|
||||
|
||||
hide_unless_approved_checkbox = p.get("hide-unless-approved-checkbox", "off")
|
||||
allow_anonymous_checkbox = p.get("allow-anonymous-checkbox", "off")
|
||||
|
|
@ -137,6 +140,17 @@ def namespace_settings(request):
|
|||
)
|
||||
)
|
||||
|
||||
if google_site_verification != request.namespace.google_site_verification and (
|
||||
google_site_verification or request.namespace.google_site_verification
|
||||
):
|
||||
request.namespace.google_site_verification = google_site_verification
|
||||
request.session.flash(
|
||||
(
|
||||
"Success, you changed the Google Site Verification code for stand alone mode.",
|
||||
"success",
|
||||
)
|
||||
)
|
||||
|
||||
if hide_unless_approved != request.namespace.hide_unless_approved:
|
||||
request.namespace.hide_unless_approved = hide_unless_approved
|
||||
request.session.flash(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue