Skip to content

Commit

Permalink
add poem from author page buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
star8ks committed Jun 1, 2023
1 parent ed93a14 commit 4c9668a
Show file tree
Hide file tree
Showing 10 changed files with 369 additions and 173 deletions.
40 changes: 31 additions & 9 deletions app/Http/Controllers/PoemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,22 @@ public function create() {
$poem->original_id = $originalPoem->id;
$poem->is_original = 0;
}
if ($a = request()->get('author_fake_id')) {
$author = Author::findOrFail(Author::getIdFromFakeId($a));
$mode = 'create poem by author';
$preset = new Poem();
$preset->poet_id = $author->id;
$preset->poet = $author->label;
$preset->poet_cn = $author->label_cn;
}
if ($presetTranslatorFakeID = request()->get('translator_fake_id')) {
$translator = Author::findOrFail(Author::getIdFromFakeId($presetTranslatorFakeID));
$mode = 'create poem by translator';
$poem->is_original = 0;
$poem->translator_ids = [$translator->id];
$poem->translator = $translator->label;
$poem['#translators_label_arr'] = $poem->translatorsLabelArr;
}

if ($preset) {
$poem->poet_id = $preset->poet_id;
Expand All @@ -132,17 +148,23 @@ public function create() {
$poem['#user_name'] = Auth::user()->name;
$poem['poem'] = "\n\n\n\n\n\n";

$deftaultAuthors = ($preset && $preset->poetLabel) ? AuthorRepository::searchLabel($preset->poetLabel, [$preset->poet_id]) : [];
$deftaultAuthors = ($preset && $preset->poetLabel)
? AuthorRepository::searchLabel($preset->poetLabel, [$preset->poet_id])
: [];
$defaultTranslators = $mode === 'create poem by translator'
? AuthorRepository::searchLabel($poem->translatorsStr, $poem->translator_ids)
: [];

return view('poems.create', [
'poem' => $poem,
'trans' => $this->trans(),
'languageList' => LanguageRepository::allInUse(),
'genreList' => Genre::select('name_lang', 'id')->get(),
'translatedPoem' => $translatedPoem ?? null, // TODO don't pass translatedPoem
'originalPoem' => $originalPoem ?? null, // TODO don't pass originalPoem
'defaultAuthors' => $deftaultAuthors, //Author::select('name_lang', 'id')->limit(10)->get()->toArray(),
'mode' => $mode
'poem' => $poem,
'trans' => $this->trans(),
'languageList' => LanguageRepository::allInUse(),
'genreList' => Genre::select('name_lang', 'id')->get(),
'translatedPoem' => $translatedPoem ?? null, // TODO don't pass translatedPoem
'originalPoem' => $originalPoem ?? null, // TODO don't pass originalPoem
'defaultAuthors' => $deftaultAuthors, //Author::select('name_lang', 'id')->limit(10)->get()->toArray(),
'defaultTranslators' => $defaultTranslators,
'mode' => $mode
]);
}

Expand Down
1 change: 1 addition & 0 deletions resources/js/poem/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Vue.component('poem-form', {
translator_wikidata_id: null,
is_owner_uploaded: 0,
'#user_name': '',
'#translators_label_arr': [],
original_link: ''
},

Expand Down
3 changes: 2 additions & 1 deletion resources/js/poem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import '../bootstrap';
import VeeValidate, { Validator } from 'vee-validate';
import zh_CN from "vee-validate/dist/locale/zh_CN";
import en from "vee-validate/dist/locale/en";
// import VModal from 'vue-js-modal';
import VModal from 'vue-js-modal';


// Vue.component('multiselect', Multiselect);
Vue.use(VeeValidate, {strict: true});
Vue.use(VModal, { dialog: true, dynamic: true, injectModalsContainer: true });

zh_CN.messages.required = function(n) {
return n+"是必填的";
Expand Down
68 changes: 26 additions & 42 deletions resources/sass/author.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
display: none;
}
input[type="radio"]:checked + label {
background: $alabaster;
border-left-color: $alabaster;
border-right-color: $alabaster;
background: #fff;
font-weight: bold;
color: $default-text-color;
}

input[type="radio"]:checked + label + .tab {
display: block;
}
Expand All @@ -20,38 +21,24 @@
order: 1;
padding: 1rem 2rem;
cursor: pointer;
font-weight: bold;
margin-right: .2rem;
border-color: $border-color;
border-style: solid;
border-width: 1px 1px 0 1px;
}

.tab {
order: 9;
flex-grow: 1;
order: 2;
width: 100%;
height: 100%;
display: none;
padding: 1rem;
background: $alabaster;
}

@media (max-width: 465px) {
.tab,
label {
order: initial;
}

label {
width: 100%;
margin-left: 50px;
}
}
}

// author page
article.poet{
padding: 1rem 1.6rem 2rem;

.author-relate {
color: $gray;
Expand Down Expand Up @@ -125,30 +112,27 @@ article.poet{
padding-left: 0;
//line-height: 3em;
}
details{
display: inline;
position: relative;
summary{
&::marker{
color: $text-muted;
font-size: $font-size-sm-in-px;
}
&:hover::marker{
color: $default-text-color;
background-color: $gray;
}

.tabs-desc {
input[type="radio"]:checked + label {
background: $alabaster;
border-left-color: $alabaster;
border-right-color: $alabaster;
}
.tab {
background: $alabaster;
min-height: 2em;
}
}
.tabs-poems {
label {
padding-bottom: 0;
color: $text-muted;
border: none;
padding-left: 0;
}
&[open]>summary{
height: 1em;
line-height: 1em;
width: 2em;
position: absolute;
bottom: -.5em;
right: -.5em;
z-index: 1;
&::marker{
content: '收起';
}
.tab {
padding: 0;
}
}
}
90 changes: 87 additions & 3 deletions resources/sass/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,88 @@
@import 'poemwiki.scss';
@import '_variables';

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 47.4% 11.2%;

--link: 222.52 100% 49.8%;
--muted : 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;

--popover : 0 0% 100%;
--popover-foreground: 222.2 47.4% 11.2%;

--card : 0 0% 100%;
--card-foreground: 222.2 47.4% 11.2%;

--border: 214.3 31.8% 91.4%;
--input : 214.3 31.8% 91.4%;

--primary : 222.2 47.4% 11.2%;
--primary-foreground: 0 0% 100%;

--secondary : 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;

--accent : 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;

--destructive : 0 100% 50%;
--destructive-foreground: 210 40% 98%;

--ring: 215 20.2% 65.1%;

--radius: 0.5rem;
--alabaster: $alabaster;
}

.dark {
--background: 224 71% 4%;
--foreground: 213 31% 91%;

--muted : 223 47% 11%;
--muted-foreground: 215.4 16.3% 56.9%;

--popover : 224 71% 4%;
--popover-foreground: 215 20.2% 65.1%;

--card : 224 71% 4%;
--card-foreground: 213 31% 91%;

--link: 222.52 100% 90%;
--border: 216 34% 17%;
--input : 216 34% 17%;

--primary : 210 40% 98%;
--primary-foreground: 222.2 47.4% 1.2%;

--secondary : 222.2 47.4% 11.2%;
--secondary-foreground: 210 40% 98%;

--accent : 216 34% 17%;
--accent-foreground: 210 40% 98%;

--destructive : 0 63% 31%;
--destructive-foreground: 210 40% 98%;

--ring: 216 34% 17%;

--radius: 0.5rem;
}
}

@layer base {
* {
@apply border-border;
}

body {
@apply bg-background text-foreground;
font-feature-settings: "rlig" 1, "calt" 1;
}
}

:root {
--main-color: transparent;
--main-color-next: transparent;
Expand Down Expand Up @@ -104,7 +186,7 @@ body{
width: theme('screens.md.min');
}
.page{
padding: 2rem 1.6rem;
padding: 2rem 1.6rem 6rem;
}
}
}
Expand Down Expand Up @@ -217,7 +299,7 @@ body{
position: relative;
width: 100%;
>a.title{
padding: 1em 0 0 0;
padding: .8em 0 0 0;
width: 100%;
display: inline-block;
color: $blue;
Expand All @@ -243,9 +325,11 @@ body{
}

.first-line{
padding-left: $font-size-larger-in-px;
position: relative;
}
.title-bar+.first-line {
padding-left: $font-size-larger-in-px;
}
}

.show-first-line .first-line>span{
Expand Down
Loading

0 comments on commit 4c9668a

Please sign in to comment.