Bhupesh-V / tutorialdb

A search 🔎 engine for programming/dev tutorials,
MIT License
121 stars 60 forks source link

Make See Docs button act more like a button #45

Closed liorbentov closed 4 years ago

liorbentov commented 4 years ago

This resolves issue #53

Animesh-Ghosh commented 4 years ago

Is there any way to keep the expand/collapse triangle?

liorbentov commented 4 years ago

@Animesh-Ghosh , @Bhupesh-V with which configuration you can't see the triangle? I've tested my branch on desktop and on mobile and I see it

Animesh-Ghosh commented 4 years ago

Cross check settings.py:

import os

from dotenv import load_dotenv
load_dotenv()

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SECRET_KEY = os.environ['SECRET_KEY']

DEBUG = True

ALLOWED_HOSTS = [
    '127.0.0.1',
    os.environ['LOCAL_HOST'], # your local IP to test the site on your network,
    'tutorialdb.pythonanywhere.com',
    'tutorialdb-app.herokuapp.com'
]

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'app',
    'api',
    'taggie',
    'import_export',
]

REST_FRAMEWORK = {
    'DEFAULT_THROTTLE_CLASSES': [
        'rest_framework.throttling.AnonRateThrottle',
        'rest_framework.throttling.UserRateThrottle'
    ],
    'DEFAULT_THROTTLE_RATES': {
        'anon': '100/day',
        'user': '100/day'
    },
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
    'PAGE_SIZE': 10
}

MIDDLEWARE = [
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'tutorialdb.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'tutorialdb.wsgi.application'

# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-IN'

TIME_ZONE = 'Asia/Kolkata'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'
STATIC_ROOT = os.environ['STATIC_ROOT']

# STATICFILES_DIRS = [os.path.join('static'),] # additional directories to collectstatic from, shouldn't contain STATIC_ROOT
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'

Cross check customCSS.css:

a.navbar-item {
  cursor: pointer;
  color: white;
}
.navbar-menu {
  background-color: #2B2828;
  box-shadow: 0 8px 16px rgba(10,10,10,.1);
  padding: .5rem 0;
}
.customBurger{
    background-color: white;
}
#shareIcon {
    display: none;
}
@media only screen and (min-device-width : 320px) and (max-device-width : 480px){ 
    #shareIcon { 
        display: inline;
    }
}
#tutorial-tag {
    color: blue;
}
summary.title {
    cursor: pointer;
    display: inline-block;
    outline: none;
}

Output at http://127.0.0.1:8000/api/: See docs.

The cursor does point when it's hovered over it, but the triangle has disappeared.

liorbentov commented 4 years ago

Thanks, I think we have a difference in the settings file, I'm checking it now

liorbentov commented 4 years ago

@Animesh-Ghosh, using your settings.py, I get an error:

  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/Users/lior/Personal/dev/venv/tutorialdb/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/Users/lior/Personal/dev/venv/tutorialdb/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 325, in execute
    settings.INSTALLED_APPS
  File "/Users/lior/Personal/dev/venv/tutorialdb/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 79, in __getattr__
    self._setup(name)
  File "/Users/lior/Personal/dev/venv/tutorialdb/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 66, in _setup
    self._wrapped = Settings(settings_module)
  File "/Users/lior/Personal/dev/venv/tutorialdb/venv/lib/python3.6/site-packages/django/conf/__init__.py", line 157, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/Users/lior/Personal/dev/venv/tutorialdb/venv/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/lior/Personal/dev/venv/tutorialdb/tutorialdb/settings.py", line 122, in <module>
    STATIC_ROOT = os.environ['STATIC_ROOT']
  File "/Users/lior/Personal/dev/venv/tutorialdb/venv/bin/../lib/python3.6/os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'STATIC_ROOT'
zsh: exit 1     python manage.py runserver
Animesh-Ghosh commented 4 years ago

Did you set STATIC_ROOT in your .env file?

Just set it as the absolute PATH to the /static/ directory since that's where collectstatic collects the static files.

Don't forget to run collectstatic as well if you haven't.

liorbentov commented 4 years ago

@Animesh-Ghosh @Bhupesh-V - It seems like FF doesn't like display: inline-block for summary tag. This solution was tested on Chrome, FF and Android

Bhupesh-V commented 4 years ago

@liorbentov thanks a lot for this PR :blue_heart: and sorry for the mess up in #46 :sweat_smile:

Bhupesh-V commented 4 years ago

@all-contributors please add @liorbentov for code, bug and design

allcontributors[bot] commented 4 years ago

@Bhupesh-V

I've put up a pull request to add @liorbentov! :tada: