0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-18 02:21:47 -05:00

Wired up the social and copy link buttons

This commit is contained in:
Sodbileg Gansukh 2024-08-06 17:36:00 +08:00
parent c513252c9a
commit 3d49e01e6a
4 changed files with 46 additions and 21 deletions

View file

@ -1,4 +1,4 @@
{{#if this.post.featureImage}}
{{#if (and this.post.featureImage (not this.post.emailOnly))}}
<figure class="modal-image">
<img src="{{this.post.featureImage}}" alt="{{this.post.title}}">
</figure>
@ -75,7 +75,7 @@
<button
class="gh-btn twitter"
type="button"
{{!-- {{on "click" this.close}} --}}
{{on "click" this.handleTwitter}}
{{on "mousedown" (optional this.noop)}}
>
<span>{{svg-jar "social-x"}}</span>
@ -83,7 +83,7 @@
<button
class="gh-btn threads"
type="button"
{{!-- {{on "click" this.close}} --}}
{{on "click" this.handleThreads}}
{{on "mousedown" (optional this.noop)}}
>
<span>{{svg-jar "social-threads"}}</span>
@ -91,7 +91,7 @@
<button
class="gh-btn facebook"
type="button"
{{!-- {{on "click" this.close}} --}}
{{on "click" this.handleFacebook}}
{{on "mousedown" (optional this.noop)}}
>
<span>{{svg-jar "social-facebook"}}</span>
@ -99,19 +99,16 @@
<button
class="gh-btn linkedin"
type="button"
{{!-- {{on "click" this.close}} --}}
{{on "click" this.handleLinkedIn}}
{{on "mousedown" (optional this.noop)}}
>
<span>{{svg-jar "social-linkedin"}}</span>
</button>
<button
class="gh-btn gh-btn-primary"
type="button"
{{!-- {{on "click" this.close}} --}}
{{on "mousedown" (optional this.noop)}}
>
<span>{{svg-jar "twitter-link"}} Copy link</span>
</button>
<GhTaskButton
@buttonText="Copy link"
@task={{this.handleCopyClick}}
@successText="Link copied"
@class="gh-btn gh-btn-primary gh-btn-icon" />
{{else}}
{{#if this.post.emailOnly}}
{{#if this.post.isScheduled}}

View file

@ -1,5 +1,8 @@
import ModalComponent from 'ghost-admin/components/modal-base';
import copyTextToClipboard from 'ghost-admin/utils/copy-text-to-clipboard';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
import {task, timeout} from 'ember-concurrency';
export default class ModalPublishFlow extends ModalComponent {
@service store;
@ -13,4 +16,31 @@ export default class ModalPublishFlow extends ModalComponent {
get postCount() {
return this.model.postCount;
}
@action
handleTwitter() {
window.open(`https://twitter.com/intent/tweet?url=${encodeURI(this.post.url)}`, '_blank');
}
@action
handleThreads() {
window.open(`https://threads.net/intent/post?text=${encodeURI(this.post.url)}`, '_blank');
}
@action
handleFacebook() {
window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURI(this.post.url)}`, '_blank');
}
@action
handleLinkedIn() {
window.open(`http://www.linkedin.com/shareArticle?mini=true&url=${encodeURI(this.post.url)}`, '_blank');
}
@task
*handleCopyClick() {
copyTextToClipboard(this.post.url);
yield timeout(1000);
return true;
}
}

View file

@ -15,10 +15,10 @@ export default class PostsList extends Component {
this.checkPublishFlowModal();
}
checkPublishFlowModal() {
async checkPublishFlowModal() {
if (localStorage.getItem('ghost-last-scheduled-post')) {
this.getLatestScheduledPost.perform();
// this.showPublishFlowModal = true;
await this.getLatestScheduledPost.perform();
this.showPublishFlowModal = true;
localStorage.removeItem('ghost-last-scheduled-post');
}
}
@ -36,6 +36,5 @@ export default class PostsList extends Component {
*getLatestScheduledPost() {
const result = yield this.store.query('post', {filter: `id:${localStorage.getItem('ghost-last-scheduled-post')}`, limit: 1});
this.latestScheduledPost = result.toArray()[0];
this.showPublishFlowModal = true;
}
}

View file

@ -41,10 +41,10 @@ export default class Analytics extends Component {
this.checkPublishFlowModal();
}
checkPublishFlowModal() {
async checkPublishFlowModal() {
if (localStorage.getItem('ghost-last-published-post')) {
this.fetchPostCountTask.perform();
// this.showPublishFlowModal = true;
await this.fetchPostCountTask.perform();
this.showPublishFlowModal = true;
localStorage.removeItem('ghost-last-published-post');
}
}
@ -333,7 +333,6 @@ export default class Analytics extends Component {
this.postCount = count;
}
this.showPublishFlowModal = true;
}
get showLinks() {